Opened 3 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#37100 closed Bug (fixed)

Prevent header injection through malformed response reason phrase

Reported by: Jake Howard Owned by: Varun Kasyap Pentamaraju
Component: HTTP handling Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

HttpResponse.reason_phrase is not correctly sanitized when creating a response body:

HttpResponse(
    "body",
    reason="OK\r\nX-Injected-header: yes",
)

This results in an extra header in the response, which is not present in .headers.

The WSGI spec requires that the status line (which contains the reason phrase) must not contain whitespace or other control characters. Therefore, Django should sanitize the input.


This was previously reported to the Security Team by rasputinkaiser, however as reason phase is never intended to be user-controlled, it was not considered a vulnerability.

Change History (10)

comment:1 by Sarah Boyce, 3 weeks ago

Triage Stage: UnreviewedAccepted

comment:2 by Varun Kasyap Pentamaraju, 3 weeks ago

Owner: set to Varun Kasyap Pentamaraju
Status: newassigned

comment:3 by Varun Kasyap Pentamaraju, 3 weeks ago

Has patch: set

comment:4 by Jake Howard, 3 weeks ago

Patch needs improvement: set

comment:5 by Varun Kasyap Pentamaraju, 2 weeks ago

Patch needs improvement: unset

comment:6 by Jake Howard, 2 weeks ago

Patch needs improvement: set

comment:7 by Varun Kasyap Pentamaraju, 2 weeks ago

Patch needs improvement: unset

comment:8 by Jacob Walls, 2 weeks ago

Triage Stage: AcceptedReady for checkin

comment:9 by Jacob Walls <jacobtylerwalls@…>, 2 weeks ago

Resolution: fixed
Status: assignedclosed

In 5364575:

Fixed #37100 -- Prevented control characters in HttpResponse reason_phrase.

comment:10 by Jacob Walls <jacobtylerwalls@…>, 2 weeks ago

In d7b3fed:

[6.1.x] Fixed #37100 -- Prevented control characters in HttpResponse reason_phrase.

Backport of 53645750412efa1e9013004040db328bd515e0f1 from main.

Note: See TracTickets for help on using tickets.
Back to Top