Blog

Claude Code Security: Risks, Best Practices, and Enterprise Controls

Lumia Security Team
Lumia Security LabsLumia Security Team

November 18, 2026 | 10 min read

How to govern what developers share with Claude Code and what the agent can do

As development teams adopt Claude Code, security teams need to control what the AI coding assistant can access, what data developers can share with it, and what actions it can perform across codebases and development environments.

This article covers Claude Code security: securing Claude Code use inside an organization. It is not about Claude Security, Anthropic's separate security product for scanning code for vulnerabilities, which was called Claude Code Security during its research preview.

Claude Code does more than complete code. Inside a terminal or integrated development environment (IDE), it can inspect repositories, edit files, run commands, and call external tools across several steps. The same access that automates development work also raises the impact of unauthorized commands, compromised instructions, and accidental data exposure.

Native controls work best with enterprise policy and monitoring on top. The rule for this guide:

Securing Claude Code requires protecting both sides of the interaction: the information flowing into the AI and the actions the AI is allowed to take.

What is Claude Code security?

Claude Code security is the set of controls and practices used to protect source code, credentials, infrastructure, development systems, and enterprise data when developers use Claude Code. Data covers what enters the model; the other areas cover what the agent can reach and do, and who oversees it:

  • Data: which code, credentials, files, and customer information developers can give Claude Code.
  • Permissions: which files, directories, commands, APIs, and external tools Claude Code can reach.
  • Actions: what it can execute, modify, send, deploy, or delete.
  • Integrations: which Model Context Protocol (MCP) servers, APIs, databases, and outside services it can use.
  • Governance: whether security teams can see, audit, restrict, and enforce how Claude Code is used across the organization.

Claude Code security belongs inside the broader AI coding assistant security and agentic AI security strategy.

Why Claude Code requires a different security model

A chat assistant receives a prompt, generates an output, and returns it, while an agentic coding assistant can also read files and modify source code. It runs shell commands and tests, installs packages, and invokes tools across several steps.

Claude Code governs those actions through permission modes, allow-and-deny rules, and a sandbox that can restrict filesystem and network access. In auto mode, the default for interactive terminal and VS Code sessions, a separate classifier model reviews actions instead of the user and blocks those it judges unsafe.

Still, any system that executes actions must plan for malicious instructions, compromised content, excessive permissions, and tired reviewers.

The last one is measurable. Anthropic reports that users accept 93% of Claude Code permission prompts and calls the result approval fatigue: people stop paying close attention to what they approve.

6 key Claude Code security risks

Each risk below follows from the access Claude Code is given.

1. Excessive permissions and approval fatigue

Claude Code permissions decide which files, commands, tools, and network resources it can use. Broad permissions raise the cost of any mistake or compromised instruction, and frequent prompts can teach developers to approve by reflex.

The --dangerously-skip-permissions flag shows the stakes: it skips permission prompts except for a few actions no mode auto-approves, and Anthropic calls it unsafe in most situations. Managed settings can turn off bypass mode and auto mode, which developers cannot override.

2. Source code, secrets, and sensitive data exposure

Repositories and developer machines hold code, API keys, tokens, and configuration files. Claude Code can read them during a task, so controls have to cover accidental exposure as well as intentional sharing.

Claude Code data security also depends on the account type. Anthropic's data usage documentation says commercial accounts (Team and Enterprise plans, the API, third-party platforms, and Claude Gov) keep their existing policies. Consumer accounts on Free, Pro, Max, and Ultra plans are used for training when the user's setting allows it.

Local storage matters for Claude Code privacy too: session transcripts stay in plaintext under ~/.claude/projects/ for 30 days by default. Training terms do not stop an agent from reading a secret in a local .env file or sending it out.

3. Prompt injection can become an execution risk

For a coding agent, a malicious instruction can change actions, not only answers. Indirect injection hides in README files, documentation, GitHub issues, pull requests, and code comments. Websites, package documentation, and MCP tool responses can carry it too.

It may tell the agent to read credentials, exfiltrate files, run unexpected commands, or install malicious dependencies.

Anthropic's own test used a different entry point: the user. In a controlled February 2026 internal red-team exercise, a researcher phished an employee into launching Claude Code with a malicious prompt. The prompt asked it to read ~/.aws/credentials and send the contents to an external endpoint, and across 25 attempts Claude completed the exfiltration 24 times.

Anthropic's lesson for this Claude Code prompt injection case: when the instruction comes from the user, model-level defenses have little to catch, and the defense that holds is the environment: egress controls and filesystem boundaries.

4. MCP expands Claude Code's access to tools and data

MCP connects Claude Code to APIs, databases, developer tools, and internal services. Each connection adds a trust boundary. Risks include malicious servers, injected tool output, excessive permissions, credential exposure, tool poisoning, and unauthorized actions.

