Repository navigation
fix(web): create the serve token file owner-only and atomically - #15
Merged
Merged
Conversation
The Playwright config checked that serve.token was missing, wrote it with default permissions and then chmod-ed it to 0600: a check-then- write race (CodeQL js/file-system-race) and a window where the token could be read by other users. It is now written once with mode 0600 and the exclusive wx flag; an existing file is left as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes code-scanning alert #4 (js/file-system-race, web/playwright.config.ts:29).
Real issue, small: exists-check → write (default perms) → chmod 0600 left a race and a window where the bearer token was readable by other local users.
Change: one
writeFileSync(local, token, { mode: 0o600, flag: "wx" }); EEXIST means another process or an earlier run already created it, so it is left alone. Copy-from-main and mint-fresh behaviour unchanged.Checked locally by extracting the real
syncTokenand running it under Node: clean checkout mints a 24-char token at mode 600; a worktree copies main's token at 600; an existing file and the main checkout are untouched. CI runs the Playwright e2e on a clean checkout (the mint path).🤖 Generated with Claude Code