Skip to content

permission: do not enforce fs and addons in audit mode - #65659

Open
theSnackOverflow wants to merge 1 commit into
nodejs:mainfrom
theSnackOverflow:fix-permission-audit-enforce
Open

permission: do not enforce fs and addons in audit mode#65659
theSnackOverflow wants to merge 1 commit into
nodejs:mainfrom
theSnackOverflow:fix-permission-audit-enforce

Conversation

@theSnackOverflow

@theSnackOverflow theSnackOverflow commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

--permission-audit is documented to run permission checks without denying
access, but three paths still enforce:

API under --permission-audit
fs.lstat* throws ERR_ACCESS_DENIED
fs.symlink* throws ERR_ACCESS_DENIED
process.dlopen throws ERR_DLOPEN_DISABLED, no audit event published

Two causes, as far as I can tell:

  1. The JS-layer checks in lib/fs.js and lib/internal/fs/promises.js do not
    consult audit mode — isAuditMode() from lib: handle --permission-audit when propagating flags #63047 appears to have been wired
    into lib/ffi.js only.
  2. Audit mode still sets allow_native_addons = false, so DLOpen() rejects
    before reaching the audit-aware check.

The fix adds !permission.isAuditMode() to the six JS checks, keeping
permission.has() first so the audit event is still published, and leaves
addon loading enabled in audit mode while still applying the kAddon scope.

I would welcome guidance on one point: the symlink restriction comes from
CVE-2025-55130, which predates audit mode, so this reads to me as an ordering
gap rather than an intentional exception — though I may be missing context.
Glad to split that part out if security-wg would prefer.

Both new tests fail without the fix and assert the --permission behaviour as
a control; parallel/test-permission* and the full suite pass locally.
Detailed analysis is in the issue thread.

Prepared with AI assistance; I reproduced, traced, and tested this myself, and
will handle review feedback personally.

@naugtur — apologies for stepping in, as you had mentioned wanting to take
this. Happy to close in favour of your PR, or to work through review together.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Aug 30, 2026
theSnackOverflow added a commit to theSnackOverflow/board that referenced this pull request Aug 30, 2026
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.04%. Comparing base (e7a6370) to head (2bbef4a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/fs/promises.js 0.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65659      +/-   ##
==========================================
+ Coverage   90.03%   90.04%   +0.01%     
==========================================
  Files         754      754              
  Lines      255744   255752       +8     
  Branches    48313    48324      +11     
==========================================
+ Hits       230252   230295      +43     
+ Misses      16622    16600      -22     
+ Partials     8870     8857      -13     
Files with missing lines Coverage Δ
lib/fs.js 98.43% <100.00%> (+<0.01%) ⬆️
src/env.cc 85.62% <100.00%> (+0.02%) ⬆️
lib/internal/fs/promises.js 92.22% <0.00%> (-0.09%) ⬇️

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

--permission-audit is documented to perform permission checks without
denying access, publishing each violation through the diagnostics
channel while execution continues. Three code paths still enforced:

* fs.lstat() and fs.symlink() are checked in the JavaScript layer,
  which threw ERR_ACCESS_DENIED without consulting audit mode. The
  isAuditMode() helper introduced for ffi was never wired into fs.
* Addon loading was disabled upfront in Environment setup, so
  process.dlopen() failed with ERR_DLOPEN_DISABLED before reaching
  the audit-aware permission check, and no audit event was published.

Skip the throw in the JavaScript checks when audit mode is on, keeping
the permission.has() call first so the diagnostics channel event is
still published. Leave native addons enabled in audit mode while still
applying the kAddon scope, so DLOpen() publishes the denial through
the channel and continues to the regular loading path. This also
covers the worker path, which inherits kNoNativeAddons from the same
option.

Each fs API carries its own copy of the check in its sync, callback
and promise flavour, so the regression test exercises all six call
sites, asserting the --permission enforce behaviour as a control.

Fixes: nodejs#65419
Refs: nodejs#63047
Assisted-by: claude:opus-5
Signed-off-by: Ji Hoon Kang <ivory.ma9ic@gmail.com>
@theSnackOverflow
theSnackOverflow force-pushed the fix-permission-audit-enforce branch from 4efc964 to 2bbef4a Compare August 30, 2026 07:13
@RafaelGSS RafaelGSS added permission Issues and PRs related to the Permission Model. author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 30, 2026
@RafaelGSS

Copy link
Copy Markdown
Member

Good catch. Thanks.

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 30, 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

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. permission Issues and PRs related to the Permission Model.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants