Skip to content

Permission model --permission-audit inconsistencies #65419

Description

@naugtur

Version

v26.7.0

Platform

Linux localhostage 7.0.0-29-generic #29-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 17 20:52:35 UTC 2026 x86_64 GNU/Linux

Subsystem

permission model

What steps will reproduce the bug?

p_a_repro.js
p_a_run.sh

====================================================
Running p_a_repro.js normally
>dlopen> /path/to/any.node: cannot open shared object file: No such file or directory
====================================================
Running p_a_repro.js with permission
[AUDIT] node:permission-model:fs: FileSystemRead /etc/hosts
>lstat> Access to this API has been restricted
[AUDIT] node:permission-model:fs: FileSystemRead /etc/hosts
>stat> Access to this API has been restricted. Use --allow-fs-read to manage permissions.
[AUDIT] node:permission-model:fs: FileSystem 
>symlink> fs.symlink API requires full fs.read and fs.write permissions.
>dlopen> Cannot load native addon because loading addons is disabled.
====================================================
Running p_a_repro.js with permission-audit
[AUDIT] node:permission-model:fs: FileSystemRead /etc/hosts
>lstat> Access to this API has been restricted
[AUDIT] node:permission-model:fs: FileSystemRead /etc/hosts
[AUDIT] node:permission-model:fs: FileSystem 
>symlink> fs.symlink API requires full fs.read and fs.write permissions.
>dlopen> Cannot load native addon because loading addons is disabled.
====================================================
Running p_a_repro.js with permission-audit with allow
>dlopen> /path/to/any.node: cannot open shared object file: No such file or directory
(node:61707) [PERM0001] SecurityWarning: The flag --allow-addons must be used with extreme caution. It could invalidate the permission model.
(Use `node --trace-warnings ...` to show where the warning was created)

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

Audit mode aka --permission-audit is documented as:

The --permission-audit flag enables audit mode for the Permission Model. In audit mode, permission checks are performed but access is not denied — no ERR_ACCESS_DENIED error is thrown. Instead, each permission violation is published through the node:diagnostics_channel module, allowing the application to observe and log which operations would be denied under enforce mode. Execution continues normally.

The Running p_a_repro.js normally and Running p_a_repro.js with permission-audit should have the same outcomes/errors

What do you see instead?

--permission-audit is enough to trigger some permission enforcement - namely on lstat, symlink and dlopen

Additional information

I'm interested in contributing a fix. Might need some pointers.

Activity

  1. added
    permissionIssues and PRs related to the Permission Model.
    on Aug 21, 2026
  2. theSnackOverflow commented on Aug 30, 2026

    @theSnackOverflow
    Contributor

    Reproduced on current main. Two causes:

    1. The JS-layer checks skip audit mode — lstat/symlink are checked in
      lib/fs.js / lib/internal/fs/promises.js with
      permission.isEnabled() && !permission.has(...), which also throws under
      --permission-audit. The isAuditMode() helper from lib: handle --permission-audit when propagating flags #63047 was wired into
      lib/ffi.js only. (stat behaves correctly because its check is in C++,
      behind the audit-aware macro.)
    2. dlopen is rejected before the permission check runs — audit mode still
      sets allow_native_addons = false
      (https://github.com/nodejs/node/blob/045ff95365c/src/env.cc#L988-L991), and
      DLOpen() checks no_native_addons() first
      (https://github.com/nodejs/node/blob/045ff95365c/src/node_binding.cc#L450-L455),
      so no audit event is published at all.

    Fix in #65659 — sorry for stepping in given you'd offered to take it; happy to
    close it in favor of yours, or to address review together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    permissionIssues and PRs related to the Permission Model.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions