codex icon indicating copy to clipboard operation
codex copied to clipboard

macOS sandbox: npm exec cannot remove user-owned lock directory in writable roots with recursive deny globs

Open zaccromero opened this issue 2 weeks ago • 2 comments

npm exec fails on macOS with EPERM removing a user-owned concurrency.lock directory inside explicitly writable ~/.npm and /private/tmp roots.

Environment: codex-cli 0.169.0, Node 24.22.3, npm 11.19.1, Darwin 25.6.0. Custom permission profile extends :workspace and includes recursive deny globs for secret environment files.

Repro: npm exec --cache /private/tmp/loom-setup-npm-cache --yes --package=@jbarket/[email protected] -- loom --help

Registry fetch succeeds, then rmdirSync in libnpmexec/lib/with-lock.js fails with EPERM on the concurrency.lock directory. Directory is owned by the current user, 0755, no special flags. npm incorrectly suggests root-owned cache files.

Please investigate ancestor-directory unlink protections generated for recursive deny globs. Expected: normal dependency installation in writable roots while secret file denies remain enforced.

Separately, connector issue creation was unavailable because effective approval_policy=never, despite approvals_reviewer=auto_review. The UI explains that approval requests are disabled. This report is submitted through gh instead.

zaccromero avatar Nov 16 '26 06:11 zaccromero

Follow-up with sanitized reproduction details: after enabling approval requests, approved require_escalated commands still fail process inspection with Operation not permitted. DNS socket probes also fail with Operation not permitted, and approved package-manager requests cannot resolve hosts despite an enabled network policy. A reviewed runtime activation helper stops at its mandatory process-inspection check. Updating saved runtime selection does not establish live activation. Please investigate whether approved execution retains unintended outer process/network restrictions, and provide a supported way to activate a selected desktop runtime. No private paths, credentials, or configuration values are included in this update.

zaccromero avatar Nov 16 '26 07:11 zaccromero

Adding the additional sanitized observations from #62584, which I am consolidating into this issue following the duplicate-detection comment.

  • Local ChatGPT/Codex command environment using macOS Seatbelt; host reported macOS 27.2.1, and the available CLI reported codex-cli 0.169.0-alpha.11.1.
  • The relevant profile extended :workspace and used "**/.env*" = "deny" under [permissions.example.filesystem.":workspace_roots"].
  • Creating and deleting ordinary scratch files inside the workspace succeeded. Removing their now-empty directory trees failed with Operation not permitted, including through the client's approved elevated-execution path.
  • The affected directories belonged to the current user, had writable mode bits, and showed no immutable flags or deny ACL.
  • A newly created, private scratch directory in the already-authorized /private/tmp location completed the same create/retain-output/delete lifecycle successfully. This was outside the workspace-scoped deny subtree. Existing blocked directories were not moved there, and credential protections were not removed.

This is consistent with the scoped/nonliteral ancestor-unlink protections retained by #47920. I did not capture the installed outer runtime's generated SBPL or run a separate clean-profile A/B, so the precise attribution remains an inference.

It would help to document this consequence of recursive workspace-scoped denies and a supported cleanup workflow. If a safe empty-directory removal mechanism is possible, it should preserve the protection against renaming secret-containing ancestors out of scope.

No credential files were created, read, or copied for these checks. No private repository names, personal paths, or business data are included here.

np-angel-labiano avatar Nov 19 '26 20:11 np-angel-labiano