fix: prompt guard distinguishes PR merges from direct pushes#143
Merged
Conversation
The check_origin_integrity function was reverting legitimate PR merges because it couldn't tell them apart from direct-push attacks. This caused a bootstrap loop where security fixes to the guard itself got auto-reverted. - Skip guard when all first-parent commits are merge commits (PR workflow) - Add .nightshift.json to PROMPT_GUARD_FILES (SSRF protection) - Return exit code 2 when revert push fails (was always 1) - daemon.sh handles exit codes 0/1/2 with appropriate messaging
2 tasks
fazxes
added a commit
that referenced
this pull request
Apr 6, 2026
) PR #143 introduced `local origin_rc=$?` outside any function at both origin-guard sites in daemon.sh. On bash 3.2 with set -u, this crashes the daemon with "unbound variable" -- no cycle has completed since. Also restores the exit-code-2 abort logic that PR #143 overwrote: both pentest-preflight and post-builder guard sites now call notify_human and break when check_origin_integrity returns 2 (revert failed), preventing reset_repo_state from pulling tampered origin/main and the exec self-restart from running attacker-controlled daemon.sh.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
check_origin_integritynow skips when all first-parent commits between snapshot and current are merge commits (PR workflow).nightshift.jsontoPROMPT_GUARD_FILES(restores SSRF protection from reverted PR security: fix prompt-guard revert-failure and .nightshift.json SSRF #140)Root cause
The guard couldn't distinguish
gh pr merge --merge(creates merge commits with 2+ parents) from direct pushes (single parent). It reverted PR #140 and #142's security fixes, causing the 3 test failures on main.Test plan
make check— 1012 passed, 0 failed