Skip to content

Commit dbba26d

Browse files
miss-islingtontadejmagajnavstinner
authored
[3.14] gh-142533: Document CRLF injection vulnerabilities in http.server doc (GH-143395) (#148020)
gh-142533: Document CRLF injection vulnerabilities in http.server doc (GH-143395) (cherry picked from commit 617f4cc) Co-authored-by: Tadej Magajna <tmagajna@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent ea9ecc8 commit dbba26d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/library/http.server.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ instantiation, of which this module provides three different variants:
287287
specifying its value. Note that, after the send_header calls are done,
288288
:meth:`end_headers` MUST BE called in order to complete the operation.
289289

290+
This method does not reject input containing CRLF sequences.
291+
290292
.. versionchanged:: 3.2
291293
Headers are stored in an internal buffer.
292294

@@ -297,6 +299,8 @@ instantiation, of which this module provides three different variants:
297299
buffered and sent directly the output stream.If the *message* is not
298300
specified, the HTTP message corresponding the response *code* is sent.
299301

302+
This method does not reject *message* containing CRLF sequences.
303+
300304
.. versionadded:: 3.2
301305

302306
.. method:: end_headers()
@@ -622,6 +626,11 @@ Security considerations
622626
requests, this makes it possible for files outside of the specified directory
623627
to be served.
624628

629+
Methods :meth:`BaseHTTPRequestHandler.send_header` and
630+
:meth:`BaseHTTPRequestHandler.send_response_only` assume sanitized input
631+
and does not perform input validation such as checking for the presence of CRLF
632+
sequences. Untrusted input may result in HTTP Header injection attacks.
633+
625634
Earlier versions of Python did not scrub control characters from the
626635
log messages emitted to stderr from ``python -m http.server`` or the
627636
default :class:`BaseHTTPRequestHandler` ``.log_message``

0 commit comments

Comments
 (0)