Skip to content

fix(cli): harden env pull file permissions#16331

Open
wesleysimplicio wants to merge 1 commit into
vercel:mainfrom
wesleysimplicio:codex/env-pull-managed-perms
Open

fix(cli): harden env pull file permissions#16331
wesleysimplicio wants to merge 1 commit into
vercel:mainfrom
wesleysimplicio:codex/env-pull-managed-perms

Conversation

@wesleysimplicio
Copy link
Copy Markdown

Problem

vercel env pull writes managed .env* files without explicitly restricting file permissions. On POSIX systems that commonly lands as group/world-readable depending on umask, which is not a great default for secrets downloaded by the CLI.

Root cause

The command writes env files with outputFile(fullPath, contents, 'utf8') and never reapplies a restricted mode after writing.

Fix

  • add a small helper that writes managed env files with mode: 0o600
  • on POSIX, follow the write with chmod(0o600) so already-existing CLI-managed files are hardened too
  • add focused unit tests covering the restricted write options and the POSIX chmod path
  • add a changeset for vercel

Solution sketch

flowchart TD
    A[env pull downloads secrets] --> B[write managed env file]
    B --> C[set mode 0o600 on create]
    C --> D{POSIX platform?}
    D -- no --> E[finish]
    D -- yes --> F[chmod file to 0o600]
    F --> E
Loading

Duplicate check

  • checked adjacent open work like #16312 and #16136; they touch nearby CLI surface but not this permission hardening behavior
  • did not find an open issue/PR specifically for restricting env pull output file mode to 0600

Tests

Attempted:

  • corepack pnpm test test/unit/commands/env/pull.test.ts

Environment note:

  • the local workspace does not have node_modules, so vitest is not available in this environment and the test command could not complete here

Added focused test coverage in:

  • packages/cli/test/unit/commands/env/pull.test.ts

Risk

Low. The change only affects files created or rewritten by env pull, and the intent matches existing secure defaults already used elsewhere for sensitive CLI material.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

🦋 Changeset detected

Latest commit: 7509968

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wesleysimplicio wesleysimplicio marked this pull request as ready for review May 14, 2026 10:16
@wesleysimplicio wesleysimplicio requested review from a team as code owners May 14, 2026 10:16
Copilot AI review requested due to automatic review settings May 14, 2026 10:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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