What happens
When a fix agent merges or rebases main into a PR branch, the post-fix gitleaks gate can fail even though the agent introduced no secrets. The agent's work is discarded and the branch is not pushed.
Observed on PR #6172:
| Workflow run |
Agent action |
gitleaks result |
| 31944245704 |
git merge origin/main |
70 commits scanned, leaks found: 1 |
| 31945204416 |
git rebase origin/main |
75 commits scanned, leaks found: 1 |
In both cases PRE_AGENT_HEAD was fdbf826 (PR head before the agent ran). The push was blocked by the post-fix script with "Secret scan blocked".
The flagged finding is a false positive from main history:
- Rule:
private-key
- Commit on main:
2385e357 — fix(#5221): redact behaviour debug artifacts before upload
- File:
.github/scripts/redact-behaviour-artifacts-test.sh
- Content: fake RSA PEM test fixture (
MIIEowIBAAKCAQEAfake), not a real credential
File-scoped scan-secrets in the agent sandbox passed. Scanning only the rebased PR commits (HEAD~5..HEAD) also passes.
What should happen
The post-fix gitleaks scan should only inspect commits the fix agent actually authored — not upstream main commits pulled in by merge or rebase.
After a rebase, PRE_AGENT_HEAD is no longer an ancestor of HEAD, so PRE_AGENT_HEAD..HEAD is not a reliable "agent commits only" range.
How to reproduce
PR_HEAD=fdbf82646667b5cef670b2c3b0d90eddc1d4c9c9
# Merge case (~70 commits in range, 1 false positive)
git checkout "$PR_HEAD"
git merge origin/main --no-edit
gitleaks detect --source . --log-opts="${PR_HEAD}..HEAD"
# Rebase case (range explodes — PRE_AGENT_HEAD orphaned)
git checkout "$PR_HEAD"
git rebase origin/main
git merge-base --is-ancestor "$PR_HEAD" HEAD # false
gitleaks detect --source . --log-opts="${PR_HEAD}..HEAD"
Context
PRE_AGENT_HEAD is recorded in .github/workflows/reusable-fix.yml (git rev-parse HEAD immediately after checkout) and passed to post-fix.sh in the agents repo, which runs:
SCAN_RANGE="${DIFF_BASE}..HEAD" # DIFF_BASE = PRE_AGENT_HEAD
gitleaks detect --source . --log-opts="${SCAN_RANGE}"
post-fix.sh already documents that PRE_AGENT_HEAD..HEAD breaks after rebase and uses merge-base for BRANCH_CHANGED_FILES / pre-commit scoping — but gitleaks still uses the broken range.
Related issues (same root cause):
- fullsend-ai/agents#318 — proposes merge-base-aware
SCAN_RANGE fix in post-fix.sh (covers Signed-off-by and gitleaks)
- fullsend#5419 — audit of rebase-unsafe commit-range checks in post-scripts
PR #6172 remains stuck at fdbf826; neither blocked fix-agent push landed.
What happens
When a fix agent merges or rebases
maininto a PR branch, the post-fix gitleaks gate can fail even though the agent introduced no secrets. The agent's work is discarded and the branch is not pushed.Observed on PR #6172:
git merge origin/main70 commits scanned,leaks found: 1git rebase origin/main75 commits scanned,leaks found: 1In both cases
PRE_AGENT_HEADwasfdbf826(PR head before the agent ran). The push was blocked by the post-fix script with "Secret scan blocked".The flagged finding is a false positive from
mainhistory:private-key2385e357—fix(#5221): redact behaviour debug artifacts before upload.github/scripts/redact-behaviour-artifacts-test.shMIIEowIBAAKCAQEAfake), not a real credentialFile-scoped
scan-secretsin the agent sandbox passed. Scanning only the rebased PR commits (HEAD~5..HEAD) also passes.What should happen
The post-fix gitleaks scan should only inspect commits the fix agent actually authored — not upstream
maincommits pulled in by merge or rebase.After a rebase,
PRE_AGENT_HEADis no longer an ancestor ofHEAD, soPRE_AGENT_HEAD..HEADis not a reliable "agent commits only" range.How to reproduce
Context
PRE_AGENT_HEADis recorded in.github/workflows/reusable-fix.yml(git rev-parse HEADimmediately after checkout) and passed topost-fix.shin the agents repo, which runs:post-fix.shalready documents thatPRE_AGENT_HEAD..HEADbreaks after rebase and uses merge-base forBRANCH_CHANGED_FILES/ pre-commit scoping — but gitleaks still uses the broken range.Related issues (same root cause):
SCAN_RANGEfix inpost-fix.sh(covers Signed-off-by and gitleaks)PR #6172 remains stuck at
fdbf826; neither blocked fix-agent push landed.