AI development
Claude Code Security: Permissions, Review and CI
Claude Code security reviews and enterprise workflows guide. Learn security scanning, CI/CD integration, GitHub Actions, and enterprise deployment patterns.

Introduction
AI-assisted development moves fast. That speed is the whole point. But speed without security is a liability. Every line of code Claude Code generates, every dependency it installs, every API route it creates: all of it lives in your production environment. And your production environment faces real threats from real attackers.
This is Part 4 of the Claude Code Mastery Series, and it is entirely focused on security. We cover Anthropic's Claude Code security review capabilities, practical scanning workflows, CI/CD integration for automated checks, enterprise deployment patterns, and the permission model that lets you control exactly what Claude Code can and cannot do.
AI-assisted changes need the same threat model and review as other code. Tell the reviewer what data the application handles and where authorization is enforced. Generated code can contain plausible mistakes, so inspect the implementation and test the relevant boundary.
What You Will Learn
- Claude Code Security: Anthropic's vulnerability scanning announcement
- How to use Claude Code for security audits and vulnerability detection
- CI/CD integration with GitHub Actions for automated security checks
- Enterprise deployment patterns for teams and organizations
- Security best practices specific to AI-generated code
- The Claude Code permission model: allowlists, denylists, and hook-based security gates
Info: Anthropic announced Claude Code security review capabilities on February 20, 2026. Since then, automated security reviews have rolled out more broadly and are now available to Claude Code users on paid Claude plans and supported Console accounts.
Claude Code Security
On February 20, 2026, Anthropic announced Claude Code's security review capabilities for finding real, exploitable vulnerabilities in codebases. This was not a minor feature update. It represented a significant expansion of what AI can do for defensive security.
What Claude Code Security Does
During its testing phase, Claude Code Security analyzed production open-source codebases and discovered more than 500 previously unknown vulnerabilities. These were not trivial style issues or theoretical concerns. They were exploitable vulnerabilities, the kind that lead to data breaches, unauthorized access, and service compromise.
The system uses the same Claude reasoning stack that powers Claude Code for development, but applies it specifically to security analysis. It reads code with the mindset of an attacker, traces data flows through complex applications, and identifies vulnerability patterns that static analysis tools routinely miss.
Current Availability
Claude Code security reviews are now broadly available to:
- Individual paid users on Claude Pro or Max
- Teams and enterprises using Claude Code across shared workflows
- Developers using supported Console accounts with pay-as-you-go billing
Anthropic continues to refine the workflows, but the core security review capabilities are no longer limited to a narrow preview cohort.
Why This Matters
Traditional static analysis tools like Snyk, SonarQube, and CodeQL operate on pattern matching. They are good at finding known vulnerability signatures: SQL injection through string concatenation, missing CSRF tokens, hardcoded credentials. But they struggle with logic bugs, complex data flow vulnerabilities, and novel attack patterns.
Claude Code Security reasons about code the way a human security researcher would. It understands business logic. It can trace a user input from an HTTP request through middleware, across service boundaries, into a database query, and identify where sanitization is missing along the way. That kind of deep analysis used to require expensive manual penetration testing.
What It Finds
The types of vulnerabilities Claude Code Security identifies include:
- SQL injection — Including parameterized query bypasses and ORM misuse
- Cross-site scripting (XSS) — Stored, reflected, and DOM-based variants
- Authentication bypasses — Logic flaws in login flows, session management, and token validation
- Authorization failures — Broken access control where users can access resources they should not
- Server-side request forgery (SSRF) — Internal network access through manipulated URLs
- Insecure deserialization — Exploitable object reconstruction from untrusted data
- Path traversal — File system access outside intended directories
- Race conditions — Time-of-check to time-of-use vulnerabilities in concurrent code
Security Scanning Workflows
Even if you are not using the full automated review workflow in CI, you can use Claude Code itself for security auditing. The underlying Claude models have strong security reasoning capabilities. You just need to prompt them correctly.
Running a Security Audit
Start a Claude Code session in your project and give it a focused security mandate:
claude "Perform a security audit of this codebase. Focus on: (1) authentication and authorization logic, (2) input validation and sanitization, (3) SQL injection vectors including ORM misuse, (4) XSS vulnerabilities in rendered content, (5) CSRF protection, (6) sensitive data exposure in logs or error messages, (7) insecure direct object references, (8) hardcoded secrets or credentials. For each finding, rate severity as Critical, High, Medium, or Low. Provide the exact file, line, and a specific remediation."Claude Code will systematically walk through your codebase, reading files, tracing data flows, and reporting its findings. A typical audit on a medium-sized application takes ten to fifteen minutes and produces a structured report.
Targeted Scanning
For larger codebases, focus the scan on high-risk areas:
claude "Audit the authentication system in src/lib/auth/ and src/app/api/auth/. Check for: JWT token validation issues, session fixation, password reset flow vulnerabilities, brute force protection, and secure cookie configuration. Show me the exact code that is vulnerable and the fix."Dependency Auditing
Third-party dependencies are a common attack vector:
claude "Review our package.json dependencies for known security issues. Run npm audit and analyze the results. For each vulnerability found, explain the risk, whether it affects us based on how we use the package, and the recommended fix — whether that is updating, replacing, or adding a workaround."API Security Review
APIs are the most exposed attack surface for most applications:
claude "Review all API routes in src/app/api/. For each route, check: Is authentication required and enforced? Is input validated with Zod or similar? Are responses sanitized to prevent data leakage? Is rate limiting applied? Are error responses safe (no stack traces, no internal details)? List every route and its security status."Tip: Run security audits regularly, not just before deployment. In our experience at Luminous Digital Visions, and as covered in our hooks and MCP configuration guide, the best practice is to run a focused security scan after each significant feature is completed. Finding an SQL injection during development costs ten minutes to fix. Finding it in production costs days of incident response.
CI/CD Integration
Automated security checks in your CI/CD pipeline catch vulnerabilities before they reach production. Claude Code can be integrated into GitHub Actions workflows to review code on every pull request.
GitHub Actions Workflow for Claude Code Review
Here is a workflow that runs Claude Code on every pull request to check for security issues:
name: Claude Code Security Review
on:
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
security-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Claude Code
run: |
curl -fsSL https://claude.ai/install.sh | bash
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Get changed files
id: changed
run: |
FILES=$(git diff --name-only origin/main...HEAD -- '*.ts' '*.tsx' '*.js' '*.jsx')
echo "files=$FILES" >> $GITHUB_OUTPUT
- name: Run security review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
claude -p "Review the following changed files for security vulnerabilities. Focus on authentication, input validation, SQL injection, XSS, and sensitive data exposure. Output a structured report in Markdown format. Changed files: ${{ steps.changed.outputs.files }}" > review.md
- name: Post review comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const review = fs.readFileSync('review.md', 'utf8');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## Security Review\n\n${review}`
});Automated PR Quality Checks
Beyond security, you can use Claude Code in CI for general code quality:
- name: Run quality check
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
claude -p "Review the git diff for this PR. Check for: type safety issues, missing error handling, performance concerns, and test coverage gaps. Be specific about file names and line numbers." > quality.mdPre-Merge Security Gates
For critical repositories, make the security check a required status check. If Claude Code identifies any Critical or High severity issues, fail the workflow:
- name: Check for critical issues
run: |
if grep -qi "severity: critical\|severity: high" review.md; then
echo "Critical or high severity issues found. Blocking merge."
exit 1
fiWarning: CI/CD integration with Claude Code uses your Anthropic API key. Store it as a GitHub secret, never in the workflow file. Limit the key's permissions and monitor usage to prevent unexpected costs. Consider using a dedicated API key for CI that is separate from developer keys.
Set enterprise controls at the correct layer
Start with the organization’s approved identity, repository and data-access model. Decide which projects may use the tool, which services it can reach and what audit records are required. Keep production secrets out of general development sessions.
Use the current managed settings and permission documentation for enforceable controls. Project instructions describe a workflow; they do not establish an isolation boundary by themselves.
Review MCP servers, plugins and hooks as executable dependencies. Separate development and production credentials. Use organization-owned settings where the policy needs to apply across a team, and verify the effective settings on a test machine.
Log the information needed for incident investigation without collecting entire prompts, secrets or customer records by default. Define access and retention for logs before enabling broad collection.
Security Best Practices for AI-Generated Code
AI-generated code is not inherently less secure than human-written code. In many cases, it follows security best practices more consistently because the model has been trained on enormous volumes of secure code patterns. But there are specific risks to be aware of.
Always Review Authentication Logic
Authentication is the highest-risk area. Claude Code will generate JWT verification, password hashing, session management, and OAuth flows correctly in most cases. But "most cases" is not good enough for authentication. Review every line. Specifically check:
- Password hashing uses bcrypt, scrypt, or Argon2 (not MD5 or SHA-256 alone)
- JWT tokens are verified with the correct algorithm and secret
- Session tokens are regenerated after login to prevent fixation
- Password reset tokens expire and are single-use
- Rate limiting is applied to login endpoints
Validate All Inputs
Claude Code usually adds input validation when asked. But it might validate at the wrong layer, or miss an edge case. Check that:
- Validation happens at the API boundary, not deep inside business logic
- String lengths are bounded to prevent memory exhaustion
- Numeric inputs have reasonable min/max bounds
- File uploads are checked for type, size, and content (not just extension)
- Array inputs have length limits to prevent denial-of-service
Check for Sensitive Data Exposure
AI-generated error handlers sometimes leak too much information:
claude "Review all error handlers in the API routes. Ensure that no error response includes stack traces, database query details, internal file paths, or configuration values. In production mode, errors should return only a status code, error type, and a user-friendly message."Dependency Management
When Claude Code installs packages, verify them:
- Check the package name for typosquatting (e.g.,
lodashvsl0dash) - Verify the package has a meaningful number of downloads and recent maintenance
- Run
npm auditafter installation - Pin dependency versions in production to prevent supply chain attacks
Environment Variable Hygiene
Never let Claude Code hardcode secrets. If you see a secret in generated code, fix it immediately. Use a PreToolUse hook to catch this automatically:
#!/bin/bash
# block-hardcoded-secrets.sh
INPUT=$(cat)
CONTENT=$(echo "$INPUT" | jq -r '.tool_input.new_string // .tool_input.content // empty')
if echo "$CONTENT" | grep -qEi '(api[_-]?key|secret|password|token)\s*[:=]\s*["\x27][A-Za-z0-9+/=]{20,}'; then
echo "BLOCKED: Possible hardcoded secret detected in file content" >&2
exit 2
fi
exit 0
Claude Code Permission Model
Claude Code includes a permission system that controls which tools it can use. This is your first line of defense against unintended actions.
Tool Allowlists and Denylists
In your settings.json, you can explicitly allow or deny specific tools:
{
"allowedTools": [
"Read",
"Write",
"Edit",
"Glob",
"Grep",
"Bash(npm test)",
"Bash(npm run build)",
"Bash(npx prisma *)"
]
}This configuration lets Claude Code read and write files, search the codebase, and run specific commands, but nothing else. It cannot run arbitrary bash commands, which prevents accidental rm -rf situations.
Hook-Based Security Gates
Hooks provide granular control that goes beyond simple allow/deny lists. You can write hooks that inspect the specific content of a tool invocation:
- Block writes to specific directories (e.g.,
prisma/migrations/) - Prevent modifications to configuration files without explicit approval
- Require tests to pass before allowing new file creation
- Log all database-related commands for audit purposes
Audit Logging
For enterprise environments, thorough audit logging is essential. A PostToolUse hook can log every action Claude Code takes:
#!/bin/bash
# audit-log.sh
INPUT=$(cat)
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
USER=$(whoami)
TOOL=$(echo "$INPUT" | jq -r '.tool_name')
PROJECT=$(basename "$(pwd)")
echo "{\"timestamp\":\"$TIMESTAMP\",\"user\":\"$USER\",\"project\":\"$PROJECT\",\"tool\":\"$TOOL\",\"input\":$(echo "$INPUT" | jq -c '.tool_input')}" >> /var/log/claude-code/audit.jsonl
exit 0This creates a structured audit trail that compliance teams can query and review.
Layered Security Model
As we covered in our full-stack development guide, production readiness requires multiple checks. The most robust setup combines multiple layers:
- CLAUDE.md rules — Tell Claude Code what it should not do (soft constraint)
- Tool allowlists — Restrict which tools are available (hard constraint)
- PreToolUse hooks — Inspect and block specific tool invocations (programmable constraint)
- PostToolUse hooks — Audit and validate after execution (monitoring layer)
- CI/CD checks — Catch anything that slips through during development (final gate)
Warning: No single layer is sufficient on its own. CLAUDE.md can be ignored under certain prompting conditions. Tool allowlists are coarse-grained. Hooks can crash. CI/CD only catches issues after code is written. Use all five layers together for defense in depth.
Build a security review record
Record the change, reviewers, checks performed and unresolved findings. An assistant’s analysis can identify issues for investigation; it is not a compliance certification or a complete security audit.
For sensitive changes, use independent review and tests that exercise the trust boundary. Confirm authorization on the server, validate inputs, test error handling and inspect what appears in logs. Maintain a rollback path for the release.
Frequently Asked Questions
Yes. Claude Code security reviews are available to supported paid Claude users and compatible Console accounts. Team and Enterprise customers can also roll them out across shared workflows. Check Anthropic's documentation for the latest plan details and rollout notes.
Claude Code Security found over 500 previously unknown vulnerabilities in production open-source code during testing. These were real vulnerabilities that had not been publicly disclosed. The model reasons about code semantics rather than matching known patterns, which allows it to find novel vulnerability types that signature-based scanners miss.
Traditional Static Application Security Testing tools like SonarQube and CodeQL use pattern matching and data flow analysis with predefined rules. They are fast and reliable for known patterns. Claude Code Security uses AI reasoning to understand business logic and trace complex data flows across service boundaries. It finds vulnerability types that SAST tools typically miss, but may run slower and cost more per scan. The best approach uses both.
No. AI-powered security scanning is a powerful addition to your security program, not a replacement for it. Continue using SAST tools, dependency scanning, and manual penetration testing. Claude Code Security adds a reasoning layer that complements these existing tools.
Store the API key as a GitHub secret (or equivalent in your CI platform). Never put it in workflow files, environment files committed to git, or build scripts. Use a dedicated API key for CI with limited permissions. Rotate it regularly and monitor usage through Anthropic's dashboard.
Only if you configure it to. Claude Code does not have inherent access to any external systems. MCP servers and environment variables must be explicitly configured. For security scanning, use read-only database credentials or point Claude Code at a staging environment, never production.
Use a PreToolUse hook that scans for patterns that look like hardcoded secrets (API keys, passwords, tokens) and blocks the file write. Combine this with git pre-commit hooks that scan for secrets using tools like git-secrets or detect-secrets. And add secret scanning to your CI/CD pipeline as a final check.
Create a shared hook repository that all projects reference. Define mandatory hooks at the organization level (in user settings distributed through your configuration management system) and allow project-specific hooks for additional checks. Document the policies in a central location and include them in developer onboarding.
This is an evolving area. The responsibility for code quality and security rests with the development team, regardless of whether code was written by a human or an AI tool. Treat AI-generated code with the same review rigor as code from a new team member. Trust but verify.
Run targeted audits after completing each significant feature, especially features involving authentication, payment processing, or user data handling. Run a full codebase audit before major releases. Integrate automated security checks into your CI/CD pipeline so that every pull request gets basic security screening.
An AI assistant can help organize control documentation and flag code for review. That is not an independent assurance report. Define the applicable control criteria and evidence with your responsible security and audit professionals, and verify every generated statement.
Code processed by Claude Code is sent to Anthropic's API. Review Anthropic's data processing agreement and terms of service to confirm they satisfy your GDPR obligations as a data controller. In most cases, source code does not contain personal data — it contains logic and structure. If your codebase includes hardcoded personal data (test fixtures with real email addresses, for example), clean those out before using Claude Code. For enterprise environments, Anthropic's Enterprise plan offers data processing terms suitable for GDPR compliance.
False positives are inherent in any security scanning tool, including AI-powered ones. When Claude Code flags something that is not actually a vulnerability, note the pattern and add it to your CLAUDE.md under a "Known safe patterns" section so Claude Code does not flag it again. For CI/CD integration, maintain an allowlist of accepted risks with justification comments. Over time, refining your security audit prompt with specific exclusions reduces noise without missing real issues.
A Claude Code security review on a typical pull request (10-50 changed files) takes two to five minutes and costs the equivalent of one API call. For full codebase scans, expect ten to twenty minutes depending on codebase size. The API cost is proportional to the amount of code analyzed. To optimize, scan only changed files in PR checks and reserve full codebase scans for nightly or pre-release runs.
Claude Code can generate the infrastructure for secret rotation (scripts that update environment variables, rotate database credentials, and cycle API keys) but it does not manage secrets directly. Pair it with a secrets manager like HashiCorp Vault, AWS Secrets Manager, or 1Password. Ask Claude Code to create rotation scripts and integrate them with your secrets management platform. Always test rotation in staging before applying to production.
When you ask Claude Code to rate severity, it follows standard classification frameworks. Critical means immediate exploitability with high impact (RCE, auth bypass, data exfiltration). High means exploitable with moderate difficulty or significant impact. Medium means requires specific conditions or has limited impact. Low means theoretical risk or minimal impact. You can calibrate this by specifying your threat model in the prompt — "This API handles financial transactions" shifts the severity assessment toward stricter ratings.
Each scan consumes API tokens proportional to the code reviewed. For a team running 20 PRs per day with focused diff-only scans, expect API costs of roughly the same as having one additional developer conversation per PR. Full codebase scans cost more. To control costs, scan only changed files in PR pipelines, run full scans on a schedule (nightly or weekly), and use a faster lower-cost model for routine checks where the deepest reasoning is not necessary.
Yes, with the right prompting. Ask Claude Code to generate a structured security assessment document covering specific compliance frameworks. For example: "Generate a security controls assessment report for our application covering the OWASP Top 10 categories. For each category, describe our current controls, identify gaps, and rate our posture as Compliant, Partially Compliant, or Non-Compliant." The output is a working document for compliance teams, not a certified audit.
Claude Code requires API connectivity to Anthropic's servers for the AI model inference. There is currently no on-premise or air-gapped deployment option for the model itself. The Claude Code CLI runs locally on your machine, so your code is only sent to Anthropic's API during active sessions. For environments with strict network isolation requirements, Claude Code is not currently suitable. Contact Anthropic's enterprise sales team for information about dedicated infrastructure options.
Anthropic processes API requests through their infrastructure. Specific data residency guarantees depend on your Anthropic plan tier. Enterprise customers should discuss data residency requirements directly with Anthropic's sales team. If your regulatory framework requires data to remain within a specific geographic region, confirm that Anthropic's infrastructure meets that requirement before deploying Claude Code in your workflow.
Set audit-log retention from the organization’s actual obligations and investigation needs. Review the current provider data-handling settings and the records created by your own tools. Protect logs from unauthorized access and avoid storing secrets or unnecessary source content.
You can ask Claude Code to generate security policy templates tailored to your stack and compliance requirements. Prompt it with your technology stack and regulatory framework: "Generate a security policy template for a Node.js and PostgreSQL application that needs to meet SOC 2 Type II requirements. Include sections on access control, data encryption, logging, incident response, and change management." The result is a solid starting point that your security team can review and adapt.
Claude Code does not directly integrate with penetration testing tools like Burp Suite or OWASP ZAP. However, you can use Claude Code to prepare for pen testing — it can generate test cases, identify likely attack vectors, and review pen test results. Feed the output from a pen test tool into Claude Code: "Here are the results from our OWASP ZAP scan. Analyze each finding, confirm whether it is a true positive or false positive based on our codebase, and provide specific remediation for each confirmed vulnerability."
Use the current OWASP Top 10 as a reference for common application risks, alongside a threat model specific to your system. Code review cannot assess every infrastructure setting or prove that no vulnerability remains.
Continue the Series
Security is not a checkbox you mark once. It is a continuous practice that evolves with your codebase, your team, and the threat environment. The tools and patterns in this article give you a strong foundation, but they work best when applied consistently and reviewed regularly.
What We Covered
- Claude Code Security — Anthropic's dedicated vulnerability scanning tool, announced February 20, 2026
- Security scanning workflows — Practical prompts for auditing authentication, APIs, dependencies, and data handling
- CI/CD integration — GitHub Actions workflows for automated security reviews on every pull request
- Enterprise patterns — Shared configurations, API key management, onboarding, and compliance
- Security best practices — Specific guidance for reviewing AI-generated code
- Permission model — Allowlists, denylists, hooks, and layered security architecture
Up Next: Part 5
The final installment of the Claude Code Mastery Series covers the most advanced features: Agent Teams for coordinated multi-agent development, git worktrees for parallel development, background tasks, and real-world workflows that combine everything in the series. This is where it all comes together.
Continue to Part 5: Agent Teams and Parallel Development
Need Expert Help?
Security auditing and enterprise Claude Code deployment are areas where professional guidance pays for itself quickly. A misconfigured security setup costs far more to fix after an incident than to set up correctly from the start. Luminous Digital Visions provides security consulting and enterprise AI integration services.
For implementation, explore Luminous services or discuss your project.