fix(workflow): NO-JIRA restore id-token permission and fix concurrency race in claude-review#1143
Conversation
…y race in claude-review
|
aman-md I had to do some changes to the claude run because it was not working, can you review them please? |
Brad Paugh (braddialpad)
left a comment
There was a problem hiding this comment.
Fine by me, but we should probably wait for aman-md to confirm
…ude-review Replace raw Read, Glob, Grep tools with sandboxed wrappers that validate all file paths stay within the repository root. Blocks directory traversal attacks (e.g. /proc/self/environ) even if prompt injection succeeds.
|
aman-md Implemented the sandboxed tools you suggested. Here's what was added: New files — Each script:
Workflow changes:
This blocks the |
|
Francis Rupert (@francisrupert) this is a high security risk, and we should not rush into it. I'll reach out on Monday to see if Aman found another scenario we need to account for or if we are good as is. |
… Bash Add persist-credentials: false to checkout step to prevent token leakage via git config. Add --tools "Bash" before --allowed-tools to ensure only Bash tool is available, blocking built-in Read/Glob/Grep that bypass sandboxed safe-* scripts.
aman-md
left a comment
There was a problem hiding this comment.
Hey Belu, the changes look good to me.
|
belumontoya I think it will fix the checks if you merge in staging |
Summary
Fixes two bugs introduced by the SEC-2156 security hardening in #1138 that broke the Claude Code Review workflow.
Bug 1 —
id-token: writepermission removed (Critical)claude-code-action@v1uses GitHub's OIDC provider to authenticate. It exchanges a short-lived JWT (viaid-token: write) for API credentials. Without this permission, the action cannot start at all — it retries 3 times and crashes:This was the error on PR #1142's review run (run 23315006702).
Fix: Restore
id-token: write. This permission is scoped to the workflow run — it allows the action to request a token identifying itself to Anthropic's API. It does not grant write access to repo contents or PRs beyond whatpull-requests: writealready provides.Bug 2 — Concurrency group race condition (High)
The
labeledtrigger fires once per label added. All label events on the same PR shared the concurrency groupclaude-review-<pr_number>withcancel-in-progress: true. When multiple labels are added in quick succession (common workflow), the last label's run cancels all previous ones — including the legitimateclaude-reviewrun.Evidence from PR #1141:
Both runs show as "skipped" in the Actions UI, making this very hard to diagnose.
Fix: Include the label name in the concurrency group key (
claude-review-<pr>-<label>). Each label event now gets its own lane. Theclaude-reviewrun can only be cancelled by anotherclaude-reviewevent on the same PR (e.g., removing and re-adding the label), which is the desired behavior.What's NOT changed
All security hardening from #1138 is preserved:
labeledtrigger (requires maintainer to addclaude-reviewlabel)Read, Glob, Grep+gh pr diff/viewonly).claude/rules/)Known remaining issue (not addressed here)
workflow_dispatchcheckout falls back togithub.sha(default branch HEAD) instead of the target PR's code. This means manual re-triggers review the wrong code. Flagging for discussion — fixing this without re-introducing the prompt injection vector from #1138 needs a design decision.Test plan
claude-reviewlabel to a test PR → review should run successfully (no OIDC error)claude-review+ another label in quick succession → review should complete (not get cancelled)claude-reviewlabel → workflow should still skip (no change in behavior)workflow_dispatchstill works for manual triggers