VYPR
High severity8.1NVD Advisory· Published Jul 19, 2016· Updated May 6, 2026

CVE-2016-5388

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.

PackageAffected versionsPatched versions
org.apache.tomcat:tomcat-catalinaMaven
>= 7.0.0, < 7.0.727.0.72
org.apache.tomcat:tomcat-catalinaMaven
>= 8.0.0, < 8.5.58.5.5

Patches

3
880250877b06

Add 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.

https://github.com/apache/tomcatMark ThomasAug 19, 2016via ghsa
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">
    
1b91e91194a0

Add 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.

https://github.com/apache/tomcatMark ThomasAug 19, 2016via ghsa
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">
    
fb3569fbb9a2

Add 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.

https://github.com/apache/tomcatMark ThomasAug 19, 2016via ghsa
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

News mentions

0

No linked articles in our index yet.