[security] do not emit HTTP_PROXY to CGI env
commit779c133c16f9af168b004dce7a2a64f16c1cb3a4
authorGlenn Strauss <gstrauss@gluelogic.com>
Tue, 19 Jul 2016 02:59:33 +0000 (18 22:59 -0400)
committerGlenn Strauss <gstrauss@gluelogic.com>
Tue, 19 Jul 2016 05:22:33 +0000 (19 01:22 -0400)
tree509b21131fad4435ad58306a4c9a2e335b9ac13a
parentd506f4a569e9d5a7b3c215333bc5916f17f3a4cc
[security] do not emit HTTP_PROXY to CGI env

Strip bogus "Proxy" header before creating subprocess environment.
(mod_cgi, mod_fastcgi, mod_scgi, mod_ssi, mod_proxy)

Do not emit HTTP_PROXY to subprocess environment.
Some executables use HTTP_PROXY to configure outgoing proxy.

This is not a lighttpd security issue per se, but this change to
lighttpd adds a layer of defense to protect backend processes which
might be vulnerable due to blindly using this untrusted environment
variable.  The HTTP_PROXY environment variable should not be trusted
by a program running in a CGI-like environment.

Mitigation in lighttpd <= 1.4.40 is to reject requests w/ Proxy header:

* Create "/path/to/deny-proxy.lua", read-only to lighttpd, with content:
  if (lighty.request["Proxy"] == nil) then return 0 else return 403 end
* Modify lighttpd.conf to load mod_magnet and run lua code
    server.modules += ( "mod_magnet" )
    magnet.attract-raw-url-to = ( "/path/to/deny-proxy.lua" )

References:

https://www.kb.cert.org/vuls/id/797896
CGI web servers assign Proxy header values from client requests to
internal HTTP_PROXY environment variables

https://httpoxy.org/
httpoxy: A CGI application vulnerability
src/mod_cgi.c
src/mod_fastcgi.c
src/mod_proxy.c
src/mod_scgi.c
src/mod_ssi.c