Skip to content

Harden claude-review workflow against fork-PR prompt injection#415

Merged
hbrodin merged 1 commit into
mainfrom
harden-claude-review-414
Jul 22, 2026
Merged

Harden claude-review workflow against fork-PR prompt injection#415
hbrodin merged 1 commit into
mainfrom
harden-claude-review-414

Conversation

@hbrodin

@hbrodin hbrodin commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Closes #414.

Fork PRs bring untrusted diffs, commit messages, and comments into the review agent's context. There an injection payload plus the read primitive (grep/rg/jq/find/Read on /proc/self/environ, which holds ANTHROPIC_API_KEY and GITHUB_TOKEN) and the write sink (gh pr comment, inline comments) form an exfil chain. The author-association gate on the triggering comment does not cover this, because the untrusted content is the PR author's diff, not the comment.

Changes (all in .github/workflows/claude-review.yml)

  • Fork-PR caution. A Classify PR authorship trust step reads isCrossRepository via gh pr view; a conditional Caution reviewer… step posts a warning comment before the review runs. Fork PRs get the warning; same-repo branch PRs (author already has push access) do not, keeping the caution meaningful rather than banner-blindness.
  • Prompt hardening. A SECURITY — UNTRUSTED INPUT preamble at the top of the prompt: block instructs the agent to treat all diff/commit/comment content as data, never instructions, and never read env, /proc, credentials, or CI secrets.
  • Corrected security comment. The comment above claude_args no longer claims the allowlist eliminates env reads (it does not — grep/rg/jq/find/Read all read /proc/self/environ). It now states the allowlist narrows the exfil surface to observable, GitHub-only channels and that the author-association gate is the actual boundary.

The author-association if: gate and the tool allowlist string from #410 are unchanged.

The optional structural fix (issue item 4 — keep the secrets out of the Bash subprocess environment / sandbox /proc) is not included; it is a larger change and the issue marks it as stretch, to do only if fork-PR review becomes an active threat.

Verification

  • actionlint — pass
  • zizmor — pass (no findings)

🤖 Generated with Claude Code

Fork PRs carry untrusted diffs, commit messages, and comments into the
review agent's context, where an injection payload plus the read
(grep/rg/jq/find/Read on /proc/self/environ) and write (gh pr comment)
tools form an exfil chain. The author-association gate on the triggering
comment does not cover this, because the untrusted content is the PR
author's diff, not the comment.

- Classify the PR via isCrossRepository and post a caution comment before
  the review runs on a fork PR (not on same-repo branch PRs).
- Add an untrusted-input preamble to the agent prompt: treat diff content
  as data, never instructions, and never read env/secrets.
- Correct the claude_args comment: the allowlist narrows the exfil
  surface to observable GitHub channels; it does not eliminate env reads,
  and the author-association gate is the actual boundary.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hbrodin
hbrodin merged commit a0c87d3 into main Jul 22, 2026
8 checks passed
@hbrodin
hbrodin deleted the harden-claude-review-414 branch July 22, 2026 08:13
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.

Harden claude-review workflow against prompt-injection in fork PR diffs

1 participant