Skip to content

Conversation

@tadejmagajna
Copy link
Contributor

@tadejmagajna tadejmagajna commented Dec 11, 2025

The pull request involves a fix for CRLF injection vulnerability in http.server and wsgiref modules which allows attackers to inject arbitrary HTTP headers or perform HTTP response splitting attacks by including CR (\r) and LF (\n) characters in header values.

This fix adds CRLF validation to send_header() method in http.server, and to three header-manipulation methods in used by wsgiref: __setitem__(), setdefault(), and add_header().

For exception wording, to ensure consistency across both modules, the same name/value agnostic wording pattern as already used in existing wsgiref exception messages was used across the change:

raise AssertionError("Header names/values must be"

Added tests to verify CR/LF rejection in header names and values across http.server and email.message modules, covering all CRLF variants (\r, \n, \r\n).

Reject CR/LF in header names/values in `http.server` and `wsgiref.headers`
to prevent CRLF injection attacks.
@aydinnyunus
Copy link

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants