Skip to content

src: pass address and port to net permission checks - #68000

Open
araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:net-permission-resource
Open

araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:net-permission-resource

Conversation

@araujogui

Copy link
Copy Markdown
Member

Network permission checks reported the denied resource inconsistently: some passed the IP address, some the address and port, and several passed nothing.

Behaviour changes:

  • Every net permission check on an IP address (TCP, UDP, DNS, QUIC, DTLS) now reports ip:port, or [ip]:port for IPv6, as the resource of ERR_ACCESS_DENIED and of node:permission-model:net diagnostics channel messages.
  • The address is reported in its canonical form. The port is the requested one, so 0 when the OS picks it.
  • An address that cannot be parsed now fails with EINVAL before the permission check, instead of ERR_ACCESS_DENIED.
  • Checks with no address, such as adopting a file descriptor, still report an empty string.

This is groundwork for --allow-net taking a list of hosts, which needs the endpoint at every check.

Refs: #67115

Copilot AI balanced review requested due to automatic review settings December 3, 2026 19:39
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net
  • @nodejs/quic
  • @nodejs/security-wg

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Dec 3, 2026
@araujogui
araujogui force-pushed the net-permission-resource branch from c5bf9d2 to 24df1db Compare December 3, 2026 19:43
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.68182% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.58%. Comparing base (fdd741c) to head (87dd381).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/tcp_wrap.cc 72.72% 1 Missing and 8 partials ⚠️
src/udp_wrap.cc 81.81% 2 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #68000      +/-   ##
==========================================
- Coverage   92.97%   90.58%   -2.40%     
==========================================
  Files         432      802     +370     
  Lines      201316   287036   +85720     
  Branches    30713    55429   +24716     
==========================================
+ Hits       187172   260009   +72837     
- Misses      13817    17127    +3310     
- Partials      327     9900    +9573     
Files with missing lines Coverage Δ
src/cares_wrap.cc 62.78% <100.00%> (ø)
src/tcp_wrap.h 62.50% <100.00%> (ø)
src/udp_wrap.h 100.00% <ø> (ø)
src/udp_wrap.cc 79.03% <81.81%> (ø)
src/tcp_wrap.cc 70.27% <72.72%> (ø)

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

Network permission checks reported the denied resource inconsistently:
some passed only the IP address, some the address and port, and several
passed nothing at all. Report `ip:port` (`[ip]:port` for IPv6) from
every check that operates on an IP address, so that the `resource` of
`ERR_ACCESS_DENIED` errors and of `node:permission-model:net`
diagnostics channel messages identifies the endpoint.

The address is formatted from the parsed socket address, so it is
reported in its canonical form. An address that cannot be parsed now
fails with `EINVAL` before the permission check, instead of with
`ERR_ACCESS_DENIED`.

Assisted-by: Claude
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
@araujogui
araujogui force-pushed the net-permission-resource branch from 24df1db to 87dd381 Compare December 3, 2026 23:07
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++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants