]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-142533: Document CRLF injection vulnerabilities in http.server doc (#143395)
authorTadej Magajna <tmagajna@gmail.com>
Thu, 2 Apr 2026 21:26:21 +0000 (23:26 +0200)
committerGitHub <noreply@github.com>
Thu, 2 Apr 2026 21:26:21 +0000 (23:26 +0200)
Co-authored-by: Victor Stinner <vstinner@python.org>
Doc/library/http.server.rst

index bd8c3f09cb43f19dc4ad3e80e3dd527cfaa70c21..cb8b5f0df88d6cb594a926db2305e9f0dd40c6c9 100644 (file)
@@ -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.
 
@@ -297,6 +299,8 @@ instantiation, of which this module provides three different variants:
       buffered and sent directly the output stream.If the *message* is not
       specified, the HTTP message corresponding the response *code*  is sent.
 
+      This method does not reject *message* containing CRLF sequences.
+
       .. versionadded:: 3.2
 
    .. method:: end_headers()
@@ -555,6 +559,11 @@ Security considerations
 requests, this makes it possible for files outside of the specified directory
 to be served.
 
+Methods :meth:`BaseHTTPRequestHandler.send_header` and
+:meth:`BaseHTTPRequestHandler.send_response_only` assume sanitized input
+and does not perform input validation such as checking for the presence of CRLF
+sequences. Untrusted input may result in HTTP Header 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``