Skip to content

src: let embedders exempt linked bindings from the addon permission - #66067

Open
codebytere wants to merge 1 commit into
nodejs:mainfrom
codebytere:embedder-linked-binding-permission
Open

codebytere wants to merge 1 commit into
nodejs:mainfrom
codebytere:embedder-linked-binding-permission

Conversation

@codebytere

Copy link
Copy Markdown
Member

Refs: #65432

Since #65432 process._linkedBinding() is subject to the permission model's addon scope, the same as process.dlopen(). A stock node binary has no linked bindings, so this only affects embedders, and for an embedder that implements part of its runtime as linked bindings (NODE_LINKED_MODULE / node::AddLinkedBinding()) it means its own bootstrap cannot reach them under --permission unless the user also passes --allow-addons - which then allows loading addons from the file system as well.

This adds EnvironmentFlags::kNoAddonPermissionForLinkedBindings. When an embedder sets it, GetLinkedBinding() skips the addon permission check for that Environment and the worker threads it creates; process.dlopen() stays gated by --allow-addons and the default behavior is unchanged. The reasoning is that --allow-addons guards loading native code from disk at runtime, while linked bindings are compiled into the executable by the embedder and trusted the same way the built-in bindings are.


Disclosure: the code, tests and this description were written by Claude Code, directed and reviewed by @codebytere.

process._linkedBinding() is subject to the permission model's addon
scope since the check was added to GetLinkedBinding(). For an embedder
that implements part of its runtime as linked bindings this means its
own bootstrap cannot reach them under --permission unless the user
also passes --allow-addons, which allows loading addons from the file
system as well.

Add EnvironmentFlags::kNoAddonPermissionForLinkedBindings. When set,
GetLinkedBinding() skips the addon permission check for that
Environment and the worker threads it creates; process.dlopen() stays
gated and the default behavior is unchanged.

Refs: nodejs#65432
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
@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 Sep 16, 2026
@codebytere codebytere added semver-minor PRs that contain new features and should be released in the next minor version. embedding Issues and PRs related to embedding Node.js in another project. labels Sep 16, 2026
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.26%. Comparing base (67e66b8) to head (eee9f6c).

Files with missing lines Patch % Lines
src/node_worker.cc 0.00% 2 Missing and 1 partial ⚠️
src/node_binding.cc 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66067      +/-   ##
==========================================
- Coverage   90.27%   90.26%   -0.01%     
==========================================
  Files         789      789              
  Lines      271473   271480       +7     
  Branches    51808    51815       +7     
==========================================
- Hits       245066   245064       -2     
- Misses      16880    16885       +5     
- Partials     9527     9531       +4     
Files with missing lines Coverage Δ
src/env-inl.h 93.95% <100.00%> (+0.02%) ⬆️
src/env.h 97.26% <ø> (ø)
src/node.h 91.66% <ø> (ø)
src/node_binding.cc 70.79% <66.66%> (+0.16%) ⬆️
src/node_worker.cc 82.05% <0.00%> (-0.05%) ⬇️

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

c++ Issues and PRs that require attention from people who are familiar with C++. embedding Issues and PRs related to embedding Node.js in another project. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants