Skip to content

fix(cli): create self-heal temp files exclusively - #593

Draft
seonghobae wants to merge 13 commits into
developmentalfrom
sentinel/fix-crypto-random-6337153868645852919
Draft

fix(cli): create self-heal temp files exclusively#593
seonghobae wants to merge 13 commits into
developmentalfrom
sentinel/fix-crypto-random-6337153868645852919

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 7, 2026

Copy link
Copy Markdown

Current exact authority

  • base: developmental@2fa92012bcf80acc1f921a4bafea76b3b1424b46
  • exact head: 800f584c639e2eee81fc0e95c2b78e81a858d40b
  • fresh compare: ahead 12 / behind 0
  • effective files: packages/cli/src/lib/event-sender.ts, packages/cli/src/lib/event-sender.test.ts

Finding and RED

The original change replaced Math.random() with 128-bit crypto.randomBytes(). That removes practical name prediction, but unpredictability alone is not the filesystem admission boundary: writeFileSync(..., 'utf8') can open an already-existing pathname and follow a pre-created symlink. The temp-file create itself must be exclusive.

Focused RED 33d00bb84b7ccec968fdc5d26ee8ae7578da6e89 first required exclusive creation. The later test refinement 5f15cf47a1579b1eb661e25a2ab4ed32990f999c narrows the contract to the causal invariant only: flag: 'wx'. It deliberately drops the earlier 0o600 assertion because changing the replacement file's mode was not necessary to close the pathname race and could change existing project-file permission behavior.

Minimal causal repair and intervening-delta adoption

The current source keeps the cryptographic suffix and writes the adjacent temporary file with { encoding: 'utf8', flag: 'wx' } before the existing rename. A pathname that already exists therefore fails closed instead of being opened or followed, while the prior default mode/umask semantics remain unchanged.

After exact 91dba856c07fa15c9b8367108ad24a21a0647776, normal descendant 9f3eae6bffdec765eb5c10e009ba5193c24cb403 reintroduced the prior non-exclusive write, removed the focused regression, restored unrelated .trivyignore CVE suppressions, and restored branch-local Sentinel doctrine. It remains in ancestry; normal child c9dd7ccd389ac55d7737af8d3d9cf1cdeb6a5a44 re-adopted the reviewed tree without force update. Current descendants then removed the non-causal mode change while preserving the exclusive-create boundary. No distinct valid semantic delta from the intervening commit was discarded.

The security scanner has already shown that the removed suppressions conceal real transitive dependency findings; those need causal package-graph repair rather than an ignore file. That dependency repair stays separate from this filesystem-boundary slice.

Gate

Keep Draft. Exact-current repository tests/lint, Security/SAST/CodeQL and qualifying independent current-head review must all be terminal and acceptable before promotion. Earlier run results do not transfer across the latest descendant. Do not merge by suppressing dependency findings, synthesizing status, or weakening the exclusive-create invariant.

@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae seonghobae changed the title 🛡️ Sentinel: [LOW] Fix 암호학적 난수 사용 (CWE-330 방지) fix(cli): create self-heal temp files exclusively Sep 7, 2026
@seonghobae
seonghobae marked this pull request as draft September 7, 2026 21:01
@seonghobae seonghobae added bug Something isn't working priority: medium Normal-priority or P2 work labels Sep 8, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: medium Normal-priority or P2 work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant