/

CVE-2026-50269

Severity:

HIGH RISK

(7.5)

HTTP Header Injection (CWE-113) in aiohttp Multipart

CVE-2026-50269

Analyzed

Vulnerability type

Category:

HTTP Header Injection

CWE:

CWE-93, CWE-113

Impact:

HTTP Request Manipulation and Header Injection

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A header injection weakness in aiohttp allows attacker-controlled input to be incorporated directly into multipart or payload headers without adequate normalization.

When applications pass user-controlled strings into MultipartWriter.append(headers=...) or Payload.headers, an attacker may inject or modify HTTP headers and alter the structure or contents of outbound requests.

Affected context

This vulnerability affects applications built on the aiohttp framework that construct outbound HTTP requests using multipart bodies or custom payloads. It becomes relevant when application code passes user-controlled values into the MultipartWriter.append(headers=...) argument or directly into Payload.headers without sanitization or normalization. In that situation, attacker input can influence how request headers are formed, potentially changing the request semantics, injected headers, or the interpreted content length and type. Not all aiohttp deployments are affected; only those that accept and propagate untrusted data into these header-related APIs are exposed.

Exploit preconditions

  • Attack surface: Outbound HTTP requests generated by aiohttp clients or servers using multipart payloads or custom Payload objects.
  • Required access: Capability to supply or control data that is later passed into MultipartWriter.append(headers=...) or Payload.headers (e.g., via HTTP parameters, form fields, or API inputs).
  • Trigger point: Construction of multipart messages or payloads where headers are derived directly from attacker-controlled data and serialized into the HTTP request.
  • Why exploitation is possible: The framework accepts raw header values without robust validation or normalization, allowing special characters and delimiter sequences that can break header boundaries and introduce additional headers or modify existing ones (CWE-113 / CWE-93).

Why this happens

The underlying issue is improper neutralization of special elements in HTTP headers (CWE-113) combined with faulty input validation in the context of HTTP protocol elements (CWE-93). aiohttp multipart and payload handling logic trusts header dictionaries or strings supplied by the application, and does not sufficiently sanitize user-controlled values before embedding them into the serialized header block. As a result, attackers who can influence those values may include newline characters or other control sequences that change the parsing of headers, enabling injection of new fields or manipulation of existing ones. The bug class is the direct concatenation of untrusted input into protocol headers without ensuring it cannot break the intended structure.

Potential impact

  • An attacker may inject additional HTTP headers into outbound requests.
  • An attacker could modify existing headers, such as Content-Type or Authorization, to change request semantics.
  • Request routing or caching behavior can be altered by manipulating Host, X-Forwarded-* or similar headers.
  • Downstream services may receive malformed or misleading request data, potentially enabling secondary attacks.
  • Security controls relying on accurate headers (e.g., CSRF or auth proxies) can be bypassed or weakened.

General mitigation guidance

Mitigation generally centers on treating all header-related data as untrusted and applying strict validation before use. Applications should avoid passing user-supplied strings directly into MultipartWriter.append(headers=...) or Payload.headers, instead building headers from controlled, server-side values. Where user input is needed (such as filenames or content descriptors), normalize to a safe subset of characters and reject or escape line breaks and control characters. Adopting a secure-by-default pattern—such as centralized header-construction helpers that enforce allowed header names and value formats—reduces the chance that unvalidated input reaches protocol boundaries. Additionally, limit the influence of user data over transport-level behavior (routing, authentication, caching) by keeping those headers derived solely from trusted configuration or application logic.

How teams detect issues like this

Detection typically involves reviewing code for places where user-controlled data is used to construct HTTP headers or multipart payloads. Static analysis rules can flag calls to MultipartWriter.append(headers=...) and Payload.headers where arguments originate from HTTP request parameters, form fields, or other untrusted sources, especially if they are passed through with minimal transformation. During manual code review, pay attention to helper functions that assemble headers and ensure they enforce strict schemas and character whitelists. Organizations may also enforce policies that disallow dynamic header construction from user input and use automated tooling or linters to highlight direct concatenation of untrusted data into header values.

Sources

SourceLink
github.comgithub.com/aio-libs/aiohttp/commit/bf88077ebb14f4c29924b8e8904cba20c55c28b8
github.comgithub.com/aio-libs/aiohttp/security/advisories/GHSA-m6qw-4cw2-hm4m

Frequently asked

questions

Exploitability depends on whether the application passes untrusted user input into multipart or payload headers. If all headers are derived from trusted configuration or validated data, practical risk is low.

An attacker needs control over data that the application later uses as header values in MultipartWriter.append(headers=...) or Payload.headers. This is usually through standard user inputs like HTTP parameters or form data.

The safest pattern is to ensure that headers are built exclusively from trusted, server-side data and to centralize header construction with strict validation of any user-influenced fields, rejecting or sanitizing disallowed characters.

Developers can adopt strict input validation for all protocol-related data, enforce header schemas, avoid direct concatenation of user input into headers, and integrate static analysis or code review checks focusing on header construction and multipart handling.

Find out what's already
exploitable in your codebase.