Anthropic encourages teams to write their own MCP servers or use trusted providers, and warns that servers fetching external content can expose users to prompt injection. A trusted server can still pass along adversarial content.

For Claude Code MCP security, a server that only needs to read issues and open pull requests should not run with repository administration rights.

5. Unsafe or unintended command execution

Claude Code runs commands to build, test, install dependencies, and execute scripts. A misread task or a malicious instruction can overwrite files, install unsafe packages, or send data out.

Lumia Security Labs' Project Pitfall research found that AI coding assistants, including Claude Code, launch helper executables such as gh, bun, and yarn by name.

The operating system resolves the name through the PATH search order. If the tool is missing, or an attacker can write to a folder searched before the real one, a file with the same name runs instead. Lumia Security Labs recommends a known-good set of executables and no execution from user-writable directories.

6. Enterprise visibility and governance gaps

Each developer can configure Claude Code safely and still leave the security team with an organizational problem. Claude Code enterprise security means answering a set of questions:

  • Who uses Claude Code, and from enterprise or personal accounts?
  • What sensitive information is being shared?
  • Which MCP integrations are connected, and with what permissions?
  • Which commands and actions are agents executing, and in which repositories and systems?
  • Are those actions compliant, and can you stop high-risk ones before they run?

Lumia's guide to AI governance for Claude traces how Claude Code carried data-security risk into environments holding source code, local files, credentials, and API keys.

What Claude Code's native security controls cover

Claude Code's native controls include:

  • Permission prompts, permission modes, and allow-and-deny rules for tools.
  • Filesystem and network sandboxing.
  • PreToolUse hooks that inspect a tool call with your own logic before it runs.
  • Managed settings deployed across the organization, including managed MCP configuration.
  • Corporate proxy support.
  • Usage and security-event monitoring through OpenTelemetry.

The monitoring guidance covers auditing security events and MCP activity and attributing actions to users. These controls answer one question: how should Claude Code itself be configured? Enterprise AI security also has to answer a second one: how do we enforce consistent policies across users, coding assistants, agents, tools, and enterprise systems?

Claude Code security best practices

To secure Claude Code, these practices limit damage even when model-level defenses fail.

1. Enforce least-privilege permissions

Give Claude Code only the permissions the current task needs. Restrict filesystem access and commands, configure permissions per project, and keep development and production privileges apart. Review them on a schedule. Blanket approval should never be the default operating model.

Note that this is not bulletproof - even tight rules leave a gap. Permission rules match a tool and a pattern, such as a command or a file path, and are evaluated as deny, ask, allow. They decide whether an operation is available, not whether this particular attempt fits the task, the data involved, or company policy.

2. Use sandboxing and network restrictions

Claude Code sandboxing is off by default. Once enabled, it limits writes and network access for shell commands, but sandboxed commands can still read most of the machine, including ~/.ssh and ~/.aws/credentials. Close that gap with sandbox.filesystem.denyRead rules or permissions.blockReadsOutsideWorkingDirectories, and allow only approved outbound domains.

Set allowUnsandboxedCommands to false so blocked commands cannot retry outside the sandbox. Built-in file tools, hooks, and local MCP servers run outside it, so deny sensitive paths in Read permission rules too.

Anthropic reports that in internal usage, sandboxing safely reduced permission prompts by 84%. A sandbox configured this way still holds after a malicious instruction has influenced the model.

Keep in mind that even when properly configured, the sandbox still has limitations. Its network proxy checks each host against the allowed domains, so an approved destination can still receive sensitive content. Sandboxed commands also inherit Claude Code’s environment variables, including any secrets stored there, unless those variables are scrubbed.

3. Define clear rules for sensitive data

Write down which data developers may give Claude Code: production and customer data, secrets, proprietary code, regulated data, and confidential documents. Enforce those rules with controls; training alone does not stop a paste.

It’s important to note that deny rules cover only part of the path. A rule such as Read(./.env) matches a file path, not the secret itself, so the same key pasted into a prompt or copied into another file can still reach the model.

4. Govern MCP servers and external tools

Keep an approved inventory of MCP integrations. For each one, review provider trust, authentication, credential handling, the data and actions it exposes, and how far you can trust its output. Grant each tool the least privilege it needs and revoke unused integrations.

An approved inventory still approves servers, not individual calls. Managed MCP configuration can fix which servers users connect to, but an allowed server can still receive sensitive arguments or return content that carries injected instructions. Furthermore, not all traffic is sent to MCP servers. Local client calls such as Bash will bypass the MCP servers. In fact, at customer deployments we uncovered that 82% of traffic bypasses MCP servers!

5. Treat prompt injection as an action-security problem

