claude-code-security-review
claude-code-security-review is an official Anthropic GitHub Action that uses Claude Code to perform diff-aware, semantic security analysis of pull requests, flagging issues like injection, broken auth, hardcoded secrets, insecure crypto, and RCE via deserialization, then posting findings as PR review comments. It includes false-positive filtering tuned to exclude low-impact findings such as DoS, rate limiting, and open redirects, and ships a matching security-review slash command for local use inside Claude Code; the authors explicitly warn it is not hardened against prompt injection and should only run on trusted, reviewed PRs.
What it is
claude-code-security-review is a GitHub Action (used as anthropics/claude-code-security-review@main) that runs Claude against PR diffs for semantic security review. The summary covers what it detects; this documents how to wire it in and the concrete safety configuration the maintainers require.
How it works
The action checks out the PR head, analyzes only changed files (diff-aware), and posts findings as inline review comments with severity ratings and remediation guidance. False-positive filtering is a separate stage: findings_filter.py plus a dedicated claude_api_client.py re-check findings before posting. The filter is tunable per project, not fixed.
Preconditions / Affected
- Requires a
CLAUDE_API_KEYrepository secret. - Workflow needs
pull-requests: write(to comment) andcontents: read. - Not hardened against prompt injection — a malicious PR can manipulate the analysis. Only run on trusted PRs.
What to do
Add to .github/workflows/security.yml:
name: Security Review
permissions:
pull-requests: write # Needed for leaving PR comments
contents: read
on:
pull_request:
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 2
- uses: anthropics/claude-code-security-review@main
with:
comment-pr: true
claude-api-key: ${{ secrets.CLAUDE_API_KEY }}Because of the prompt-injection exposure, also enable the repo setting "Require approval for all external contributors" so the workflow only runs after a maintainer reviews the PR — this is the gate that makes the "trusted PRs only" constraint enforceable.
To customize false-positive filtering or scan instructions, copy security-review.md from the repo into your project's .claude/commands/ folder and edit it (e.g. add org-specific filtering directions); see the repo docs/ folder. Run /security-review inside Claude Code for the same analysis on pending local changes.
To validate a local checkout:
cd claude-code-security-review
pytest claudecode -vCaveats
- The maintainers state plainly it is not hardened against prompt injection; the external-contributor approval gate is a mitigation, not a fix.
- The filter deliberately drops DoS, rate-limiting, memory/CPU exhaustion, generic input validation "without proven impact," and open redirects — if those matter to you, retune the filter or they will be silently suppressed.
- Pinned to
@mainin the documented example, so behavior can change without a version bump.
Technologies named here
- Claude Code Security Review
- GitHub Actions
- Claude Code
- github_action_audit.py
- prompts.py
- findings_filter.py
- claude_api_client.py
- json_parser.py
- Pytest
- Claude
- Anthropic
- Python
Techniques named here
- SQL injection
- Command injection
- LDAP injection
- XPath injection
- NoSQL Injection
- XXE
- Broken authentication
- Privilege escalation
- Insecure direct object references
- Authorization bypass logic flaws
- Session flaws
- Hardcoded secrets
- Sensitive data logging
- Information disclosure
- PII handling violations
- Weak cryptographic algorithms
- Improper key management
- Insecure random number generation
- Missing input validation
- Improper sanitization
- Buffer overflows
- Race Conditions
- Time-of-check-time-of-use issues
- Insecure defaults
- Missing security headers
- Permissive CORS
- Vulnerable dependencies
- Typosquatting risks
- RCE via deserialization
- Pickle injection
- Eval injection
- Reflected XSS
- Stored XSS
- DOM-based XSS
- Prompt Injection
Related in AI Security
