mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.7.x] Stripped headers containing underscores to prevent spoofing in WSGI environ.
This is a security fix. Disclosure following shortly. Thanks to Jedediah Smith for the report.
This commit is contained in:
@@ -155,6 +155,17 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler, object):
|
||||
|
||||
sys.stderr.write(msg)
|
||||
|
||||
def get_environ(self):
|
||||
# Strip all headers with underscores in the name before constructing
|
||||
# the WSGI environ. This prevents header-spoofing based on ambiguity
|
||||
# between underscores and dashes both normalized to underscores in WSGI
|
||||
# env vars. Nginx and Apache 2.4+ both do this as well.
|
||||
for k, v in self.headers.items():
|
||||
if '_' in k:
|
||||
del self.headers[k]
|
||||
|
||||
return super(WSGIRequestHandler, self).get_environ()
|
||||
|
||||
|
||||
def run(addr, port, wsgi_handler, ipv6=False, threading=False):
|
||||
server_address = (addr, port)
|
||||
|
||||
Reference in New Issue
Block a user