Filtering malicious text is not enough. Assume an injection will eventually influence the agent, then limit what it can do: sandboxing and egress controls set the outer boundary, while tool restrictions, action validation, and human approval for high-impact operations add checks inside it. The goal is a smaller blast radius when model-level defenses fail.

These layers reduce the impact without closing the entry point. Anthropic’s own analysis notes that when the user types the malicious instruction, a model-layer classifier sees nothing anomalous. What happens next depends on what the environment still allows.

6. Monitor and control high-risk agent actions

Separate routine work from consequential actions. Explaining a function or suggesting a unit test carries less operational risk, though untrusted material can still inject instructions. Higher-risk actions deserve stronger policy, approval, monitoring, and enforcement:

  • Modifying authentication logic or accessing production credentials.
  • Installing packages, pushing code, or changing infrastructure.
  • Running administrative commands.
  • Sending data externally or deleting files.

Monitoring and enforcement here depend on what each team builds. OpenTelemetry exports events for review, and tool content logging is disabled by default. PreToolUse hooks can block a call before it runs, but they are custom scripts that run with the user’s full permissions and cover Claude Code only.

There’s More: Enterprise Claude Code security requires runtime controls

The gaps above share a pattern. Most native controls decide by tool, file path, domain, or server: a rule makes an operation available, a proxy checks the destination host, and an allowlist names approved servers. The auto mode classifier and custom hooks do review individual actions, but only inside Claude Code.

Enterprise policy needs three more inputs. Content is what the prompt, file, or tool call carries. Context is who is asking, which repository and environment are involved, which tool and permissions the agent uses, and whether data leaves the organization. Intent is whether the action fits the task the developer asked for.

"Read this configuration file" may be harmless in one repository and unacceptable when the file holds production credentials. "Deploy this application" may be allowed in development and prohibited in production. Enterprise Claude Code security needs controls that evaluate both the intent and the impact of each agent action.

How Lumia secures Claude Code and AI coding agents

Claude Code shows why AI security is moving beyond prompt and response monitoring: security teams need to see what agents do, not only what users ask.

Lumia acts as the control layer between autonomy and execution. Deployed within existing network infrastructure or as a standalone proxy, it tracks agent actions such as modifying files, running commands, and invoking APIs, and it identifies which permissions agents use and which systems those actions affect.

Lumia evaluates actions that pass through it against context, intent, and policy before execution, and blocks unauthorized or high-risk ones before they reach systems or data. It helps prevent harmful behavior caused by prompt injection, model confusion, or external manipulation. Its log of attempted, executed, and prevented actions supports compliance.

Lumia also connects to Anthropic’s Claude Compliance API. For Claude Enterprise customers, this adds visibility into Claude Code activity after the fact, depending on deployment and API permissions. Real-time enforcement comes from the inline deployment.

Claude Code can make developers dramatically more capable. Enterprise security needs to ensure those expanded capabilities stay within defined boundaries. Claude Code security works best when native configuration and runtime enforcement operate together.

Give developers the freedom to use powerful coding agents without giving those agents unlimited freedom to act. See how Lumia provides visibility, runtime guardrails, and enterprise controls for AI agents.

Frequently Asked Questions

Claude Code Security: Risks, Best Practices, and Enterprise Controls

Lumia Security Team
Lumia Security LabsLumia Security Team

November 18, 2026 | 10 min read

Claude Code security is the set of controls and practices that protect source code, credentials, infrastructure, development systems, and enterprise data when developers use Claude Code. It covers what data enters the model, what the agent can access and do, which integrations it uses, and how security teams oversee it.

Claude Code includes native controls such as permission modes, allow and deny rules, sandboxing, hooks, and managed settings. These help, but they mostly decide by tool, file path, domain, or server. Enterprises should add organization-wide policy, monitoring, and runtime enforcement that can evaluate each agent action in context.

The main risks are excessive permissions and approval fatigue, exposure of source code, secrets, and sensitive data, prompt injection that leads to execution, MCP integrations that widen access, unsafe or unintended command execution, and limited enterprise visibility and governance. Each one follows from the access Claude Code is given inside developer environments.

Lumia sits between Claude Code and the systems it acts on. It runs inside existing network infrastructure or as a standalone proxy. Lumia tracks agent actions like modifying files, running commands, and invoking APIs. Before those actions run, it checks them against context, intent, and policy, and blocks unauthorized or high-risk ones. Lumia also keeps an audit log of attempted, executed, and prevented actions for compliance.

No. Claude Code security means securing how your organization uses Claude Code. Claude Security is Anthropic's separate product for scanning code for vulnerabilities, which was called Claude Code Security during its research preview.

Blocking AI apps is not an option anymore. Adopt AI. Safely. Reach out today to learn more.

We use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking "Accept", you consent to our use of cookies.