GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Reject all control characters and DEL in HTTP response reason phrases by qchole · Pull Request #18331 · netty/netty

Conversation

@qchole

@qchole qchole commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Motivation:

HttpResponseStatus only rejected CR and LF in the reason phrase. Other control characters (NUL, VT, FF, ...) and DEL were still accepted when parsing a response status line and written verbatim to the wire by HttpResponseEncoder. Lenient downstream parsers may treat these as line separators (response splitting / desync) and C-string based parsers may truncate at NUL. This closes the sibling gap of the request line hardening: RFC 9110 defines the reason-phrase as
*( HTAB / SP / VCHAR / obs-text ).

Modification:

Reject every control character except HTAB, and DEL, in the HttpResponseStatus reason phrase. HTAB and SP remain legal.

Result:

A response with control characters in its reason phrase is now rejected by the decoder instead of being accepted and re-encoded verbatim.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
qchole and others added 2 commits November 10, 2026 11:29
@qchole
Reject all control characters and DEL in HTTP response reason phrases
cd683e2
Motivation:

HttpResponseStatus only rejected CR and LF in the reason phrase. Other
control characters (NUL, VT, FF, ...) and DEL were still accepted when
parsing a response status line and written verbatim to the wire by
HttpResponseEncoder. Lenient downstream parsers may treat these as line
separators (response splitting / desync) and C-string based parsers may
truncate at NUL. This closes the sibling gap of the request line
hardening: RFC 9110 defines the reason-phrase as
*( HTAB / SP / VCHAR / obs-text ).

Modification:

- Reject every control character except HTAB, and DEL, in the
  HttpResponseStatus reason phrase. HTAB and SP remain legal.
- Add regression tests for the constructor, parseLine and the response
  decoder, including acceptance of HTAB and obs-text.

Result:

A response with control characters in its reason phrase is now rejected
by the decoder (BAD_MESSAGE) instead of being accepted and re-encoded
verbatim.

Potentially breaking: HttpResponseStatus now throws
IllegalArgumentException for reason phrases containing control
characters (except HTAB) or DEL.
@qchole
Merge branch '4.2' into fix/http-response-reason-phrase-control-chars
167a209
@testlens-app

testlens-app Bot commented Nov 10, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 167a209
▶️ Tests: 59786 executed
⚪️ Checks: 26/26 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer requested a review from franz1981 November 11, 2026 08:31
@normanmaurer

normanmaurer commented Nov 11, 2026

Copy link
Copy Markdown
Member

@franz1981 PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Nov 13, 2026

Copy link
Copy Markdown
Member

@qchole please sign our ICLA and let me know once done: https://netty.io/s/icla

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@qchole

qchole commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@qchole please sign our ICLA and let me know once done: https://netty.io/s/icla

@normanmaurer Done — I've signed the ICLA.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.2.21.Final milestone Nov 13, 2026
@normanmaurer
normanmaurer merged commit aa30b7a into netty:4.2 Nov 13, 2026
27 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Nov 13, 2026
@netty-project-bot

netty-project-bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot

