CVE-2016-5388
Description
Apache Tomcat 7.x through 7.0.70 and 8.x through 8.5.4, when the CGI Servlet is enabled, follows RFC 3875 section 4.1.18 and therefore does not protect applications from the presence of untrusted client data in the HTTP_PROXY environment variable, which might allow remote attackers to redirect an application's outbound HTTP traffic to an arbitrary proxy server via a crafted Proxy header in an HTTP request, aka an "httpoxy" issue. NOTE: the vendor states "A mitigation is planned for future releases of Tomcat, tracked as CVE-2016-5388"; in other words, this is not a CVE ID for a vulnerability.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
org.apache.tomcat:tomcat-catalinaMaven | >= 7.0.0, < 7.0.72 | 7.0.72 |
org.apache.tomcat:tomcat-catalinaMaven | >= 8.0.0, < 8.5.5 | 8.5.5 |
Patches
3880250877b06Add a new initialisation parameter, envHttpHeaders, to the CGI Servlet to mitigate httpoxy (CVE-2016-5388) by default and to provide a mechanism that can be used to mitigate any future, similar issues.
4 files changed · +40 −7
conf/web.xml+10 −1 modified@@ -329,6 +329,15 @@ <!-- executable Name of the executable used to run the --> <!-- script. [perl] --> <!-- --> + <!-- envHttpHeaders A regular expression used to select the HTTP --> + <!-- headers passed to the CGI process as --> + <!-- environment variables. Note that headers are --> + <!-- converted to upper case before matching and --> + <!-- that the entire header name must match the --> + <!-- pattern. --> + <!-- [ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST| --> + <!-- IF-[-0-9A-Z]*|REFERER|USER-AGENT] --> + <!-- --> <!-- parameterEncoding Name of parameter encoding to be used with --> <!-- CGI servlet. --> <!-- [System.getProperty("file.encoding","UTF-8")] --> @@ -348,7 +357,7 @@ <param-name>cgiPathPrefix</param-name> <param-value>WEB-INF/cgi</param-value> </init-param> - <load-on-startup>5</load-on-startup> + <load-on-startup>5</load-on-startup> </servlet> -->
java/org/apache/catalina/servlets/CGIServlet.java+17 −6 modified@@ -35,6 +35,7 @@ import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.Vector; +import java.util.regex.Pattern; import javax.servlet.RequestDispatcher; import javax.servlet.ServletConfig; @@ -268,6 +269,16 @@ public final class CGIServlet extends HttpServlet { */ private long stderrTimeout = 2000; + /** + * The regular expression used to select HTTP headers to be passed to the + * CGI process as environment variables. The name of the environment + * variable will be the name of the HTTP header converter to upper case, + * prefixed with <code>HTTP_</code> and with all <code>-</code> characters + * converted to <code>_</code>. + */ + private Pattern envHttpHeadersPattern = Pattern.compile( + "ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST|IF-[-0-9A-Z]*|REFERER|USER-AGENT"); + /** object used to ensure multiple threads don't try to expand same file */ private static final Object expandFileLock = new Object(); @@ -329,6 +340,10 @@ public void init(ServletConfig config) throws ServletException { "stderrTimeout")); } + if (getServletConfig().getInitParameter("envHttpHeaders") != null) { + envHttpHeadersPattern = + Pattern.compile(getServletConfig().getInitParameter("envHttpHeaders")); + } } @@ -989,12 +1004,8 @@ protected boolean setCGIEnvironment(HttpServletRequest req) throws IOException { //REMIND: rewrite multiple headers as if received as single //REMIND: change character set //REMIND: I forgot what the previous REMIND means - if ("AUTHORIZATION".equalsIgnoreCase(header) || - "PROXY_AUTHORIZATION".equalsIgnoreCase(header)) { - //NOOP per CGI specification section 11.2 - } else { - envp.put("HTTP_" + header.replace('-', '_'), - req.getHeader(header)); + if (envHttpHeadersPattern.matcher(header).matches()) { + envp.put("HTTP_" + header.replace('-', '_'), req.getHeader(header)); } }
webapps/docs/cgi-howto.xml+6 −0 modified@@ -103,6 +103,12 @@ if your script is itself executable (e.g. an exe file). Default is <li><strong>executable-arg-1</strong>, <strong>executable-arg-2</strong>, and so on - additional arguments for the executable. These precede the CGI script name. By default there are no additional arguments.</li> +<li><strong>envHttpHeaders</strong> - A regular expression used to select the +HTTP headers passed to the CGI process as environment variables. Note that +headers are converted to upper case before matching and that the entire header +name must match the pattern. Default is +<code>ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST|IF-[-0-9A-Z]*|REFERER|USER-AGENT</code> +</li> <li><strong>parameterEncoding</strong> - Name of the parameter encoding to be used with the CGI servlet. Default is <code>System.getProperty("file.encoding","UTF-8")</code>. That is the system
webapps/docs/changelog.xml+7 −0 modified@@ -130,6 +130,13 @@ Switch the CGI servlet to the standard logging mechanism and remove support for the debug attribute. (markt) </fix> + <add> + Add a new initialisation parameter, <code>envHttpHeaders</code>, to + the CGI Servlet to mitigate <a href="https://httpoxy.org">httpoxy</a> + (<a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-5388" + >CVE-2016-5388</a>) by default and to provide a mechanism that can be + used to mitigate any future, similar issues. (markt) + </add> </changelog> </subsection> <subsection name="Coyote">
1b91e91194a0Add a new initialisation parameter, envHttpHeaders, to the CGI Servlet to mitigate httpoxy (CVE-2016-5388) by default and to provide a mechanism that can be used to mitigate any future, similar issues.
4 files changed · +40 −7
conf/web.xml+10 −1 modified@@ -334,6 +334,15 @@ <!-- executable Name of the executable used to run the --> <!-- script. [perl] --> <!-- --> + <!-- envHttpHeaders A regular expression used to select the HTTP --> + <!-- headers passed to the CGI process as --> + <!-- environment variables. Note that headers are --> + <!-- converted to upper case before matching and --> + <!-- that the entire header name must match the --> + <!-- pattern. --> + <!-- [ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST| --> + <!-- IF-[-0-9A-Z]*|REFERER|USER-AGENT] --> + <!-- --> <!-- parameterEncoding Name of parameter encoding to be used with --> <!-- CGI servlet. --> <!-- [System.getProperty("file.encoding","UTF-8")] --> @@ -353,7 +362,7 @@ <param-name>cgiPathPrefix</param-name> <param-value>WEB-INF/cgi</param-value> </init-param> - <load-on-startup>5</load-on-startup> + <load-on-startup>5</load-on-startup> </servlet> -->
java/org/apache/catalina/servlets/CGIServlet.java+17 −6 modified@@ -35,6 +35,7 @@ import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.Vector; +import java.util.regex.Pattern; import javax.servlet.RequestDispatcher; import javax.servlet.ServletConfig; @@ -265,6 +266,16 @@ public final class CGIServlet extends HttpServlet { */ private long stderrTimeout = 2000; + /** + * The regular expression used to select HTTP headers to be passed to the + * CGI process as environment variables. The name of the environment + * variable will be the name of the HTTP header converter to upper case, + * prefixed with <code>HTTP_</code> and with all <code>-</code> characters + * converted to <code>_</code>. + */ + private Pattern envHttpHeadersPattern = Pattern.compile( + "ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST|IF-[-0-9A-Z]*|REFERER|USER-AGENT"); + /** object used to ensure multiple threads don't try to expand same file */ private static final Object expandFileLock = new Object(); @@ -326,6 +337,10 @@ public void init(ServletConfig config) throws ServletException { "stderrTimeout")); } + if (getServletConfig().getInitParameter("envHttpHeaders") != null) { + envHttpHeadersPattern = + Pattern.compile(getServletConfig().getInitParameter("envHttpHeaders")); + } } @@ -963,12 +978,8 @@ protected boolean setCGIEnvironment(HttpServletRequest req) throws IOException { //REMIND: rewrite multiple headers as if received as single //REMIND: change character set //REMIND: I forgot what the previous REMIND means - if ("AUTHORIZATION".equalsIgnoreCase(header) || - "PROXY_AUTHORIZATION".equalsIgnoreCase(header)) { - //NOOP per CGI specification section 11.2 - } else { - envp.put("HTTP_" + header.replace('-', '_'), - req.getHeader(header)); + if (envHttpHeadersPattern.matcher(header).matches()) { + envp.put("HTTP_" + header.replace('-', '_'), req.getHeader(header)); } }
webapps/docs/cgi-howto.xml+6 −0 modified@@ -103,6 +103,12 @@ if your script is itself executable (e.g. an exe file). Default is <li><strong>executable-arg-1</strong>, <strong>executable-arg-2</strong>, and so on - additional arguments for the executable. These precede the CGI script name. By default there are no additional arguments.</li> +<li><strong>envHttpHeaders</strong> - A regular expression used to select the +HTTP headers passed to the CGI process as environment variables. Note that +headers are converted to upper case before matching and that the entire header +name must match the pattern. Default is +<code>ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST|IF-[-0-9A-Z]*|REFERER|USER-AGENT</code> +</li> <li><strong>parameterEncoding</strong> - Name of the parameter encoding to be used with the CGI servlet. Default is <code>System.getProperty("file.encoding","UTF-8")</code>. That is the system
webapps/docs/changelog.xml+7 −0 modified@@ -146,6 +146,13 @@ <code>StandardRoot</code> instance now invalidate the cache if caching is enabled. (markt) </fix> + <add> + Add a new initialisation parameter, <code>envHttpHeaders</code>, to + the CGI Servlet to mitigate <a href="https://httpoxy.org">httpoxy</a> + (<a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-5388" + >CVE-2016-5388</a>) by default and to provide a mechanism that can be + used to mitigate any future, similar issues. (markt) + </add> </changelog> </subsection> <subsection name="Coyote">
fb3569fbb9a2Add a new initialisation parameter, envHttpHeaders, to the CGI Servlet to mitigate httpoxy (CVE-2016-5388) by default and to provide a mechanism that can be used to mitigate any future, similar issues.
4 files changed · +40 −7
conf/web.xml+10 −1 modified@@ -334,6 +334,15 @@ <!-- executable Name of the executable used to run the --> <!-- script. [perl] --> <!-- --> + <!-- envHttpHeaders A regular expression used to select the HTTP --> + <!-- headers passed to the CGI process as --> + <!-- environment variables. Note that headers are --> + <!-- converted to upper case before matching and --> + <!-- that the entire header name must match the --> + <!-- pattern. --> + <!-- [ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST| --> + <!-- IF-[-0-9A-Z]*|REFERER|USER-AGENT] --> + <!-- --> <!-- parameterEncoding Name of parameter encoding to be used with --> <!-- CGI servlet. --> <!-- [System.getProperty("file.encoding","UTF-8")] --> @@ -353,7 +362,7 @@ <param-name>cgiPathPrefix</param-name> <param-value>WEB-INF/cgi</param-value> </init-param> - <load-on-startup>5</load-on-startup> + <load-on-startup>5</load-on-startup> </servlet> -->
java/org/apache/catalina/servlets/CGIServlet.java+17 −6 modified@@ -35,6 +35,7 @@ import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.Vector; +import java.util.regex.Pattern; import javax.servlet.RequestDispatcher; import javax.servlet.ServletConfig; @@ -265,6 +266,16 @@ public final class CGIServlet extends HttpServlet { */ private long stderrTimeout = 2000; + /** + * The regular expression used to select HTTP headers to be passed to the + * CGI process as environment variables. The name of the environment + * variable will be the name of the HTTP header converter to upper case, + * prefixed with <code>HTTP_</code> and with all <code>-</code> characters + * converted to <code>_</code>. + */ + private Pattern envHttpHeadersPattern = Pattern.compile( + "ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST|IF-[-0-9A-Z]*|REFERER|USER-AGENT"); + /** object used to ensure multiple threads don't try to expand same file */ private static final Object expandFileLock = new Object(); @@ -326,6 +337,10 @@ public void init(ServletConfig config) throws ServletException { "stderrTimeout")); } + if (getServletConfig().getInitParameter("envHttpHeaders") != null) { + envHttpHeadersPattern = + Pattern.compile(getServletConfig().getInitParameter("envHttpHeaders")); + } } @@ -963,12 +978,8 @@ protected boolean setCGIEnvironment(HttpServletRequest req) throws IOException { //REMIND: rewrite multiple headers as if received as single //REMIND: change character set //REMIND: I forgot what the previous REMIND means - if ("AUTHORIZATION".equalsIgnoreCase(header) || - "PROXY_AUTHORIZATION".equalsIgnoreCase(header)) { - //NOOP per CGI specification section 11.2 - } else { - envp.put("HTTP_" + header.replace('-', '_'), - req.getHeader(header)); + if (envHttpHeadersPattern.matcher(header).matches()) { + envp.put("HTTP_" + header.replace('-', '_'), req.getHeader(header)); } }
webapps/docs/cgi-howto.xml+6 −0 modified@@ -103,6 +103,12 @@ if your script is itself executable (e.g. an exe file). Default is <li><strong>executable-arg-1</strong>, <strong>executable-arg-2</strong>, and so on - additional arguments for the executable. These precede the CGI script name. By default there are no additional arguments.</li> +<li><strong>envHttpHeaders</strong> - A regular expression used to select the +HTTP headers passed to the CGI process as environment variables. Note that +headers are converted to upper case before matching and that the entire header +name must match the pattern. Default is +<code>ACCEPT[-0-9A-Z]*|CACHE-CONTROL|COOKIE|HOST|IF-[-0-9A-Z]*|REFERER|USER-AGENT</code> +</li> <li><strong>parameterEncoding</strong> - Name of the parameter encoding to be used with the CGI servlet. Default is <code>System.getProperty("file.encoding","UTF-8")</code>. That is the system
webapps/docs/changelog.xml+7 −0 modified@@ -146,6 +146,13 @@ <code>StandardRoot</code> instance now invalidate the cache if caching is enabled. (markt) </fix> + <add> + Add a new initialisation parameter, <code>envHttpHeaders</code>, to + the CGI Servlet to mitigate <a href="https://httpoxy.org">httpoxy</a> + (<a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-5388" + >CVE-2016-5388</a>) by default and to provide a mechanism that can be + used to mitigate any future, similar issues. (markt) + </add> </changelog> </subsection> <subsection name="Coyote">
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
46- www.oracle.com/technetwork/security-advisory/cpujul2017-3236622.htmlnvdPatchThird Party Advisory
- lists.opensuse.org/opensuse-updates/2016-09/msg00025.htmlnvdThird Party Advisory
- rhn.redhat.com/errata/RHSA-2016-1624.htmlnvdThird Party Advisory
- rhn.redhat.com/errata/RHSA-2016-2045.htmlnvdThird Party Advisory
- rhn.redhat.com/errata/RHSA-2016-2046.htmlnvdThird Party Advisory
- www.kb.cert.org/vuls/id/797896nvdThird Party AdvisoryUS Government Resource
- www.oracle.com/technetwork/topics/security/linuxbulletinoct2016-3090545.htmlnvdThird Party Advisory
- www.securityfocus.com/bid/91818nvdThird Party AdvisoryVDB Entry
- www.securitytracker.com/id/1036331nvdThird Party AdvisoryVDB EntryVendor Advisory
- access.redhat.com/errata/RHSA-2016:1635nvdThird Party AdvisoryWEB
- access.redhat.com/errata/RHSA-2016:1636nvdThird Party AdvisoryWEB
- github.com/advisories/GHSA-v646-rx6w-r3qqghsaADVISORY
- h20566.www2.hpe.com/hpsc/doc/public/displaynvdThird Party AdvisoryWEB
- h20566.www2.hpe.com/portal/site/hpsc/public/kb/docDisplaynvdThird Party AdvisoryWEB
- h20566.www2.hpe.com/portal/site/hpsc/public/kb/docDisplaynvdThird Party AdvisoryWEB
- h20566.www2.hpe.com/portal/site/hpsc/public/kb/docDisplaynvdThird Party AdvisoryWEB
- httpoxy.orgnvdThird Party Advisory
- nvd.nist.gov/vuln/detail/CVE-2016-5388ghsaADVISORY
- tomcat.apache.org/tomcat-7.0-doc/changelog.htmlnvdRelease NotesVendor AdvisoryWEB
- www.apache.org/security/asf-httpoxy-response.txtnvdVendor AdvisoryWEB
- access.redhat.com/errata/RHSA-2016:1624ghsaWEB
- access.redhat.com/errata/RHSA-2016:2045ghsaWEB
- access.redhat.com/errata/RHSA-2016:2046ghsaWEB
- access.redhat.com/security/cve/CVE-2016-5388ghsaWEB
- bugzilla.redhat.com/show_bug.cgighsaWEB
- github.com/apache/tomcat/commit/1b91e91194a095ea922f96d1dccddf6fbc446e54ghsaWEB
- github.com/apache/tomcat/commit/880250877b0643956435282afb9c111450cfff4cghsaWEB
- github.com/apache/tomcat/commit/fb3569fbb9a2f55459aa8e1e22bc35a737e66329ghsaWEB
- lists.apache.org/thread.html/053d9ce4d579b02203db18545fee5e33f35f2932885459b74d1e4272%40%3Cissues.activemq.apache.org%3EnvdWEB
- lists.apache.org/thread.html/053d9ce4d579b02203db18545fee5e33f35f2932885459b74d1e4272@%3Cissues.activemq.apache.org%3EghsaWEB
- lists.apache.org/thread.html/6b414817c2b0bf351138911c8c922ec5dd577ebc0b9a7f42d705752d%40%3Cissues.activemq.apache.org%3EnvdWEB
- lists.apache.org/thread.html/6b414817c2b0bf351138911c8c922ec5dd577ebc0b9a7f42d705752d@%3Cissues.activemq.apache.org%3EghsaWEB
- lists.apache.org/thread.html/6d3d34adcf3dfc48e36342aa1f18ce3c20bb8e4c458a97508d5bfed1%40%3Cissues.activemq.apache.org%3EnvdWEB
- lists.apache.org/thread.html/6d3d34adcf3dfc48e36342aa1f18ce3c20bb8e4c458a97508d5bfed1@%3Cissues.activemq.apache.org%3EghsaWEB
- lists.apache.org/thread.html/r2853582063cfd9e7fbae1e029ae004e6a83482ae9b70a698996353dd%40%3Cusers.tomcat.apache.org%3EnvdWEB
- lists.apache.org/thread.html/r2853582063cfd9e7fbae1e029ae004e6a83482ae9b70a698996353dd@%3Cusers.tomcat.apache.org%3EghsaWEB
- lists.apache.org/thread.html/rc6b2147532416cc736e68a32678d3947b7053c3085cf43a9874fd102%40%3Cusers.tomcat.apache.org%3EnvdWEB
- lists.apache.org/thread.html/rc6b2147532416cc736e68a32678d3947b7053c3085cf43a9874fd102@%3Cusers.tomcat.apache.org%3EghsaWEB
- lists.apache.org/thread.html/rf21b368769ae70de4dee840a3228721ae442f1d51ad8742003aefe39%40%3Cusers.tomcat.apache.org%3EnvdWEB
- lists.apache.org/thread.html/rf21b368769ae70de4dee840a3228721ae442f1d51ad8742003aefe39@%3Cusers.tomcat.apache.org%3EghsaWEB
- lists.debian.org/debian-lts-announce/2019/08/msg00015.htmlnvdWEB
- lists.opensuse.org/opensuse-updates/2016-09/msg00025.htmlghsaWEB
- rhn.redhat.com/errata/RHSA-2016-1624.htmlghsaWEB
- rhn.redhat.com/errata/RHSA-2016-2045.htmlghsaWEB
- rhn.redhat.com/errata/RHSA-2016-2046.htmlghsaWEB
- www.kb.cert.org/vuls/id/797896ghsaWEB
News mentions
0No linked articles in our index yet.