Skip to content

src,permission: add --allow-net permission #58517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

RafaelGSS
Copy link
Member

@RafaelGSS RafaelGSS commented May 30, 2025

This pull request introduces the experimental --allow-net CLI flag, extending Node.js's Permission Model to manage network access explicitly. When enabled, processes require explicit permission to access network resources.

For now, let's flag it as semver-major because for actual users of Permission Model, this will be a breaking change (requiring them to pass --allow-net to get back to the current behaviour).

This initial implementation is a boolean; either you allow network access (inbound and outgoing) or you don't. I will check how feasible it is to make it more granular (e.g: --allow-net="https://nodejs.org")

Notable Change

The Permission Model now gets an extension to check network access (HTTP, HTTPS, DNS, TCP and UDP) and a new flag to allow it (--allow-net).

$ node --permission --allow-net index.js

@RafaelGSS RafaelGSS added wip Issues and PRs that are still a work in progress. permission Issues and PRs related to the Permission Model labels May 30, 2025
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/gyp
  • @nodejs/net
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels May 30, 2025
@geeksilva97
Copy link
Contributor

🚀

@RafaelGSS RafaelGSS force-pushed the add-permission-model-to-net branch from f5e6c64 to 3e95997 Compare June 10, 2025 14:14
@RafaelGSS RafaelGSS removed the wip Issues and PRs that are still a work in progress. label Jun 10, 2025
@RafaelGSS RafaelGSS marked this pull request as ready for review June 10, 2025 14:27
@RafaelGSS RafaelGSS added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 10, 2025
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
@RafaelGSS RafaelGSS force-pushed the add-permission-model-to-net branch from 3e95997 to da26847 Compare June 10, 2025 14:29
@mcollina
Copy link
Member

Is this emitting a warning?

@RafaelGSS
Copy link
Member Author

RafaelGSS commented Jun 10, 2025

Is this emitting a warning?

Now, it is 😄

Copy link

codecov bot commented Jun 10, 2025

Codecov Report

Attention: Patch coverage is 74.41860% with 22 lines in your changes missing coverage. Please review.

Project coverage is 90.13%. Comparing base (563be01) to head (062d335).
Report is 273 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/process/pre_execution.js 8.33% 11 Missing ⚠️
src/cares_wrap.h 82.35% 0 Missing and 3 partials ⚠️
src/tcp_wrap.cc 0.00% 0 Missing and 3 partials ⚠️
src/udp_wrap.cc 50.00% 0 Missing and 3 partials ⚠️
src/cares_wrap.cc 91.66% 0 Missing and 1 partial ⚠️
src/env.cc 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58517      +/-   ##
==========================================
- Coverage   90.20%   90.13%   -0.07%     
==========================================
  Files         633      639       +6     
  Lines      186852   188076    +1224     
  Branches    36690    36902     +212     
==========================================
+ Hits       168550   169525     +975     
- Misses      11090    11294     +204     
- Partials     7212     7257      +45     
Files with missing lines Coverage Δ
lib/internal/errors.js 97.50% <100.00%> (+0.02%) ⬆️
src/node_options.cc 84.57% <100.00%> (-0.68%) ⬇️
src/node_options.h 97.86% <100.00%> (-1.04%) ⬇️
src/permission/net_permission.cc 100.00% <100.00%> (ø)
src/permission/net_permission.h 100.00% <100.00%> (ø)
src/permission/permission.cc 80.00% <100.00%> (+1.50%) ⬆️
src/permission/permission.h 83.33% <ø> (ø)
src/cares_wrap.cc 54.60% <91.66%> (+0.21%) ⬆️
src/env.cc 80.70% <50.00%> (-0.08%) ⬇️
src/cares_wrap.h 79.24% <82.35%> (+0.27%) ⬆️
... and 3 more

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

Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

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

This is excellent!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@RafaelGSS RafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 10, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 10, 2025
@nodejs-github-bot
Copy link
Collaborator

@RafaelGSS RafaelGSS added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 10, 2025
@nodejs-github-bot
Copy link
Collaborator

@RafaelGSS RafaelGSS force-pushed the add-permission-model-to-net branch from e148039 to 062d335 Compare June 14, 2025 00:20
@nodejs-github-bot
Copy link
Collaborator

@RafaelGSS
Copy link
Member Author

I had to push a small test fix for websocket (when no openssl). Could you please re-approve? @mcollina @Ethan-Arrowood

Comment on lines +17 to +18
// TODO(rafaelgss): make this test more comprehensive
ws.addEventListener('error', common.mustCall());
Copy link
Contributor

Choose a reason for hiding this comment

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

This was fixed here: nodejs/undici#4274 so once that lands we can update this test to assert cause

@RafaelGSS RafaelGSS added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 16, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 16, 2025
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/58517
✔  Done loading data for nodejs/node/pull/58517
----------------------------------- PR info ------------------------------------
Title      src,permission: add --allow-net permission (#58517)
Author     Rafael Gonzaga <rafael.nunu@hotmail.com> (@RafaelGSS)
Branch     RafaelGSS:add-permission-model-to-net -> nodejs:main
Labels     semver-major, lib / src, author ready, needs-ci, permission
Commits    2
 - src,permission: add --allow-net permission
 - fixup! src,permission: add --allow-net permission
Committers 1
 - RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/58517
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/58517
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Fri, 30 May 2025 20:53:53 GMT
   ✔  Approvals: 2
   ✔  - Ethan Arrowood (@Ethan-Arrowood): https://github.com/nodejs/node/pull/58517#pullrequestreview-2932137688
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/58517#pullrequestreview-2914481831
   ✘  semver-major requires at least 2 TSC approvals
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2025-06-14T00:21:55Z: https://ci.nodejs.org/job/node-test-pull-request/67432/
- Querying data for job/node-test-pull-request/67432/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/15682641187

@RafaelGSS
Copy link
Member Author

Ping @nodejs/tsc for another TSC approval.

@RafaelGSS RafaelGSS removed the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Jun 16, 2025
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@RafaelGSS RafaelGSS added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 17, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 17, 2025
@nodejs-github-bot nodejs-github-bot merged commit 462c741 into nodejs:main Jun 17, 2025
64 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 462c741

@RafaelGSS RafaelGSS added the notable-change PRs with changes that should be highlighted in changelogs. label Jun 17, 2025
Copy link
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @RafaelGSS.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. permission Issues and PRs related to the Permission Model semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants