# GHSA-6G26-XHVX-G5W3: HttpPostRequestEncoder emits CRLF in multipart filename/contentType as part headers

- Database: GitHub
- Severity: CVSS 5.3 (Medium)
- Published: 2026-12-02
- Modified: 2026-12-02

## Tracked as

- [CVE-2026-142452](https://cve.now/CVE-2026-142452.md): Io.netty/netty-codec-http: netty: httppostrequestencoder emits crlf in multipart filename/contenttype as part headers

## Affected versions

- io.netty:netty-codec-http (Maven): from 4.1.0.Final, through 4.1.138.Final
- io.netty:netty-codec-http (Maven): from 4.2.0.Final, through 4.2.18.Final

## Description

## Summary

`HttpPostRequestEncoder` builds multipart part headers by concatenating `FileUpload.getFilename()` into the `Content-Disposition` header and `FileUpload.getContentType()` into the `Content-Type` header. `MemoryFileUpload` and `DiskFileUpload` only null-check those values; they do not reject, escape, or strip carriage return or line feed characters.

As a result, an application that uses Netty to re-post or relay uploaded files with attacker-influenced filename or MIME type metadata can generate an outbound multipart request containing attacker-controlled per-part headers.

## Technical Details

Netty already treats multipart field names as header-context values. The `AbstractHttpData` constructor stores `cleanName(name)`, and `cleanName(...)` removes `\n` and replaces `\r` and `\t` with spaces before names are emitted into multipart headers.

The sibling `FileUpload` metadata paths do not receive equivalent treatment:

- `MemoryFileUpload.setFilename(...)` stores the filename after only `ObjectUtil.checkNotNull(...)`;
- `MemoryFileUpload.setContentType(...)` stores the content type after only `ObjectUtil.checkNotNull(...)`;
- `DiskFileUpload` has the same behavior;
- `MixedFileUpload` delegates to the wrapped memory or disk implementation.

`HttpPostRequestEncoder.addBodyHttpData(...)` then writes these values directly into generated part headers:

```java
internal.addValue(HttpHeaderNames.CONTENT_DISPOSITION + ": " + HttpHeaderValues.FORM_DATA + "; "
        + HttpHeaderValues.NAME + "=\"" + fileUpload.getName() + "\"; "
        + HttpHeaderValues.FILENAME + "=\"" + fileUpload.getFilename() + "\"\r\n");

internal.addValue(HttpHeaderNames.CONTENT_TYPE + ": " + fileUpload.getContentType());
```

A filename containing `"\\r\\nX-Injected-Filename: yes` closes the quoted filename parameter and starts a new multipart header line. A content type containing `\\r\\nX-Injected-Type: yes` starts a new header after Netty's generated `Content-Type` line.

## Impact

Any Netty-based application that accepts user-provided files and re-posts them via `HttpPostRequestEncoder` with attacker-influenced filename or MIME type metadata can emit attacker-controlled multipart part headers in the outbound request body.

This can affect downstream services that make security decisions from per-part metadata, such as upload filters that trust per-part `Content-Type`, workflows that route or validate files by `Content-Disposition` parameters, or multipart parsers and gateways that treat duplicate or unexpected per-part headers inconsistently.

This report does not claim top-level HTTP request-header injection, server compromise, or a proven cross-request desynchronization. The demonstrated issue is multipart body header injection inside Netty-generated outbound requests.

## Suggested Fix

Reject or escape CR and LF before any `FileUpload` metadata is inserted into a multipart part header.

Recommended fix points:

- reject `\r` and `\n` in `MemoryFileUpload.setFilename(...)` and `DiskFileUpload.setFilename(...)`, or percent-encode them consistently with multipart/form-data serialization rules;
- apply equivalent validation to `setContentType(...)`, because that value is emitted as a raw header value;
- preserve the existing `name` normalization behavior or replace it with a single shared multipart header-parameter escaping helper;
- add regression tests for filename CRLF, content-type CRLF, field-name control behavior, and the multipart/mixed attachment path.

## Affected Package/Versions

`io.netty:netty-codec-http`

Confirmed affected:

- current `4.2` branch at `7bae566a93e69409697fe57fa807910ba5c9720e`
- `4.2.15.Final` at `a41f7b289ce1d697c50846f3ade3983e22b2ed40`
- `4.1.135.Final` at `f05f765d81460799c53123a207f665bf3b465171`

Suggested affected ranges:

- `>= 4.1.0.Final, <= 4.1.135.Final`
- `>= 4.2.0.Final, <= 4.2.15.Final`

The latest supported 4.1 and 4.2 release lines were dynamically confirmed. Older lower bounds are inferred from the longstanding encoder code path.

## References

- Netty security policy: https://github.com/netty/netty/security/policy
- Netty 4.2 `FileUpload` API: https://netty.io/4.2/api/io/netty/handler/codec/http/multipart/FileUpload.html
- Netty 4.1 `FileUpload` API: https://netty.io/4.1/api/io/netty/handler/codec/http/multipart/FileUpload.html
- RFC 7578, multipart/form-data: https://datatracker.ietf.org/doc/html/rfc7578
- WHATWG multipart/form-data serializer draft: https://andreubotella.github.io/multipart-form-data/
- Req advisory `GHSA-px9f-whj3-246m` / `CVE-2026-49756`: https://github.com/wojtekmach/req/security/advisories/GHSA-px9f-whj3-246m
- Axios advisory `GHSA-445q-vr5w-6q77` / `CVE-2026-42037`: https://github.com/axios/axios/security/advisories/GHSA-445q-vr5w-6q77

## CWE and CVSS

Primary CWE: `CWE-93` (Improper Neutralization of CRLF Sequences).

Secondary CWE: `CWE-113` (Improper Neutralization of CRLF Sequences in HTTP Headers). The injected headers are multipart part headers in the HTTP request body, not top-level request headers, so `CWE-93` is the more precise primary classification.

Suggested CVSS v3.1:

```text
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
```

Suggested severity: Medium, score 5.3.

Rationale: exploitation can be driven over a network by supplying upload metadata to a Netty-based relay, requires low complexity and no user interaction, and primarily affects integrity of downstream multipart metadata. No direct confidentiality or availability impact is demonstrated.

## Duplicate Boundary

A live private-advisory query for Netty security advisories containing `multipart`, `form-data`, `content-disposition`, `content-type`, `filename`, `crlf`, or `header injection` found existing Netty CRLF/header advisories, but no multipart encoder advisory.

Existing matches are distinct:

- `GHSA-84h7-rjj3-6jx4`: top-level `HttpRequestEncoder` CRLF injection;
- `GHSA-45q3-82m4-75jr`: `HttpProxyHandler` disabled validation;
- `GHSA-rgrr-p7gp-5xj7`: Redis codec CRLF injection;
- `GHSA-hvcg-qmg6-jm4c`: HTTP decoder initial-control-character handling;
- private `GHSA-9643-8r5j-g4xq`: SMTP custom command names bypass a CRLF fix.

I also checked the local submission bundle/status docs for prior Netty multipart/form-data, filename, and part-header submissions and did not find this candidate already submitted.

## Local PoV

PoV file:

`HttpPostRequestEncoderMultipartHeaderInjectionPovTest.java`

Run from a Netty checkout:

```fish
./mvnw -pl codec-http -am \
  -DskipTests=false \
  -Dtest=HttpPostRequestEncoderMultipartHeaderInjectionPovTest \
  -Dsurefire.failIfNoSpecifiedTests=false test
```

The PoV constructs a multipart encoder with a `MemoryFileUpload` whose filename and content type contain CRLF. The encoded body contains real injected part headers:

```text
\r\nX-Injected-Filename: yes"\r\n
\r\nX-Injected-Type: yes\r\n
```

The control test uses CRLF in the field `name` instead. That value is normalized to `name="file X-Injected-Name: no"`, and no `X-Injected-Name` header line is created. This demonstrates that the issue is a sibling guard-coverage gap in `filename` and `contentType`, not an unavoidable multipart behavior.

The same PoV passes on current `4.2` head, `4.2.15.Final`, and `4.1.135.Final`.

## Why This Is Not Intended Behavior

Netty's own implementation already normalizes `name` before inserting it into a multipart `Content-Disposition` header. That establishes the local invariant that caller-provided multipart metadata must not be allowed to inject header line separators into Netty-generated part headers.

Netty's 4.1 and 4.2 `FileUpload` API documentation describes `filename` as the original filename provided by client software and `contentType` as the content type passed by the browser if defined. These are precisely the values upload relay, proxy, and API gateway applications commonly preserve when forwarding a file downstream.

RFC 7578 allows percent-encoding for otherwise disallowed filename characters, including control characters. The WHATWG multipart/form-data serializer escapes LF, CR, and quote bytes in names and filenames before emitting them into `Content-Disposition`. The observed behavior instead preserves raw CRLF inside the generated multipart header block.

Comparable multipart encoder issues have also been accepted as advisories in other ecosystems:

- Req `GHSA-px9f-whj3-246m` / `CVE-2026-49756`: unescaped multipart `name`, `filename`, and `content_type`;
- Axios `GHSA-445q-vr5w-6q77` / `CVE-2026-42037`: unsanitized multipart per-part `Content-Type`.

## References

- https://github.com/netty/netty/security/advisories/GHSA-6g26-xhvx-g5w3

Page: https://cve.now/GHSA-6G26-XHVX-G5W3

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
