Skip to content

fix(fs): require sys permission for umask - #36222

Merged
nathanwhit merged 2 commits into
denoland:mainfrom
nathanwhit:fix/umask-sys-permission
Jul 23, 2026
Merged

nathanwhit merged 2 commits into
denoland:mainfrom
nathanwhit:fix/umask-sys-permission

Conversation

@nathanwhit

Copy link
Copy Markdown
Member

Summary

  • add umask as a scoped allow-sys permission
  • require that permission when querying or changing the process umask
  • document the requirement for both Deno.umask() and the shared Node operation
  • add coverage for Deno and Node query/set behavior, including worker permissions

Testing

  • cargo fmt --all -- --check
  • ./tools/format.js --check cli/tsc/dts/lib.deno.ns.d.ts ext/fs/ops.rs ext/node/polyfills/process.ts runtime/permissions/lib.rs tests/unit/umask_test.ts
  • cargo build -p deno
  • cargo test -p deno_permissions
  • cargo test -p unit_tests --test unit -- umask_test
  • direct process.umask() query/set checks with --allow-sys=umask and --deny-sys=umask

@bartlomieju bartlomieju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Well-scoped permission fix — gating umask at the shared op_fs_umask op is the right depth, since both Deno.umask() and process.umask() route through it, so there's no per-API duplication and no unchecked path to the syscall. Verified the descriptor wiring ("umask" added to SysDescriptor::parse matches the check_sys("umask", ...) string), and that PermissionCheckError surfaces as NotCapable.

Confirmed the change has no collateral breakage: op_fs_umask is only called from the two user-facing umask APIs — no mkdir/open/makeTemp op or runtime bootstrap invokes it — so common mode-setting FS operations are unaffected. The test-permission additions are all legitimate (those tests call Deno.umask() in their mode & ~Deno.umask() assertions), and rename_test.ts was correctly left alone because its assertDirectory guards the umask call behind mode !== undefined and every call passes no mode. Good coverage on Deno/Node query+set, the denied case, and worker propagation.

Worth calling out in the release notes (not a code issue): this is an intentional breaking change — Deno.umask() and process.umask() previously required no permission and now throw NotCapable without allow-sys=umask, which will also affect Node-compat code calling process.umask(). Documented in the d.ts and the process.ts comment, so just a heads-up for the changelog.

@nathanwhit
nathanwhit merged commit 09994b3 into denoland:main Jul 23, 2026
136 checks passed
bartlomieju pushed a commit that referenced this pull request Jul 23, 2026
## Summary

- add `umask` as a scoped `allow-sys` permission
- require that permission when querying or changing the process umask
- document the requirement for both `Deno.umask()` and the shared Node
operation
- add coverage for Deno and Node query/set behavior, including worker
permissions

## Testing

- `cargo fmt --all -- --check`
- `./tools/format.js --check cli/tsc/dts/lib.deno.ns.d.ts ext/fs/ops.rs
ext/node/polyfills/process.ts runtime/permissions/lib.rs
tests/unit/umask_test.ts`
- `cargo build -p deno`
- `cargo test -p deno_permissions`
- `cargo test -p unit_tests --test unit -- umask_test`
- direct `process.umask()` query/set checks with `--allow-sys=umask` and
`--deny-sys=umask`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants