Skip to content

Commit b1edcf8

Browse files
committed
gh-142533: Document CRLF injection vulnerability in http.server and wsgiref modules
1 parent 12283f6 commit b1edcf8

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Doc/library/http.server.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ 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 allowing the
291+
possibility of CRLF injection, where a single method call can inject
292+
multiple arbitrary headers.
293+
290294
.. versionchanged:: 3.2
291295
Headers are stored in an internal buffer.
292296

@@ -555,6 +559,10 @@ Security considerations
555559
requests, this makes it possible for files outside of the specified directory
556560
to be served.
557561

562+
The :meth:`BaseHTTPRequestHandler.send_header` method assumes sanitized input
563+
and does not perform input validation such as checking for the presence of CRLF
564+
sequences. Untrusted input may result in CRLF injection attacks.
565+
558566
Earlier versions of Python did not scrub control characters from the
559567
log messages emitted to stderr from ``python -m http.server`` or the
560568
default :class:`BaseHTTPRequestHandler` ``.log_message``

Doc/library/wsgiref.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ manipulation of WSGI response headers using a mapping-like interface.
263263

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

266+
This method does not reject input containing CRLF sequences allowing the
267+
possibility of CRLF injection, where a single method call can inject
268+
multiple arbitrary headers.
266269

267270
.. versionchanged:: 3.5
268271
*headers* parameter is optional.
@@ -896,4 +899,10 @@ directory and port number (default: 8000) on the command line::
896899
print("Shutting down.")
897900
httpd.server_close()
898901

902+
Security considerations
903+
-----------------------
899904

905+
The :class:`wsgiref.headers.Headers` class assumes sanitized input for header
906+
names and values and does not perform input validation such as checking for the
907+
presence of CRLF sequences. Untrusted input may result in CRLF injection
908+
attacks.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Document CRLF injection vulnerability in :mod:`http.server` and
2+
:mod:`wsgiref` modules.

0 commit comments

Comments
 (0)