Skip to content

fix(probe-hook): harden probe capture file writes against symlink attacks - #808

Draft
gmoncor wants to merge 1 commit into
bmad-code-org:mainfrom
gmoncor:fix/s01-09-harden-probe-hook-symlinks
Draft

gmoncor wants to merge 1 commit into
bmad-code-org:mainfrom
gmoncor:fix/s01-09-harden-probe-hook-symlinks

Conversation

@gmoncor

@gmoncor gmoncor commented Sep 17, 2026

Copy link
Copy Markdown

What: Port the hardening primitives already used by the production hook writer into bmad_loop_probe_hook.py's _atomic_write: a symlink/junction check, O_NOFOLLOW/dir_fd-anchored create+rename, an explicit 0o600 mode, and a short-write-safe write loop.

Why: The probe hook's _atomic_write currently does a plain open()+json.dump()+os.replace() with no symlink check and no explicit permissions, unlike the production relay's writer; SECURITY.md explicitly lists hook/signal-file handling as in-scope.

How:

  • Follow the repo's existing twin-file pattern: duplicate the hardened write functions into bmad_loop_probe_hook.py rather than sharing an import.
  • Add a parity/ablation test in tests/test_probe_hook.py mirroring tests/test_hook_script.py.

Testing: Run tests/test_probe_hook.py; new tests must fail against the pre-fix _atomic_write and pass after porting the hardening.

Changelog: "Security: hardened the probe-adapter capture writer against symlink-based file replacement, matching the production hook writer."

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 17, 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.

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