Repository navigation
fix(claude-review): remove the agent's shell tools and redact credentials - #111
Closed
crowecawcaw wants to merge 1 commit into
Closed
crowecawcaw wants to merge 1 commit into
crowecawcaw wants to merge 1 commit into
Conversation
…ials The agent's tools were not as read-only as intended: git diff, log, and show accept --output=, which writes a file. Remove Bash, Write, Edit, NotebookEdit, WebFetch, and WebSearch outright, scope the Read, Glob, and Grep rules to pr-head/ and review-context/ so reads outside the workspace need an approval a headless run never gives, and give the agent the PR's commit messages as review-context/commits.txt instead of git log. As a backstop, the post job redacts anything shaped like a Bedrock API key, GitHub token, AWS access key ID, or JWT from text it posts, including the fingerprint in the marker, and redacts before truncating. Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>
Author
|
Folded into #112, together with a fix found in testing: the agent now gets diffs numbered with each line's anchor, since without shell tools it often anchored comments a few lines low. |
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.
What was the problem/requirement? (What/Why)
The threat model treats the review agent as attacker-controlled (prompt injection from PR content), so its tools are meant to be read-only. They weren't quite:
git diff,git log, andgit showaccept--output=<file>, so the allowedBash(git -C pr-head …)tools could write files on the runner, outside the agent's process. The agent step's own environment scrubbing doesn't cover that.Separately, nothing stopped a credential-shaped string the model wrote from being posted to the public PR. GitHub masks secrets in logs, not in comments.
What was the solution? (How)
Bash,Write,Edit,NotebookEdit,WebFetch, andWebSearchoutright (--disallowedTools). The agent has no shell at all.Read/Glob/Greprules topr-head/andreview-context/. Reads outside the workspace (the environment,/proc,$GITHUB_ENV) need an approval a headless run never gives.review-context/commits.txt, replacinggit log.lineis the file's line number, not a position insidepr.diff. Without shell tools the model readpr.diffand used its line numbers, putting every comment 6 lines low.What is the impact of this change?
The agent can read the PR and the review context, and nothing else. Callers need no changes.
How was this change tested?
commit_log. Each failed before its fix. All 62 tests pass (python -m unittest discover -s test).Bash/Writeare not available at all, reads outside the cwd are refused, and reads underpr-head/andreview-context/work.Was this change documented?
Yes, in the workflow comment above the agent step and the
defangdocstring.Is this a breaking change?
No.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.