Skip to content

fix(security): write job sidecar files with 0600 mode (#3753)#3809

Merged
williamzujkowski merged 1 commit into
mainfrom
fix/job-sidecar-0600-mode-3753
Jun 9, 2026
Merged

fix(security): write job sidecar files with 0600 mode (#3753)#3809
williamzujkowski merged 1 commit into
mainfrom
fix/job-sidecar-0600-mode-3753

Conversation

@williamzujkowski

Copy link
Copy Markdown
Collaborator

Closes #3753.

What

Async job sidecar files (<NEXUS_DATA_DIR>/jobs/result-<jobId>.json) were written with the default umask. Defense-in-depth (post-session security audit finding): the payload may carry job-result data, so restrict to the owner if NEXUS_DATA_DIR is ever shared across users. Not exploitable today (per-user stdio MCP, randomUUID jobIds, sha256 idempotency filenames) — pure hardening.

How

  • Extracted persistJobRecord(path, record) — DRY over the four writers (writeJobPending/Complete/Failed/Cancelled, previously four identical writeFileSync calls). It writes with { mode: 0o600 } and chmodSync(path, 0o600) after — the chmod guarantees the mode even when a terminal status overwrites a pre-existing pending file (the writeFileSync mode option only applies on file create, not overwrite).

Tests (TDD red→green)

4 new tests: 0600 on each terminal write (complete/failed/cancelled), on writeJobPending create, and on the pending→complete overwrite path (the case the chmod covers). 11 store tests + 81 jobs-suite tests pass; typecheck + lint clean.

🤖 Generated with Claude Code

Async job sidecar files (jobs/result-<jobId>.json) were written with the default
umask. Defense-in-depth (#3753): the payload may carry job-result data, so restrict
to the owner in case NEXUS_DATA_DIR is ever shared across users. Not exploitable
today (per-user stdio MCP, randomUUID jobIds) — pure hardening.

- Extract persistJobRecord(path, record) (DRY over the 4 writers: pending/complete/
  failed/cancelled) — writeFileSync with mode 0o600 + chmodSync after, so the mode
  holds even when a terminal status overwrites a pre-existing default-umask pending
  file (the writeFileSync mode option only applies on create).
- 4 new tests assert 0600 on each terminal write, on pending-create, and the
  pending->complete overwrite path.

11 + 81 jobs tests pass; typecheck + lint clean.

Closes #3753.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@williamzujkowski williamzujkowski merged commit cda2da6 into main Jun 9, 2026
52 of 54 checks passed
@williamzujkowski williamzujkowski deleted the fix/job-sidecar-0600-mode-3753 branch June 9, 2026 17:17
@github-project-automation github-project-automation Bot moved this from Backlog to Done in nexus-agents project Jun 9, 2026
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.

security(defense-in-depth): set 0600 mode on job sidecar files under NEXUS_DATA_DIR

1 participant