netty-project-bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #18381

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Nov 13, 2026
Auto-port 4.1: Reject all control characters and DEL in HTTP response reason phrases #18381
Merged
@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Nov 13, 2026
@normanmaurer normanmaurer mentioned this pull request Nov 13, 2026
Port 5.0: Reject all control characters and DEL in HTTP response reason phrases (#18331) #18382
Merged
@normanmaurer

normanmaurer commented Nov 13, 2026

Copy link
Copy Markdown
Member

Ported to 5.0: #18382

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Nov 13, 2026
@qchole
qchole deleted the fix/http-response-reason-phrase-control-chars branch November 13, 2026 14:34
@He-Pin He-Pin mentioned this pull request Nov 13, 2026
Validate custom HTTP response reason phrases apache/pekko-http#1452
Merged
normanmaurer added a commit that referenced this pull request Nov 13, 2026
@normanmaurer
Fix 4.1 test compilation: avoid lambdas in HttpResponseStatusTest
189cefe
Motivation:

The auto-port of #18331 added tests using lambda expressions, but the 4.1
branch compiles tests with -source 1.6, so verify-pr failed with
'lambda expressions are not supported in -source 1.6'.

Modification:

Replace the lambdas with anonymous Executable classes and drop the
assertThatThrownBy usage in favour of assertThrows plus assertThat.

Result:

The tests compile on the 4.1 Java 6 baseline.
chrisvest pushed a commit that referenced this pull request Nov 13, 2026
@netty-project-bot @qchole @normanmaurer
Auto-port 4.1: Reject all control characters and DEL in HTTP response…
2df8707
… reason phrases (#18381)

Auto-port of #18331 to 4.1
Cherry-picked commit: aa30b7a

---
Motivation:

HttpResponseStatus only rejected CR and LF in the reason phrase. Other
control characters (NUL, VT, FF, ...) and DEL were still accepted when
parsing a response status line and written verbatim to the wire by
HttpResponseEncoder. Lenient downstream parsers may treat these as line
separators (response splitting / desync) and C-string based parsers may
truncate at NUL. This closes the sibling gap of the request line
hardening: RFC 9110 defines the reason-phrase as
*( HTAB / SP / VCHAR / obs-text ).

Modification:

Reject every control character except HTAB, and DEL, in the
HttpResponseStatus reason phrase. HTAB and SP remain legal.

Result:

A response with control characters in its reason phrase is now rejected
by the decoder instead of being accepted and re-encoded verbatim.

---------

Co-authored-by: 秦利斌 <[email protected]>
Co-authored-by: Norman Maurer <[email protected]>
chrisvest pushed a commit that referenced this pull request Nov 13, 2026
@normanmaurer @qchole
Port 5.0: Reject all control characters and DEL in HTTP response reas…
53854f3
…on phrases (#18331) (#18382)

Motivation:

Port of #18331 to 5.0.

HttpResponseStatus only rejected CR and LF in the reason phrase. Other
control characters (NUL, VT, FF, ...) and DEL were still accepted when
parsing a response status line and written verbatim to the wire by
HttpResponseEncoder. Lenient downstream parsers may treat these as line
separators (response splitting / desync) and C-string based parsers may
truncate at NUL. RFC 9110 defines the reason-phrase as *( HTAB / SP /
VCHAR / obs-text ).

Modification:

Cherry-pick of aa30b7a from 4.2. The only conflict was in
HttpResponseDecoderTest, where `testInvalidHeaders0` declares `throws
Exception` on 5.0; the new tests were adjusted accordingly.

Result:

A response with control characters (other than HTAB) or DEL in its
reason phrase is now rejected by the decoder instead of being accepted
and re-encoded verbatim.

Potentially breaking: this adds stricter validation by default; reason
phrases containing such characters that were previously accepted are now
rejected.

Co-authored-by: 秦利斌 <[email protected]>
He-Pin added a commit to He-Pin/incubator-pekko-http that referenced this pull request Nov 17, 2026
@He-Pin
fix: validate custom HTTP response reason phrases
fed72dd
Motivation:
Keep constructed status reasons within the HTTP/1 reason-phrase grammar.
The test suite must also compile where generated case-class copy methods
inherit constructor visibility, including Scala 3 and Scala next.

Modification:
Validate concrete status constructors, preserve legal bytes, cover public
factories, and document unknown-status parsing behavior. Remove test calls
to inaccessible generated copy methods while retaining public factory
coverage. Keep parser and validation behavior unchanged by this CI fix.

Result:
The original construction-time validation remains intact. Tests no longer
rely on case-class copy methods that are not public across Scala versions.
The separate review question about parser behavior remains unresolved.

Tests:
- git diff --check: passed.
- Static check: no generated copy calls remain in ResponseRendererSpec;
  existing public factory coverage and imports are retained.
- Scala compilation, tests, MiMa and formatting were not run for this
  revision: a working full JDK is unavailable. Prior-head reported passes
  are not evidence that this revised commit passes.

References:
Refs apache#1452 and PJ Fanning review 5938963618.
Refs netty/netty#18331 and RFC 9112 section 4.
pjfanning pushed a commit to He-Pin/incubator-pekko-http that referenced this pull request Nov 17, 2026
@He-Pin @pjfanning
fix: validate custom HTTP response reason phrases
e70eca4
Motivation:
Keep constructed status reasons within the HTTP/1 reason-phrase grammar.
The test suite must also compile where generated case-class copy methods
inherit constructor visibility, including Scala 3 and Scala next.

Modification:
Validate concrete status constructors, preserve legal bytes, cover public
factories, and document unknown-status parsing behavior. Remove test calls
to inaccessible generated copy methods while retaining public factory
coverage. Keep parser and validation behavior unchanged by this CI fix.

Result:
The original construction-time validation remains intact. Tests no longer
rely on case-class copy methods that are not public across Scala versions.
The separate review question about parser behavior remains unresolved.

Tests:
- git diff --check: passed.
- Static check: no generated copy calls remain in ResponseRendererSpec;
  existing public factory coverage and imports are retained.
- Scala compilation, tests, MiMa and formatting were not run for this
  revision: a working full JDK is unavailable. Prior-head reported passes
  are not evidence that this revised commit passes.

References:
Refs apache#1452 and PJ Fanning review 5938963618.
Refs netty/netty#18331 and RFC 9112 section 4.
@mkurz mkurz mentioned this pull request Nov 18, 2026
Upgrade Netty to 4.2.21.Final AsyncHttpClient/async-http-client#2395
Merged
6 tasks done
pjfanning added a commit to apache/pekko-http that referenced this pull request Nov 18, 2026
@He-Pin @pjfanning
Validate custom HTTP response reason phrases (#1452)
b2f6e58
* fix: validate custom HTTP response reason phrases

Motivation:
Keep constructed status reasons within the HTTP/1 reason-phrase grammar.
The test suite must also compile where generated case-class copy methods
inherit constructor visibility, including Scala 3 and Scala next.

Modification:
Validate concrete status constructors, preserve legal bytes, cover public
factories, and document unknown-status parsing behavior. Remove test calls
to inaccessible generated copy methods while retaining public factory
coverage. Keep parser and validation behavior unchanged by this CI fix.

Result:
The original construction-time validation remains intact. Tests no longer
rely on case-class copy methods that are not public across Scala versions.
The separate review question about parser behavior remains unresolved.

Tests:
- git diff --check: passed.
- Static check: no generated copy calls remain in ResponseRendererSpec;
  existing public factory coverage and imports are retained.
- Scala compilation, tests, MiMa and formatting were not run for this
  revision: a working full JDK is unavailable. Prior-head reported passes
  are not evidence that this revised commit passes.

References:
Refs #1452 and PJ Fanning review 5938963618.
Refs netty/netty#18331 and RFC 9112 section 4.

* Drop invalid reason characters when parsing responses

Motivation:
With reason validation in the status constructors, an HTTP/1 response with
an unregistered status code and a control character in its reason phrase
failed at message start. RFC 9112 section 4 says a client SHOULD ignore
the reason-phrase content, so the reason should not make the response
unusable.

Modification:
Remove control characters other than HTAB, and DEL, from the received
reason before building the custom status. Update the parser test and the
http-model docs accordingly. Application-constructed statuses are still
validated.

Result:
Responses from servers with sloppy reason phrases still parse; the status
code and the remaining reason text are kept.

Tests:
- sbt "http-core/testOnly ...ResponseParserCRLFSpec ...ResponseParserLFSpec ...ResponseRendererSpec": 111 passed

References:
Refs #1452 review

---------

Co-authored-by: PJ Fanning <[email protected]>
hyperxpro pushed a commit to AsyncHttpClient/async-http-client that referenced this pull request Nov 21, 2026
@mkurz @claude
Upgrade Netty to 4.2.21.Final (#2395)
8f6d126
## Summary

- Upgrades Netty from 4.2.20.Final to
[4.2.21.Final](https://github.com/netty/netty/releases/tag/netty-4.2.21.Final).
It mainly reverts a build mistake in 4.2.20: Netty's native libraries
for x86_64 and aarch64 required glibc 2.33. AHC declares the native
epoll and io_uring jars at its Netty version, and when they do not load,
it falls back to NIO, silently unless `useNativeTransport` is set. On
4.2.20 that would happen on systems with an older glibc, such as RHEL 8
or Ubuntu 20.04. AHC 3.0.14 used Netty 4.2.18, so no AHC release has
4.2.20.
- 4.2.21 also fixes `ZstdDecoder` and `ZstdDecompressor` at a
non-positive `io.netty.compression.defaultMaxForwardBytes`
(netty/netty#18289). This PR drops AHC's workarounds for that bug, so
zstd now waits for demand at any value of the property, like br and
snappy. A zero or negative value of the property now needs Netty 4.2.21
or later.

## Change

- **Netty 4.2.21.Final.**
- **Drop the `ZstdDecoder` replacement from #2375.** At a non-positive
value of the property, `Http1ContentDecompressor` replaced the
`ZstdDecoder` that `HttpContentDecompressor` creates with one whose
buffers hold `MAX_PART_SIZE`, because Netty's decoder handed on an empty
body at 0 and failed below it.
- **Drop the zstd guard from #2362.** At such a value, zstd went to
`HttpContentDecompressor` instead of `PullDecompression`, because
Netty's `ZstdDecompressor` handed out nothing at 0 while reporting more
output. It now takes the pull path there too:
  - it waits for demand;
  - parts are at most 64 KiB;
  - the size limit applies;
- a truncated stream fails with `Truncated zstd stream` instead of
ending quietly.
- **Docs:** the README and the Javadoc of
`ResponseBodyControl.suspend()` and of `Http1ContentDecompressor` no
longer make an exception for zstd. The README and `suspend()` say
instead that a zero or negative value of the property needs Netty 4.2.21
or later. With Netty 4.2.17 to 4.2.20, zstd responses then fail at a
negative value, and at 0 they never end and keep the event loop busy, as
Netty's `ZstdDecompressor` hands out empty buffers while it reports more
output. `MAX_FORWARD_BYTES` is private, since only
`Http1ContentDecompressor` uses it now.
- **Test:** `Http1ContentDecompressorForwardThresholdTest` runs with the
property at 0 and -1 in a fresh JVM. It now also checks zstd while
suspending after every part (one part per resume, none larger than
`MAX_PART_SIZE`) and a truncated zstd body (it fails, and nothing is
left allocated).

## Notes

- With the property at its default (64 KiB), nothing changes for zstd.
- Other changes in 4.2.21 that touch AHC's paths:
- Netty now also rejects control characters such as NUL and ESC, and
DEL, in a response's reason phrase (netty/netty#18331). CR and LF were
already rejected; HTAB is still allowed.
  - `SslHandler` changes: netty/netty#18253, #18323, #18363 and #18406.
  
  AHC's tests pass without changes.

## AI disclosure

Claude Code on behalf of Matthias Kurz. The commit includes
`Co-Authored-By` per `AGENTS.md`.

## Test plan

- [x] `./mvnw -B -ntp -Dgpg.skip=true clean verify` on JDK 11: 2,098
tests, 0 failures, 0 errors, 11 skipped; Revapi passed. No test-skipping
flags were used.
- [x] With the README and Javadoc change from review (`5fd35bad8`), the
same `clean verify`: 2,098 tests, 0 failures, 0 errors, 22 skipped;
Revapi passed. Docker was not running, so the 11 Testcontainers proxy
tests skipped themselves; they ran and passed in the runs above, on the
same code.
- [x] The version change alone, without the other changes, passes the
same `clean verify`: 2,098 tests, 0 failures.
- [x] The extended test fails where it should:
- with the guard put back, at 0 and -1: "the suspended zstd body did not
wait for demand after its first part";
- without the workarounds on Netty 4.2.20: at 0, the check hangs until
its 60 s timeout; at -1, it fails with `IllegalArgumentException:
initialCapacity : -1`.
- [x] The `Http1ContentDecompressor*Test`,
`Http2ContentDecompressorTest`, `Http1Decompression*Test` and
`ResponseBodyControlTest` classes: 142 tests, 0 failures.
- [x] Merged with #2394 (`ef18b0b68`): no conflicts; the same classes,
203 tests, 0 failures; `clean verify` on JDK 11, 2,159 tests, 0
failures, 0 errors, 11 skipped; Revapi passed.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@franz1981 franz1981 Awaiting requested review from franz1981

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.21.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@qchole @normanmaurer @netty-project-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.