Skip to content

fix(web): create the serve token file owner-only and atomically - #15

Merged
BoozeLee merged 1 commit into
mainfrom
fix/token-file-race
Oct 13, 2026
Merged

BoozeLee merged 1 commit into
mainfrom
fix/token-file-race

Conversation

@BoozeLee

Copy link
Copy Markdown
Collaborator

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 syncToken and 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

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>
@BoozeLee
BoozeLee merged commit c370bc2 into main Oct 13, 2026
6 checks passed
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