Skip to content

fix: Restrict credential file permissions to owner-only#11870

Merged
anthonyshew merged 1 commit intomainfrom
shew/file-permissions-check
Feb 17, 2026
Merged

fix: Restrict credential file permissions to owner-only#11870
anthonyshew merged 1 commit intomainfrom
shew/file-permissions-check

Conversation

@anthonyshew
Copy link
Copy Markdown
Contributor

@anthonyshew anthonyshew commented Feb 16, 2026

Summary

Credential files (config.json, auth.json) were created with fs::File::create() which inherits the process umask — typically 0o644 (world-readable) on Unix. On shared multi-user systems, this allowed any local user to read another user's Vercel API tokens.

  • Adds create_with_contents_secret() to AbsoluteSystemPath that sets 0o600 atomically at creation time via OpenOptions::mode(), and explicitly tightens permissions on pre-existing files
  • Applies it to all credential write paths: turbo login, auth token refresh (write_to_auth_file), and logout config rewrite
  • On Windows, delegates to create_with_contents (no POSIX permission semantics)

Testing

New tests verify:

  • Fresh files are created with 0o600
  • Pre-existing 0o644 files are tightened to 0o600 on overwrite
  • write_to_auth_file produces 0o600 end-to-end

All existing tests in turbopath, turborepo-auth, and turborepo-lib pass.

@anthonyshew anthonyshew requested a review from a team as a code owner February 16, 2026 15:16
@anthonyshew anthonyshew requested review from tknickman and removed request for a team February 16, 2026 15:16
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
examples-designsystem-docs Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
examples-kitchensink-blog Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
examples-vite-web Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
turbo-site Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
turborepo-agents Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm
turborepo-test-coverage Ready Ready Preview, Comment, Open in v0 Feb 16, 2026 3:21pm

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Feb 16, 2026

Congrats! CodSpeed is installed 🎉

🆕 4 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks


Open in CodSpeed

Credential files (config.json, auth.json) were created via
fs::File::create() which inherits the process umask, typically
resulting in world-readable 0o644 permissions. On shared systems,
this allowed other local users to read Vercel API tokens.

Add create_with_contents_secret() that sets 0o600 atomically at
file creation time on Unix, and explicitly tightens permissions
on pre-existing files. Use it for all credential write paths:
turbo login, auth token refresh, and logout config rewrite.
@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report

Metric Coverage
Lines 76.33%
Functions 47.20%
Branches 0.00%

View full report

@anthonyshew anthonyshew changed the title fix: Restrict credential file permissions to owner-only (0o600) fix: Restrict credential file permissions to owner-only Feb 16, 2026
@anthonyshew anthonyshew merged commit dba6568 into main Feb 17, 2026
178 of 179 checks passed
@anthonyshew anthonyshew deleted the shew/file-permissions-check branch February 17, 2026 03:06
github-actions Bot added a commit that referenced this pull request Feb 17, 2026
## Release v2.8.10-canary.3

Versioned docs: https://v2-8-10-canary-3.turborepo.dev

### Changes

- release(turborepo): 2.8.10-canary.2 (#11873) (`3970226`)
- perf: Replace twox-hash with xxhash-rust and optimize file hashing
(#11874) (`c4f3325`)
- fix: Restrict credential file permissions to owner-only (#11870)
(`dba6568`)
- perf: Reduce allocations in globwalk (#11528) (`227ce2d`)
- fix: Sanitize git command inputs in create-turbo (#11876) (`1d53b4f`)

---------

Co-authored-by: Turbobot <turbobot@vercel.com>
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.

1 participant