GHSA-h4x7-gw46-3wm6: CRLF Injection

Published Sep 8, 2026
·
Updated

Summary

HTTPX2 serializes the per-file Content-Type and custom headers supplied through the files= tuple API directly into the multipart/form-data body without validating custom header names or values. An attacker who can influence upload metadata passed to HTTPX2 can use CR or LF characters to terminate a multipart part header and inject additional part headers or end the part header block early.

Details

The three-element file tuple accepts (filename, content, contenttype), and the four-element form accepts (filename, content, contenttype, headers). FileField.renderheaders() interpolates the supplied header names and values between CRLF delimiters without validating them.

For example:

python import httpx2

request = httpx2.Request( "POST", "https://example.com/upload", headers={"Content-Type": "multipart/form-data; boundary=BOUNDARY"}, files={ "file": ( "safe.txt", b"payload", "text/plain\r\nX-Injected: true", ) }, )

print(request.read().decode())

The generated body contains an attacker-injected part header:

text --BOUNDARY Content-Disposition: form-data; name="file"; filename="safe.txt" Content-Type: text/plain X-Injected: true

payload --BOUNDARY--

The same issue affects names and values in the custom header mapping from the four-element tuple.

Field names and filenames are serialized through a separate escaping path and do not permit CRLF header injection.

Impact

Applications are affected when they pass attacker-controlled upload metadata into the per-file contenttype or custom headers arguments. The receiving server interprets injected lines as genuine multipart part headers. Depending on how that server validates and processes uploads, this can alter part semantics or bypass checks based on part headers.

This does not split the outer HTTP request: the injected headers are contained within the multipart body. The concrete security impact therefore depends on the downstream multipart parser and application behavior.

Mitigation

Upgrade to HTTPX2 2.11.0 or later. Patched versions reject forbidden control characters in multipart part header names and values and raise ValueError before serializing the request.

If upgrading is not immediately possible, applications should validate custom multipart header names as HTTP field-name tokens. They should reject NUL, CR, LF, other C0 controls except horizontal tab, and DEL in per-file content types and custom header values before passing them to HTTPX2.

Affected Software

1 affected componentFixes available
pip/httpx2<2.11.0
2.11.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/httpx2 to a version that resolves this vulnerability.

    Fixed in 2.11.0
  2. Upgrade

    Upgrade httpx2 to a version that resolves this vulnerability.

    Fixed in 2.11.0
  3. Configuration

    Before passing attacker-influenced upload metadata into HTTPX2 per-file content_type or custom headers (files= tuple; including the four-element tuple form that accepts (filename, content, content_type, headers) and the three-element form (filename, content, content_type)), validate and reject NUL, CR, LF, other C0 controls except horizontal tab, and DEL in per-file content types and custom header values.

    Applications using HTTPX2 multipart/form-data uploads validation of per-file Content-Type and custom multipart header names/values (reject forbidden control characters) = Reject NUL, CR, LF, other C0 controls except horizontal tab, and DEL

Event History

Sep 8, 2026
Advisory Published
via GitHub·08:45 PM
Data Sourced
via GitHub·08:45 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What inputs must an attacker control to exploit this issue?

The attacker must be able to influence metadata passed through HTTPX2's files= tuple API, specifically the per-file content_type value or custom per-part headers in the four-element tuple form. They need to supply CR or LF characters in a header name or value.

2

Is a multipart upload affected when it uses only a filename and file content?

The described injection path is in caller-supplied per-file Content-Type values and custom headers. The provided data does not identify the basic filename-and-content tuple alone as an affected input path.

3

What can the injection change in the generated request?

CR or LF characters can terminate a multipart part header and inject additional part headers, or end the part header block early. The impact described is integrity-only, with no confidentiality or availability impact indicated by the supplied severity vector.

4

How can I determine whether my application is exposed?

Review uses of httpx2 files= uploads for three- or four-element file tuples that pass content types or custom headers from external or insufficiently validated sources. Inputs containing carriage return or line feed characters in those fields indicate exposure to the described request-body manipulation.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203