Claude Code Security is an AI-powered capability by Anthropic designed to scan codebases, reason about context-dependent vulnerabilities, and suggest human-reviewed patches. Originally introduced in February 2026 as part of Claude Code on the web, it uses Claude's reasoning capabilities to analyze codebases, identify security weaknesses, and recommend targeted patches for developer review.
What Is Claude Code Security?
Unlike traditional static application security testing (SAST) tools, which primarily rely on predefined rules and vulnerability patterns, Claude Code Security examines application logic, traces data flows, and analyzes interactions between components. This approach helps uncover complex vulnerabilities, including broken access controls, authentication weaknesses, and business logic flaws that conventional scanners may overlook.
How it works:
- Permission-based architecture and approval modes: Controls which operations Claude Code can perform automatically and which require user approval. Supports configurable permission modes and allow, ask, and deny rules.
- Sandboxing, devcontainers, and network isolation: Restricts filesystem access, shell commands, and network connections. Devcontainers and virtual machines provide additional isolation for untrusted repositories.
- Prompt injection protections: Uses permission checks, workspace trust controls, and command analysis to reduce the risk of malicious instructions embedded in source code, documentation, or external content.
- MCP server permissions and trust: Requires trust approval for new project-scoped MCP servers and supports policies restricting tool usage and available integrations.
- Managed settings, enterprise policies, and OpenTelemetry monitoring: Enforces centrally managed security configurations and exports activity telemetry for auditing, investigation, and compliance monitoring.
Key tools and deployment options:
- Claude Security for enterprise teams (powered by Claude Mythos 5): Provides centralized, AI-driven vulnerability detection, risk assessment, and human-reviewed patch recommendations across enterprise repositories.
- Claude Security plugin for Claude Code: Enables developers to scan repositories or code changes, investigate vulnerabilities using multiple AI agents, and generate targeted patches directly within Claude Code.
- The /security-review command and GitHub Action: Reviews code changes for security weaknesses. The command runs locally in Claude Code, while the GitHub Action automates vulnerability analysis and reports findings on pull requests.
This is part of a series of articles about agentic AI security
In this article:
- How Claude Code Security Finds Vulnerabilities
- Claude Code Security Products and Deployment Options
- Types of Vulnerabilities Claude Code Security Detects
- How Claude Code’s Built-In Security Model Works
- Key Security Risks When Using Claude Code
- Limitations of Claude Code Security
- Tools That Complement Claude Code Security
- Best Practices for Claude Code Security
How Claude Code Security Finds Vulnerabilities
Reasoning-Based Analysis vs. Rule-Based SAST
Traditional SAST tools generally identify vulnerabilities by applying predefined detection rules, pattern matching, and program analysis techniques. These methods are effective for many known vulnerability classes, such as SQL injection, insecure cryptographic operations, and hardcoded credentials. However, they may struggle to recognize vulnerabilities that depend on complex application behavior or interactions across multiple components.
Claude Code Security takes a reasoning-based approach. It:
- Examines source code in context
- Follows data flows across files and functions
- Evaluates how application components interact
Instead of relying exclusively on known vulnerability signatures, it investigates whether combinations of otherwise legitimate operations could introduce exploitable security weaknesses.
For example, Claude may identify an authorization flaw involving several services where individual functions appear secure but their combined behavior allows unauthorized access. This makes reasoning-based scanning particularly useful as a complement to traditional SAST, rather than a replacement for established security testing methods.
Multi-Stage Verification and False Positive Filtering
Claude Code Security uses a multi-stage verification process to evaluate potential vulnerabilities before presenting them to security analysts. After identifying a suspicious code path, Claude re-examines the finding, challenges its initial assumptions, and attempts to establish whether the suspected weakness represents a genuine security issue.
This verification process helps distinguish exploitable vulnerabilities from benign coding patterns. Claude considers:
- The relevant execution context
- Attack prerequisites
- The potential security impact
It also assigns confidence assessments so analysts can understand the strength of the evidence supporting each reported issue. By filtering questionable findings before they reach developers, Claude Code Security aims to reduce false positives and unnecessary investigation.
However, automated verification does not guarantee that every finding is accurate. Security teams should still validate important findings against their deployment environment, application behavior, and threat model.
Severity Ratings, CWE Categories, and Human-Approved Patches
Claude Security organizes vulnerability findings using severity ratings and vulnerability categories, including Common Weakness Enumeration (CWE) identifiers when applicable. Its documented severity levels include Critical, High, Medium, and Low, with ratings based on exploitability, attack prerequisites, potential impact, and the application's threat model rather than vulnerability type alone.
Each finding provides contextual information to support investigation and remediation, including:
- Affected file locations
- Relevant code evidence
- An explanation of the vulnerability, potential attack paths, and guidance for fixing the issue
This helps teams prioritize remediation based on actual application risk rather than treating every detected weakness as equally urgent. Claude Security can also initiate targeted fixes through Claude Code, allowing developers to inspect and modify the affected code.
Patches remain subject to human review and approval, so teams retain control over whether proposed changes are applied. This human-supervised approach helps ensure that security improvements do not unintentionally introduce functional regressions or disrupt application behavior.
Claude Code Security Products and Deployment Options
Claude Security for Enterprise Teams (Powered by Claude Mythos 5)
Claude Security is Anthropic's commercial vulnerability detection and remediation product, designed to help enterprise security teams identify weaknesses across application repositories. It uses AI-driven analysis to investigate complex vulnerabilities, prioritize findings, and generate proposed patches for human review. Rather than examining only individual code changes, teams can use it to assess existing codebases and incorporate vulnerability detection into their software development workflows.
Claude Security initially launched in public beta for Claude Enterprise customers using models such as Claude Opus. As of September 2026, the product is powered by Claude Mythos 5.1, Anthropic's specialized model for advanced cybersecurity research. Mythos 5.1 builds on the earlier Mythos 5 model, with enhanced capabilities for identifying complex software vulnerabilities. Unlike direct access to Mythos through Anthropic's restricted verification programs, Claude Security provides these capabilities through a dedicated commercial security product.
This option is most appropriate for organizations looking to establish centralized vulnerability discovery and remediation processes across development teams. It allows security specialists to review findings and proposed fixes while maintaining human oversight of code changes.
Claude Security Plugin for Claude Code
The Claude Security plugin brings Anthropic's vulnerability scanning capabilities directly into a developer's Claude Code session. Unlike the hosted Claude Security product, the plugin operates within the existing Claude Code environment, using the developer's repository access and session permissions. It coordinates multiple AI agents to map the application architecture, develop a threat model, investigate potential vulnerabilities, and independently verify findings.
Developers can install the plugin from Anthropic's official marketplace using the command /plugin install claude-security@claude-plugins-official, then reload plugins and run /claude-security. The interface supports three main workflows:
- Scan codebase: Analyze an entire repository or selected components to identify vulnerabilities in existing application code.
- Scan changes: Review a branch, pull request diff, or individual commit to identify security issues introduced by recent modifications.
- Suggest patches: Generate targeted patch files for confirmed findings, allowing developers to review and apply the proposed fixes.
The plugin supports configurable scanning scope and effort levels, helping developers balance analysis depth against token consumption. Because scans run with the current Claude Code session's permissions and do not add their own isolation layer, Anthropic recommends using a sandboxed environment when examining untrusted repositories.
The /security-review Command and GitHub Action
Anthropic also provides a lightweight security review workflow through the /security-review command and the Claude Code Security Reviewer GitHub Action. These tools focus primarily on identifying vulnerabilities in code changes before they are merged, making them suitable for developer-level security checks and automated pull request reviews.
The /security-review command runs directly inside Claude Code and analyzes pending changes for potential security vulnerabilities. It uses context-aware analysis to identify weaknesses that may not be obvious from individual lines of code. Developers can also customize its instructions to reflect organization-specific security requirements and false positive filtering policies.
The Claude Code Security Reviewer GitHub Action integrates similar functionality into GitHub workflows. It can automatically inspect pull requests, analyze modified code, filter potential false positives, and post security findings as pull request comments. This enables teams to introduce AI-assisted vulnerability detection into their CI/CD pipelines without requiring developers to initiate every review manually. Unlike a comprehensive repository scan, pull request reviews focus on changed files, although the analysis may use surrounding code context to assess security risks.
Types of Vulnerabilities Claude Code Security Detects
Claude Code Security can identify a broad range of application security vulnerabilities, including common coding mistakes and complex weaknesses involving multiple components. Its reasoning-based analysis is particularly useful for identifying flaws that depend on application context, data flows, and interactions between functions rather than isolated vulnerable code patterns:
- Injection vulnerabilities: SQL injection and other weaknesses that allow untrusted inputs to influence database queries, commands, or application operations.
- Cross-Site Scripting (XSS): Improper handling of user-controlled content that allows attackers to execute malicious scripts in another user's browser.
- Authentication and authorization flaws: Weaknesses that allow users to bypass authentication, access restricted resources, or perform actions beyond their assigned permissions.
- Business logic vulnerabilities: Application workflow flaws that attackers can exploit to bypass intended restrictions, manipulate transactions, or access resources through unexpected sequences of legitimate operations.
- Server-Side Request Forgery (SSRF): Vulnerabilities that allow attackers to manipulate server-side requests and potentially reach internal services or restricted network resources.
- Insecure data handling: Insufficient input validation, unsafe deserialization, and insecure processing of sensitive information that may lead to unauthorized access or code execution.
- Hardcoded secrets and exposed credentials: API keys, passwords, tokens, and other sensitive values embedded in source code or insecurely exposed through application components.
- Path traversal vulnerabilities: Improper validation of file paths that allows attackers to read or manipulate files outside intended directories.
- Dependency vulnerabilities: Known security issues in third-party libraries and packages that may introduce exploitable weaknesses into an application.
Claude Code Security is particularly valuable when identifying multi-file and context-dependent vulnerabilities, such as authorization checks that are implemented correctly in one function but bypassed through another application path. However, its effectiveness depends on the available source code, repository context, and analysis depth. Anthropic recommends using its security capabilities alongside traditional SAST, dependency scanning, and manual code reviews rather than treating them as a complete replacement for existing application security tools.
How Claude Code’s Built-In Security Model Works
Permission-Based Architecture and Approval Modes
Claude Code uses a permission system that determines which operations its AI agent can perform autonomously and which require approval. In Manual mode, read-only operations within the approved working directory can run without additional prompts, while file modifications, most shell commands, and external network requests require authorization. Users can approve individual actions or establish reusable permission rules.
Claude Code supports several permission modes with different levels of autonomy:
- Manual/default: Requires approval for actions that are not already permitted, while allowing supported read-only operations.
- Plan: Allows Claude to explore a codebase and propose changes without modifying source files.
- Accept Edits: Automatically approves file modifications and certain filesystem operations within approved directories.
- Auto: Uses a separate classifier model to evaluate actions and block those considered unsafe, reducing the need for manual permission prompts.
- Don't Ask: Denies operations that are not explicitly permitted instead of prompting the user.
- Bypass Permissions: Removes routine approval prompts and is intended only for carefully controlled execution environments.
Administrators can also define allow, ask, and deny rules for specified tools and operations. These controls help organizations balance developer productivity with security requirements, although approval modes should not be treated as substitutes for operating-system isolation.
Sandboxing, Devcontainers, and Network Isolation
Claude Code supports sandboxing to restrict which files and network destinations its shell commands can access. Its built-in Bash sandbox enforces filesystem and network boundaries at the operating-system level, allowing approved commands to execute with fewer permission prompts. Teams can define writable directories and allowed network domains while restricting access to sensitive files and unauthorized external endpoints.
For stronger environment isolation, developers can run Claude Code inside development containers (devcontainers) or virtual machines. Devcontainers provide consistent, isolated development environments with configurable access to host resources, credentials, and networks. Anthropic provides a reference devcontainer configuration that supports network restrictions and controlled execution, making it suitable for teams that need reproducible security policies across developer workstations.
However, Claude Code's built-in shell sandbox does not cover every operation. File tools, MCP servers, and hooks can execute outside its boundary, while native Windows requires WSL2 for the supported sandbox implementation. Organizations handling untrusted repositories or sensitive code should consider isolating the entire Claude Code process and avoid exposing host credentials to its execution environment.
Prompt Injection Protections
Prompt injection occurs when attackers place malicious instructions inside content that an AI assistant processes, such as source code comments, repository documentation, web pages, or tool responses. In Claude Code, these instructions might attempt to redirect the agent away from its legitimate task, execute unauthorized commands, modify sensitive files, or disclose confidential information.
Claude Code reduces these risks through:
- Permission enforcement
- Workspace trust checks
- Command analysis
- Restrictions on network operations
In Manual mode, commands that download external content generally require approval unless explicitly permitted. Claude Code also uses additional processing for many web fetches, returning summarized content rather than exposing the agent directly to the full raw page.
These safeguards reduce the likelihood that malicious instructions will lead to harmful actions, but they cannot eliminate prompt injection entirely. Developers should treat external repositories, downloaded content, and third-party tool outputs as untrusted, review sensitive operations before approval, and use isolated execution environments when processing potentially malicious material.
MCP Server Permissions and Trust
Claude Code integrates with external applications and development tools through the Model Context Protocol (MCP). MCP servers can provide access to repositories, databases, cloud infrastructure, and other services, expanding what the AI agent can accomplish. However, these integrations also introduce security risks because connected servers may expose sensitive information or provide tools capable of modifying external systems.
Claude Code supports MCP configurations at local, project, and user scopes, with project-level server definitions commonly stored in .mcp.json. Interactive sessions require trust approval for new project-scoped servers, and administrators can configure permissions to control MCP tool usage. Organizations can also restrict which MCP servers are available through managed configurations.
Anthropic recommends connecting only to trusted MCP servers and applying appropriate access restrictions. Anthropic does not security-audit or manage every third-party MCP server, including those available through its connector ecosystem. Security teams should therefore review server implementations, requested permissions, credential scopes, and potential data exposure before approving integrations.
Managed Settings, Enterprise Policies, and OpenTelemetry Monitoring
Claude Code provides managed settings that allow enterprise administrators to enforce security policies across development teams. These policies can be distributed through centrally managed configuration files or supported server-managed settings. They take precedence over ordinary user and project configurations, allowing organizations to restrict tool permissions, disable permission-bypass modes, control integrations, and enforce approved development practices.
For visibility into agent activity, Claude Code supports OpenTelemetry-based monitoring:
- Organizations can export metrics and events to compatible monitoring and security platforms, including SIEM systems.
- Depending on configuration, telemetry can capture API usage, token consumption, tool execution decisions, permission mode changes, authentication activity, and MCP server connections.
- These records can help security teams investigate suspicious behavior, monitor policy compliance, and understand how AI agents are being used.
Enterprise teams can combine managed policies with centralized telemetry to establish governance over AI-assisted development. For example, administrators can block access to sensitive credential files, restrict unapproved MCP integrations, and monitor permission-related events. However, OpenTelemetry is a monitoring mechanism rather than a preventive security control, and organizations must configure appropriate telemetry collection, access controls, and data retention policies.
Key Security Risks When Using Claude Code
1. Standing Privileges Inherited from the Developer’s Session
Claude Code typically operates within the developer's existing environment, where it may have access to local files, environment variables, authenticated command-line tools, and credentials. For example, a developer signed into AWS through the AWS CLI may allow Claude Code to interact with cloud resources using that authenticated session, subject to Claude Code's tool permissions and sandbox restrictions.
This creates a standing privilege risk because Claude Code does not automatically receive a separate, narrowly scoped identity for every task. Even if an agent only needs to inspect application logs, the underlying developer credentials might permit modifying infrastructure, accessing production databases, or managing sensitive resources. The risk increases when developers use persistent credentials, broad IAM roles, or permissive approval settings.
2. Over-Permissive MCP Connections to Production Systems
Model Context Protocol (MCP) servers extend Claude Code's capabilities by connecting it to external services such as GitHub, cloud platforms, databases, and internal applications. These integrations can expose operations that go beyond reading information, including modifying records, executing queries, changing infrastructure configurations, and accessing sensitive business data.
An MCP connection configured with broad production privileges can create a significant security risk. For example, a database MCP server with unrestricted SQL execution capabilities could allow an agent to modify or delete production records while performing an otherwise legitimate development task. Claude Code's permission prompts do not replace the authorization controls enforced by the connected service.
3. Prompt Injection Leading to Risky Command Execution
Claude Code processes information from repositories, documentation, issue descriptions, web pages, and external tool responses. Attackers can exploit these inputs by embedding instructions that attempt to manipulate the agent's behavior. This is known as indirect prompt injection because malicious instructions arrive through content the agent encounters rather than through the legitimate user's request.
For example, an attacker could insert instructions into a repository README directing Claude Code to execute a shell command, modify security configuration files, or retrieve sensitive information. If the agent interprets this content as authoritative and has the necessary permissions, it may attempt actions unrelated to the developer's original objective.
4. Data Exfiltration and Secrets Exposure
Claude Code may encounter sensitive information while analyzing repositories, troubleshooting applications, or executing commands. This can include API keys, database credentials, customer records, internal documentation, and proprietary source code. The exposure risk depends on which resources the agent can access and where it can transmit information.
Data exfiltration can occur through several paths, including unauthorized network requests, compromised MCP servers, malicious scripts, and prompt injection attacks. For example, an agent with access to a credentials file and an external HTTP tool could potentially be manipulated into transmitting secrets to an attacker-controlled endpoint.
5. Malicious Dependencies and Supply Chain Risk
Claude Code interacts with development dependencies, package managers, build scripts, repository configurations, and third-party extensions. These components create supply chain risks because the agent may install or execute code obtained from sources outside the organization's control.
For example, an attacker could publish a malicious dependency using a name similar to a legitimate package. If Claude Code selects and installs that dependency, its installation scripts might execute harmful code or attempt to steal credentials. Untrusted MCP servers, plugins, and repository hooks can introduce similar risks by expanding the code and instructions the agent processes.
Limitations of Claude Code Security
While Anthropic provides several model-level protections and mitigation strategies like permission checks, these are not always sufficient for securing organizations against all AI-related threats.
Model Reasoning Is Not Policy Enforcement
Claude Code Security uses AI reasoning to identify vulnerabilities, evaluate potential attack paths, and suggest remediation steps. Although this can reveal complex weaknesses that traditional scanners overlook, model-generated security assessments are probabilistic and can contain false positives, false negatives, or incorrect assumptions about application behavior.
More importantly, a model's ability to recognize risky operations does not mean it can reliably prevent them. For example, Claude Code might identify an insecure cloud configuration in a repository, but that does not automatically prevent a separately running agent from making unauthorized infrastructure changes through an available tool.
Enforceable security boundaries require controls outside the model, including identity and access management, sandboxing, network restrictions, and authorization policies. Anthropic itself emphasizes that model-level defenses cannot provide complete protection without complementary environmental safeguards.
No Visibility into Agent Identities and Access Paths
Claude Code Security focuses on vulnerabilities in source code rather than providing a centralized inventory of every identity, credential, and access path available to AI coding agents across an enterprise. Its scanning results do not inherently reveal which developer sessions have production credentials, which MCP connections expose sensitive operations, or how permissions are delegated between agents and external systems.
This creates a governance gap for organizations deploying multiple coding agents across teams. Security administrators may need to determine which agents can access particular repositories, cloud accounts, databases, and production environments, especially when access is inherited from developer credentials or shared service accounts.
Claude Code provides permission settings and OpenTelemetry monitoring that can support operational visibility, but these are separate capabilities from vulnerability scanning. Organizations may need additional identity governance, privileged access management, and runtime monitoring controls to map agent access paths and detect excessive privileges.
Coverage Gaps Across the Software Development Lifecycle
Claude Code Security analyzes source code and recommends fixes, but secure software delivery involves additional stages and security controls. Vulnerabilities can emerge from infrastructure misconfigurations, compromised build pipelines, malicious dependencies, leaked credentials, insecure deployments, and runtime application behavior that is not fully represented in the scanned repository.
For example, an application may pass source code security reviews while remaining vulnerable because of an overly permissive cloud IAM role, an exposed Kubernetes service, or a production configuration that differs from the repository. Similarly, source code analysis cannot independently confirm that deployed applications behave securely under real-world traffic and attack conditions.
Anthropic recommends treating automated security reviews as a complement to existing security practices. Organizations should continue using software composition analysis (SCA), infrastructure as code scanning, dynamic application security testing (DAST), secrets scanning, CI/CD security controls, and runtime monitoring to cover risks beyond Claude Code Security's primary scope.
Tools That Complement Claude Code Security
Venice: Zero Standing Access for Claude Code Sessions and MCP Identities
Venice is a privileged access management (PAM) platform that helps organizations eliminate standing privileges across human, machine, and AI agent identities. Rather than allowing Claude Code sessions to inherit persistent developer permissions, Venice uses just-in-time (JIT) access to grant temporary, task-specific privileges. This reduces the potential impact of compromised agents, prompt injection attacks, and unintended actions involving sensitive systems.
Venice integrates with Anthropic's Claude Compliance API to discover Claude Enterprise identities, connect them to existing enterprise identities, and identify excessive permissions. Its Agentic Gateway provides a controlled access path to connected systems, applying policies based on the user, agent, and task. Privileges are granted when required and revoked when the task ends, while access requests and session activities can be recorded for auditing.
By combining identity discovery, least-privilege enforcement, and runtime authorization, Venice complements Claude Code Security's vulnerability scanning capabilities. It helps organizations control what AI agents can access and execute, rather than relying exclusively on the agents to recognize unsafe actions.
SAST and Software Composition Analysis (SCA) Scanners
Traditional static application security testing (SAST) and software composition analysis (SCA) tools provide additional coverage for vulnerabilities that Claude Code Security may miss. SAST scanners use static program analysis and predefined rules to detect coding weaknesses, while SCA tools inspect open-source dependencies for known vulnerabilities, license risks, and outdated packages.
These tools complement reasoning-based security analysis by providing repeatable checks throughout the CI/CD pipeline. For example, organizations can use SAST to enforce established secure coding rules, SCA to identify vulnerable library versions, and Claude Code Security to investigate more complex issues involving application logic or interactions between components.
Secrets Detection Tools
Secrets detection tools scan source code, repositories, commits, and development workflows for exposed credentials. They can identify API keys, access tokens, private keys, database passwords, and other sensitive information that attackers could exploit to access enterprise systems.
Unlike general-purpose code security scanners, dedicated secrets detection platforms can continuously monitor repositories, validate certain credential types, and integrate with remediation processes such as credential revocation and rotation. Using these tools alongside Claude Code Security helps organizations prevent sensitive credentials from entering codebases and identify existing exposures before they reach production.
AI Agent Runtime Monitoring and Audit Tools
AI agent runtime monitoring tools provide visibility into the actions coding agents perform while executing development tasks. They can track tool calls, command execution, MCP interactions, access requests, and connections to external systems. This helps security teams understand agent behavior beyond the vulnerabilities identified in application source code.
Some platforms also support real-time policy evaluation, anomaly detection, and automated intervention when agents attempt unauthorized operations. Others focus on logging, session reconstruction, and audit trails for incident investigations and compliance reporting. These capabilities complement Claude Code Security by helping organizations detect risky agent behavior during execution rather than relying exclusively on code analysis before deployment.
Best Practices for Claude Code Security
Here are some useful measures to consider when using Claude Code Security.
1. Grant Claude Sessions Just-in-Time, Task-Scoped Access
Claude Code can inherit broad permissions from developer accounts, increasing the impact of compromised sessions or unintended actions. Use just-in-time (JIT) access to grant only the permissions required for a specific task. Short-lived credentials and independent authorization controls help prevent agents from retaining unnecessary access to sensitive systems.
Key actions:
- Grant temporary, task-specific permissions instead of persistent administrative access.
- Use read-only access when the task does not require modifications.
- Issue short-lived credentials through privileged access management (PAM) or access brokers.
- Enforce authorization independently of Claude Code's permission settings.
- Automatically revoke access when the task or session ends.
2. Run Claude Code in Isolated Development Environments
Run Claude Code in controlled environments to limit its access to sensitive files, credentials, and production systems. Built-in sandboxing restricts shell commands, filesystem access, and network connections, but does not cover every tool or integration. Containers, virtual machines, and ephemeral environments provide additional isolation.
Key actions:
- Use devcontainers, virtual machines, or ephemeral development environments.
- Restrict filesystem access to approved directories.
- Allow network connections only to required destinations.
- Keep production credentials and sensitive host files outside the environment.
- Apply container-level or operating-system controls to cover tools outside the built-in sandbox.
3. Allowlist and Audit MCP Servers Regularly
MCP servers connect Claude Code to external systems and may expose sensitive data or privileged operations. Restrict connections to approved servers that have undergone security review. Regularly examine their permissions, authentication methods, and available tools to identify unnecessary access or changes that introduce security risks.
Key actions:
- Maintain an inventory and allowlist of approved MCP servers.
- Review server implementations and requested permissions before enabling connections.
- Use narrowly scoped credentials and prefer read-only access where possible.
- Log MCP tool usage and monitor changes to server configurations.
- Remove unused integrations and periodically reassess existing permissions.
4. Keep Credentials and Secrets Out of the Agent’s Context
Claude Code may encounter credentials stored in repositories, environment variables, configuration files, or command output. Exposing these values to the agent increases the risk of accidental disclosure or exfiltration through compromised tools and prompt injection. Use secrets management and access restrictions to minimize the sensitive information available during development sessions.
Key actions:
- Store credentials in dedicated secrets managers rather than repository files.
- Use workload identities and short-lived credentials where supported.
- Restrict access to sensitive directories, environment variables, and credential files.
- Avoid including production secrets in prompts, project instructions, or command output.
- Scan repositories for exposed secrets and rotate compromised credentials.
5. Require Human Review for Patches and High-Risk Commands
Claude Code Security can identify vulnerabilities and generate patches, but its recommendations may contain errors or introduce unintended changes. Require developers to review security fixes before applying them to critical codebases. High-risk commands should also remain subject to explicit approval, particularly when they affect production systems, access controls, or sensitive data.
Key actions:
- Review proposed patches for security correctness and functional impact.
- Require approval before modifying access policies or production infrastructure.
- Keep permission checks enabled for sensitive operations.
- Run automated tests and regression checks before merging security fixes.
- Independently validate significant vulnerability remediations.
6. Scan Only Changed Code in Pull Requests to Control Cost and Noise
Focus automated pull request security reviews on changed code while retaining enough surrounding context to identify related vulnerabilities. Diff-aware scanning reduces token consumption, review time, and duplicate findings compared with repeatedly scanning entire repositories. Supplement these checks with periodic full-codebase assessments to detect existing or newly relevant weaknesses.
Key actions:
- Configure pull request reviews to prioritize added and modified code.
- Include surrounding code context when evaluating potential vulnerabilities.
- Customize review instructions to emphasize high-confidence security findings.
- Run full-repository scans periodically and after significant architecture changes.
- Require maintainer approval before running security review workflows on external contributions.
- Monitor scanning costs, review duration, and false positive rates.
