Skip to content

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

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

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

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b6c35c55-03b4-4267-ba16-d6b2e911cfc9

📥 Commits

Reviewing files that changed from the base of the PR and between ddd2bf8 and 450f859.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/bmad_loop/data/bmad_loop_probe_hook.py
  • tests/test_probe_hook.py

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.

@gmoncor
gmoncor force-pushed the fix/s01-09-harden-probe-hook-symlinks branch from b9876a9 to 450f859 Compare September 23, 2026 10:05
@gmoncor
gmoncor marked this pull request as ready for review September 23, 2026 11:05
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