Skip to content

http2: reject non-latin1 client request values - #63571

Open
mcollina wants to merge 3 commits into
nodejs:mainfrom
mcollina:fix/http2-reject-nonlatin1-client-request-values-pr
Open

mcollina wants to merge 3 commits into
nodejs:mainfrom
mcollina:fix/http2-reject-nonlatin1-client-request-values-pr

Conversation

@mcollina

@mcollina mcollina commented May 25, 2026 •

Copy link
Copy Markdown
Member
  • reject non-latin1 header values in HTTP/2 client requests
  • reject unescaped characters in the HTTP/2 client :path pseudo-header

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels May 25, 2026
@pimterry

pimterry commented May 28, 2026 •

Copy link
Copy Markdown
Member

There's merge conflicts here.

I think to go forward this should align with #63571 (just about to merge right now). We'd want a matching httpValidation option for HTTP/2 requests, so we can add strict behaviour like this (reject everything the RFC calls invalid) but keep relaxed validation for fetch/WHATWG compatibility.

I think the path validation is correct as-is, but for header values this PR rejects control codes like 0x01–0x08 while browser fetch does allow those: WHATWG excludes only >0xff, 0x0, and newlines (https://fetch.spec.whatwg.org/#header-value). Totally on board with the goal here, it would be good to follow the HTTP RFCs strictly by default for Node in general, as long as we keep the door open for that relaxed behaviour for fetch use cases.

For HTTP/2 we already have a related option: strictSingleValueFields - if we have a relaxed option, I'd suggest subsuming that into it as well (i.e. disable it by default when relaxed, make options mutually exclusive, eventually aim to deprecate the standalone options). We have strictFieldWhitespaceValidation too but I think that is explicitly malformed & invalid. I'm not sure if it's actually insecure, but imo we shouldn't enable for relaxed mode.

@mcollina

Copy link
Copy Markdown
Member Author

I think to go forward this should align with #63571 (just about to merge right now). We'd want a matching httpValidation option for HTTP/2 requests, so we can add strict behaviour like this (reject everything the RFC calls invalid) but keep relaxed validation for fetch/WHATWG compatibility.

The linked PR is this PR. Which one you meant?

@pimterry

Copy link
Copy Markdown
Member

😂 ah sorry! I meant #61597

mcollina added a commit to mcollina/node that referenced this pull request Jun 4, 2026
… option

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: nodejs#63571
@mcollina
mcollina force-pushed the fix/http2-reject-nonlatin1-client-request-values-pr branch from db6b9a4 to 1af0980 Compare June 4, 2026 06:42
@mcollina
mcollina force-pushed the fix/http2-reject-nonlatin1-client-request-values-pr branch from 2446dce to 2a31214 Compare June 17, 2026 11:06
- Disable strictFieldWhitespaceValidation in relaxed/insecure mode so it
  does not conflict with the relaxed behaviour (per @pimterry review).
- Document that relaxed/insecure subsumes strictSingleValueFields and
  strictFieldWhitespaceValidation.
- Add integration tests for the http2.connect() httpValidation option.
@mcollina
mcollina force-pushed the fix/http2-reject-nonlatin1-client-request-values-pr branch from 2a31214 to cfef7fb Compare November 11, 2026 09:55
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.69%. Comparing base (128f247) to head (57788f4).
⚠️ Report is 70 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63571      +/-   ##
==========================================
- Coverage   90.69%   90.69%   -0.01%     
==========================================
  Files         797      801       +4     
  Lines      279611   281905    +2294     
  Branches    53787    54329     +542     
==========================================
+ Hits       253603   255676    +2073     
- Misses      16295    16363      +68     
- Partials     9713     9866     +153     
Files with missing lines Coverage Δ
lib/internal/http2/core.js 94.95% <100.00%> (+0.02%) ⬆️
lib/internal/http2/util.js 93.13% <100.00%> (+0.20%) ⬆️

... and 110 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The http2 client request headers array form is a flat list of
[name, value, name, value, ...], not an array of pairs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants