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 — Port 4.1: Validate header values on DefaultHeaders.copy(), bulk add, entry setValue and ReadOnlyHttpHeaders (#17841) by normanmaurer · Pull Request #17854 · netty/netty

Conversation

@normanmaurer

@normanmaurer normanmaurer commented Oct 16, 2026

Copy link
Copy Markdown
Member

Motivation:

DefaultHttpHeaders validates header values by default to protect against
HTTP response splitting (CWE-113). Several code paths bypassed this
validation, so a default-constructed instance could end up carrying
CR/LF
in a header value, which the HTTP/1 encoder writes to the wire as is:

  • DefaultHeaders.copy() used a constructor that installs
    ValueValidator.NO_VALIDATION, so copies (for example from
    FullHttpMessage.copy()/replace()) did not validate values.
  • The addImpl fast path copies entries without validating them when the
    hashing strategy and name validator are identical, but did not compare
    the value validator. Values from a non-validating (or tainted) headers
    instance could be merged into a validating one.
  • HeaderEntry.setValue(...), reachable via the iterator, only checked
    for
    null.
  • ReadOnlyHttpHeaders validated header names but not header values when
    validation was requested.

Modification:

  • Pass the value validator to the copy created by DefaultHeaders.copy().
  • Only use the addImpl fast path when the value validator is the same
    instance as well.
  • Let each HeaderEntry remember the value validator of its headers (set
    in add0, so it also covers HeaderEntry subclasses such as the HTTP/2 and
    HTTP/3 ones) and validate in setValue(...).
  • Validate header values in ReadOnlyHttpHeaders when validation is
    enabled.
  • Add tests to DefaultHttpHeadersTest and ReadOnlyHttpHeadersTest.

Result:

Header value validation can no longer be bypassed through copy(),
add/set/setAll of other headers, Map.Entry.setValue(...) or
ReadOnlyHttpHeaders.


Co-authored-by: Chris Vest [email protected]

Sorry, something went wrong.

Uh oh!

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

All reactions
@normanmaurer @chrisvest
Port 4.1: Validate header values on DefaultHeaders.copy(), bulk add, …
73d6c39
…entry setValue and ReadOnlyHttpHeaders (#17841)

Motivation:

DefaultHttpHeaders validates header values by default to protect against
HTTP response splitting (CWE-113). Several code paths bypassed this
validation, so a default-constructed instance could end up carrying
CR/LF
in a header value, which the HTTP/1 encoder writes to the wire as is:

- DefaultHeaders.copy() used a constructor that installs
  ValueValidator.NO_VALIDATION, so copies (for example from
  FullHttpMessage.copy()/replace()) did not validate values.
- The addImpl fast path copies entries without validating them when the
  hashing strategy and name validator are identical, but did not compare
  the value validator. Values from a non-validating (or tainted) headers
  instance could be merged into a validating one.
- HeaderEntry.setValue(...), reachable via the iterator, only checked
for
  null.
- ReadOnlyHttpHeaders validated header names but not header values when
  validation was requested.

Modification:

- Pass the value validator to the copy created by DefaultHeaders.copy().
- Only use the addImpl fast path when the value validator is the same
  instance as well.
- Let each HeaderEntry remember the value validator of its headers (set
in add0, so it also covers HeaderEntry subclasses such as the HTTP/2 and
  HTTP/3 ones) and validate in setValue(...).
- Validate header values in ReadOnlyHttpHeaders when validation is
  enabled.
- Add tests to DefaultHttpHeadersTest and ReadOnlyHttpHeadersTest.

Result:

Header value validation can no longer be bypassed through copy(),
add/set/setAll of other headers, Map.Entry.setValue(...) or
ReadOnlyHttpHeaders.

---------

Co-authored-by: Chris Vest <[email protected]>
@normanmaurer normanmaurer mentioned this pull request Oct 16, 2026
Validate header values on DefaultHeaders.copy(), bulk add, entry setValue and ReadOnlyHttpHeaders #17841
Merged
@testlens-app

This comment has been minimized.

Sign in to view
@normanmaurer
final
9559be9
@normanmaurer
normanmaurer merged commit 0c65820 into 4.1 Oct 16, 2026
19 checks passed

Uh oh!

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

@normanmaurer normanmaurer added this to the 4.1.140.Final milestone Oct 16, 2026
@normanmaurer
normanmaurer deleted the h41 branch October 16, 2026 12:13
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
@normanmaurer @chrisvest @lltopk
Port 4.1: Validate header values on DefaultHeaders.copy(), bulk add, …
46ac9eb
…entry setValue and ReadOnlyHttpHeaders (netty#17841) (netty#17854)

Motivation:

DefaultHttpHeaders validates header values by default to protect against
HTTP response splitting (CWE-113). Several code paths bypassed this
validation, so a default-constructed instance could end up carrying
CR/LF
in a header value, which the HTTP/1 encoder writes to the wire as is:

- DefaultHeaders.copy() used a constructor that installs
  ValueValidator.NO_VALIDATION, so copies (for example from
  FullHttpMessage.copy()/replace()) did not validate values.
- The addImpl fast path copies entries without validating them when the
  hashing strategy and name validator are identical, but did not compare
  the value validator. Values from a non-validating (or tainted) headers
  instance could be merged into a validating one.
- HeaderEntry.setValue(...), reachable via the iterator, only checked
for
  null.
- ReadOnlyHttpHeaders validated header names but not header values when
  validation was requested.

Modification:

- Pass the value validator to the copy created by DefaultHeaders.copy().
- Only use the addImpl fast path when the value validator is the same
  instance as well.
- Let each HeaderEntry remember the value validator of its headers (set
in add0, so it also covers HeaderEntry subclasses such as the HTTP/2 and
  HTTP/3 ones) and validate in setValue(...).
- Validate header values in ReadOnlyHttpHeaders when validation is
  enabled.
- Add tests to DefaultHttpHeadersTest and ReadOnlyHttpHeadersTest.

Result:

Header value validation can no longer be bypassed through copy(),
add/set/setAll of other headers, Map.Entry.setValue(...) or
ReadOnlyHttpHeaders.

---------

Co-authored-by: Chris Vest <[email protected]>

---------

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

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.1.140.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

1 participant

@normanmaurer
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.