Harden greenlight reviewer against instruction-file injection from the reviewed checkout - #8435
Merged
Merged
Conversation
…e reviewed checkout **Impact:** greenlight PR-reviewer workflow (CI only); no change to the `review` scan or the CLI service **Risk:** medium ## What Adds two fail-closed controls to `greenlight-pr-review.yml`, both running before the model: a sanitize step that strips every in-repo AI-assistant instruction file (`CLAUDE.md`, `CLAUDE.local.md`, `AGENTS.md`, `.claude/`, `.cursorrules`, `.github/copilot-instructions.md`) from the untrusted `./pytorch` checkout and restores only pytorch `main`'s trusted `.claude/skills/`, plus a deny-root runtime detector that fails the review if any instruction file actually loaded from under `./pytorch` (or if the sanitize/hook machinery never ran). ## Why The reviewer checks out the PR's `pytorch/pytorch` tree and points Claude Code at it. Any of those instruction files auto-loads as reviewer steering, so a reviewed PR could plant a `CLAUDE.md` (or equivalent) to override the reviewer's own task and coax a favorable verdict. Stripping them at the source plus a fail-closed detector that catches a poisoned-but-successful run closes that injection vector. This is the first hardening item from the post-MVP threat-model pass. # Notes - The detector depends on the `SessionStart` and `InstructionsLoaded` hooks firing under the pinned `claude-code-action`; it fails closed if they don't, but the first live dispatch should confirm they actually fire. - The forbidden-name set is single-sourced in the sanitize script and must be re-verified on any `claude-code-action` / Claude Code CLI bump (last verified CLI 2.1.169 / action v1.0.141). `claudeMdExcludes` in the settings is insurance only, a no-op on the pinned CLI — not a substitute for the sanitize step. - This does **not** close the higher-severity cred-exfil gap: the model keeps unrestricted `Read` and its verdict `message` is not secret-scrubbed, so a data-injection payload could still coax it to read a credential and emit it. Constraining `Read` and scrubbing the published message remain open follow-ups. - The new hooks live at `.claude/hooks/greenlight/` and are excluded from test-infra's shared lintrunner; they're linted/typechecked/tested through greenlight's own just recipes, run by `greenlight-tests.yml` (which now also triggers on changes to the reviewer workflow). Signed-off-by: Jean Schmidt <contato@jschmidt.me>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
izaitsevfb
approved these changes
Aug 4, 2026
jeanschmidt
temporarily deployed
to
greenlight-record
August 5, 2026 00:35 — with
GitHub Actions
Inactive
jeanschmidt
temporarily deployed
to
greenlight-record
August 5, 2026 00:36 — with
GitHub Actions
Inactive
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.
Impact: greenlight PR-reviewer workflow
Risk: medium
What
Adds two fail-closed controls to
greenlight-pr-review.yml, both running before the model: a sanitize step that strips every in-repo AI-assistant instruction file (CLAUDE.md,CLAUDE.local.md,AGENTS.md,.claude/,.cursorrules,.github/copilot-instructions.md) from the untrusted./pytorchcheckout and restores only pytorchmain's trusted.claude/skills/, plus a deny-root runtime detector that fails the review if any instruction file actually loaded from under./pytorch(or if the sanitize/hook machinery never ran).Why
The reviewer checks out the PR's
pytorch/pytorchtree and points Claude Code at it. Any of those instruction files auto-loads as reviewer steering, so a reviewed PR could plant aCLAUDE.md(or equivalent) to override the reviewer's own task and coax a favorable verdict. Stripping them at the source plus a fail-closed detector that catches a poisoned-but-successful run closes that injection vector. This is the first hardening item from the post-MVP threat-model pass.Notes
SessionStartandInstructionsLoadedhooks firing under the pinnedclaude-code-action; it fails closed if they don't, but the first live dispatch should confirm they actually fire.claude-code-action/ Claude Code CLI bump (last verified CLI 2.1.169 / action v1.0.141).claudeMdExcludesin the settings is insurance only, a no-op on the pinned CLI — not a substitute for the sanitize step.Readand its verdictmessageis not secret-scrubbed, so a data-injection payload could still coax it to read a credential and emit it. ConstrainingReadand scrubbing the published message remain open follow-ups..claude/hooks/greenlight/and are excluded from test-infra's shared lintrunner; they're linted/typechecked/tested through greenlight's own just recipes, run bygreenlight-tests.yml(which now also triggers on changes to the reviewer workflow).