Skip to content

net: fail closed when BlockList peer address is unavailable - #66640

Open
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:net-blocklist-fail-closed
Open

mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:net-blocklist-fail-closed

Conversation

@mcollina

Copy link
Copy Markdown
Member

When a net.Server is configured with a blockList, the peer address is looked up with getpeername() and checked before the connection is accepted. If the peer address cannot be obtained (for example, the connection was reset before getpeername(), causing uv_tcp_getpeername() to return ENOTCONN), the access-control check was silently skipped and the connection proceeded, allowing a blocked peer to reach the application's 'connection' handler (fail open).

Fail closed: when a BlockList is configured but the peer address cannot be determined, close the connection instead of bypassing the check. A connection whose peer address cannot be obtained cannot be proven to be allowed, so it must be refused.

Ref: #66422
Ref: libuv/libuv#5337

Assisted-by: pi

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. labels Oct 10, 2026
@mcollina
mcollina force-pushed the net-blocklist-fail-closed branch from fce951a to 06c4567 Compare October 10, 2026 09:54
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.47%. Comparing base (96ee81c) to head (2841c91).
⚠️ Report is 358 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66640      +/-   ##
==========================================
+ Coverage   90.35%   90.47%   +0.11%     
==========================================
  Files         790      791       +1     
  Lines      273814   277248    +3434     
  Branches    52382    53311     +929     
==========================================
+ Hits       247409   250835    +3426     
+ Misses      16906    16813      -93     
- Partials     9499     9600     +101     
Files with missing lines Coverage Δ
lib/net.js 94.78% <100.00%> (+0.35%) ⬆️

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

When a net.Server is configured with a `blockList`, the peer address is
looked up with getpeername() and checked before the connection is
accepted. If the peer address cannot be obtained (for example, the
connection was reset before getpeername(), causing
uv_tcp_getpeername() to return ENOTCONN), the access-control check was
silently skipped and the connection proceeded, allowing a blocked peer
to reach the application's 'connection' handler (fail open).

Fail closed: when a BlockList is configured but the peer address cannot
be determined, close the connection instead of bypassing the check. A
connection whose peer address cannot be obtained cannot be proven to be
allowed, so it must be refused.

Ref: nodejs#66422
Ref: libuv/libuv#5337

Signed-off-by: Matteo Collina <hello@matteocollina.com>
Assisted-by: pi
@mcollina
mcollina force-pushed the net-blocklist-fail-closed branch from 06c4567 to 2841c91 Compare October 13, 2026 10:22
@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 Oct 13, 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 Oct 13, 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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants