Skip to content
6 changes: 6 additions & 0 deletions Doc/library/http.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ instantiation, of which this module provides three different variants:
specifying its value. Note that, after the send_header calls are done,
:meth:`end_headers` MUST BE called in order to complete the operation.

This method does not reject input containing CRLF sequences.

.. versionchanged:: 3.2
Headers are stored in an internal buffer.

Expand Down Expand Up @@ -555,6 +557,10 @@ Security considerations
requests, this makes it possible for files outside of the specified directory
to be served.

The :meth:`BaseHTTPRequestHandler.send_header` method assumes sanitized input
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and send_response_only()

and does not perform input validation such as checking for the presence of CRLF
sequences. Untrusted input may result in CRLF injection attacks.

Earlier versions of Python did not scrub control characters from the
log messages emitted to stderr from ``python -m http.server`` or the
default :class:`BaseHTTPRequestHandler` ``.log_message``
Expand Down
10 changes: 10 additions & 0 deletions Doc/library/wsgiref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ manipulation of WSGI response headers using a mapping-like interface.

Content-Disposition: attachment; filename="bud.gif"

This method does not reject input containing CRLF sequences.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer true, please check the update wsgiref code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the vulnerability was addressed while this change was in review. Thank you.

I removed my wsgiref.rst changes, while leaving http.server.rst change in place as it remains relevant.


.. versionchanged:: 3.5
*headers* parameter is optional.
Expand Down Expand Up @@ -899,3 +900,12 @@ directory and port number (default: 8000) on the command line::
httpd.server_close()


.. _wsgiref-security:

Security considerations
-----------------------
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format this the same as we did for Http.server, that is: add a label and enough blank lines.


The :class:`wsgiref.headers.Headers` class assumes sanitized input for header
names and values and does not perform input validation such as checking for the
presence of CRLF sequences. Untrusted input may result in CRLF injection
attacks.
Loading