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
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 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.43%. Comparing base (96ee81c) to head (06c4567).
⚠️ Report is 307 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66640      +/-   ##
==========================================
+ Coverage   90.35%   90.43%   +0.07%     
==========================================
  Files         790      791       +1     
  Lines      273814   276612    +2798     
  Branches    52382    53125     +743     
==========================================
+ Hits       247409   250155    +2746     
+ Misses      16906    16866      -40     
- Partials     9499     9591      +92     
Files with missing lines Coverage Δ
lib/net.js 94.78% <100.00%> (+0.35%) ⬆️

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

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.

2 participants