Skip to content

http: forward-port pending-read fix (CVE-2026-105481) to lib/internal/http/agent.js - #67073

Open
emyei wants to merge 1 commit into
nodejs:mainfrom
emyei:http-forward-port-pending-read-fix
Open

emyei wants to merge 1 commit into
nodejs:mainfrom
emyei:http-forward-port-pending-read-fix

Conversation

@emyei

@emyei emyei commented Oct 28, 2026

Copy link
Copy Markdown

Summary

  • The hardening added for CVE-2026-105481 (commit 0683ee5, "http: ensure agent data guard works without I/O", shipped in v26.12.1) checks the OS directly for a pending read before a kept-alive socket is reused, closing the window where a peer's premature response could be delivered as the answer to the next request on the same connection.
  • That fix landed in lib/_http_agent.js on the release branches. Five days earlier, PR lib: deprecate _http_* #58535 had already moved the Agent implementation to lib/internal/http/agent.js on main, and the security fix was never forward-ported there — so main (and any v27 nightly) currently lacks this protection even though every supported release line (22.x/24.x/26.x) has it.
  • This PR restores the complete fix on main: the hasPendingRead() helper and its two call sites in lib/internal/http/agent.js (ported to the file's current structure), the unchanged lib/internal/tls/wrap.js proxy entry and src/stream_wrap.cc/.h native implementation (both already apply cleanly, byte-for-byte identical to the original fix), and the regression test test/parallel/test-http-agent-free-socket-pending-read.js that was dropped along with it.

Why now, in the open

No information here is under embargo: the original fix and its CVE have been public since 2026-10-20, and no supported/published Node.js version is affected — only main and nightlies built from it, which are not for production use. The goal is simply to close the gap before a 27.x release ships without this protection.

Test plan

  • node --check on the three modified/added JS files (syntax-verified in this environment, which does not have a full build toolchain for this repo set up).
  • Confirmed git apply --check of the original stream_wrap.cc/.h and tls/wrap.js hunks against current main — they apply unchanged.
  • Confirmed (via lib/internal/http/agent.js diff review) that the ported addRequest/on('free', ...) call sites match the structure and intent of the original lib/_http_agent.js fix.
  • CI: test/parallel/test-http-agent-free-socket-pending-read.js exercises both regression paths (free-pool reuse and direct hand-off to a queued request) and should be run by the project's build to confirm the native HasPendingRead binding links and behaves as expected on all platforms.

🤖 Generated with Claude Code

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. http Issues and PRs related to the http subsystem. needs-ci PRs that need a full CI run. tls Issues and PRs related to the tls subsystem. labels Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

@pimterry

Copy link
Copy Markdown
Member

Thanks for opening this, good catch @emyei! Agreed, we should merge this ASAP.

CC @jasnell who did the original security patch, but this looks like a clean port to me.

Right now the commit message linting is failing though, can you update that and force push? If you want to validate a commit message locally, you can do so with git rev-parse HEAD | xargs npx -q core-validate-commit --no-validate-metadata --tap (to check commit HEAD).

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.70%. Comparing base (ec7a28f) to head (f60d783).
⚠️ Report is 257 commits behind head on main.

Files with missing lines Patch % Lines
src/stream_wrap.cc 60.00% 2 Missing and 6 partials ⚠️
lib/internal/http/agent.js 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67073      +/-   ##
==========================================
+ Coverage   90.65%   90.70%   +0.05%     
==========================================
  Files         797      801       +4     
  Lines      278482   281924    +3442     
  Branches    53559    54329     +770     
==========================================
+ Hits       252445   255717    +3272     
+ Misses      16393    16345      -48     
- Partials     9644     9862     +218     
Files with missing lines Coverage Δ
lib/internal/tls/wrap.js 95.68% <100.00%> (+0.06%) ⬆️
src/stream_wrap.h 100.00% <ø> (ø)
lib/internal/http/agent.js 96.63% <96.29%> (-0.02%) ⬇️
src/stream_wrap.cc 86.10% <60.00%> (-2.19%) ⬇️

... and 150 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.

@pimterry

pimterry commented Nov 3, 2026

Copy link
Copy Markdown
Member

I'd like to get this merged sooner rather than later. @emyei do you mind updating the commit message? If not, in a few days I'll patch up the commit message and finish this myself.

The Agent data guard only runs once the event loop polls for I/O. Data
that reaches an idle kept-alive socket's OS buffer right before that
poll can be handed to the next request as if it were that request's
own response (response-queue poisoning).

Commit 0683ee5 ("http: ensure agent data guard works without I/O",
CVE-2026-105481) fixed this by checking the OS directly via a new
LibuvStreamWrap::HasPendingRead before reusing a free socket. It
landed in lib/_http_agent.js on the release branches (shipped in
v26.12.1) but was never forward-ported after PR nodejs#58535 moved the Agent
implementation to lib/internal/http/agent.js on main five days
earlier. As a result, main (and any v27 nightly built from it) lost
the protection even though every supported release line (22.x/24.x/
26.x) still has it.

This restores the complete fix on main:
- lib/internal/http/agent.js: re-add the hasPendingRead() helper and
  its two call sites (the free socket handed to a queued request, and
  the free-pool socket selected in addRequest), ported 1:1 to the
  current structure of the file.
- lib/internal/tls/wrap.js, src/stream_wrap.cc/.h: unchanged from the
  original fix, which already applies cleanly on main.
- test/parallel/test-http-agent-free-socket-pending-read.js: restore
  the regression test covering both assignment paths, so the fix
  cannot be silently dropped again by a future refactor.

Fixes: https://hackerone.com/reports/4038361
CVE-ID: CVE-2026-105481

Co-authored-by: Tim Perry <pimterry@gmail.com>
Signed-off-by: Tim Perry <pimterry@gmail.com>
@pimterry
pimterry force-pushed the http-forward-port-pending-read-fix branch from 85e07cd to f60d783 Compare November 12, 2026 17:26

@pimterry pimterry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've force pushed to sign this myself to fix the commit message (under 'b' from the DCO, I think I can sign this off as closely based on existing code we've already merged).

I'll land once CI etc passes.

@pimterry pimterry added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 12, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 12, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@pimterry pimterry added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 12, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 12, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@pimterry pimterry added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 13, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 13, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@pimterry pimterry added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 15, 2026
@github-actions github-actions Bot added resume-ci-failed Resuming CI with the resume-ci label failed and requires manual intervention. and removed resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Nov 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Failed to resume CI

✖ Failed to load PR CI job 79031: Unexpected token '<', ..."

Full Auto Start CI output
�[36m⠋�[39m Validating Jenkins credentials
�[36m⠋�[39m Validating Jenkins credentials
✔  Jenkins credentials valid
�[36m⠙�[39m Looking for CI runs for pull request 67073
�[36m⠙�[39m Looking for CI runs for pull request 67073
�[36m⠙�[39m Getting PR from nodejs/node/pull/67073
�[36m⠙�[39m Getting reviews from nodejs/node/pull/67073
�[36m⠙�[39m Getting comments from nodejs/node/pull/67073
✔  Found PR CI job 79031
�[36m⠹�[39m Querying data for job/node-test-pull-request/79031/
�[36m⠹�[39m Querying data for job/node-test-pull-request/79031/
�[36m⠹�[39m Querying API for job/node-test-pull-request/79031/

[DEBUG] [SyntaxError: Unexpected token '<', ..."    
  
  <!DOCTYPE "... is not valid JSON]
✖  Failed to load PR CI job 79031: Unexpected token '<', ..."    
  
  <!DOCTYPE "... is not valid JSON

View workflow run

@pimterry pimterry added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed resume-ci-failed Resuming CI with the resume-ci label failed and requires manual intervention. labels Nov 16, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 16, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. http Issues and PRs related to the http subsystem. needs-ci PRs that need a full CI run. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants