Get the free coreGet core

Claude Code security: permissions, sandboxing and published advisories

Updated 6 min readSection 03 / Is it safe?
SHORT ANSWER

Claude Code security rests on four layers. Permission modes decide when it asks you. Rules let you allow or deny specific tools. An optional sandbox, a restricted area enforced by the operating system, limits shell commands. Hooks are your own scripts; one kind runs before a tool does and can block it. None of them is a complete wall: auto mode does not guarantee safety, the sandbox is off by default, and a Bash command you approve can still write anywhere your user account can.

risk-check · 2 stepsClaude CodeCursorCodexGemini CLI / Asks before each actionAuto-accepts editsSkips all permissions, on my main MacInside a sandbox, container or VM
1Which agent
2How it runs
LOWAsks before each action: You see each command before it runs. Read the prompt before you press y, and keep the project in git.
MEDIUMAuto-accepts edits: File edits go through without a question. Commit before you start so you can roll back, and keep secrets out of the project folder.
HIGHSkips all permissions, on my main Mac: Nothing asks you before a command runs. Run it only in a container or VM with no secrets, not on your main Mac.
LOWInside a sandbox, container or VM: Low if nothing secret is inside. Check that your keys, ~/.ssh and cloud credentials are not mounted into the container or VM.
Get the free coreQuiet until it matters. You decide.

01What Claude Code security consists of

Claude Code is a coding agent that runs on your machine and can read files and run shell commands. Its security is a set of controls around that power. Each row of the table links to a full page.

LayerWhat it doesWhere it stopsFull page
Permission modesDecide when Claude Code asks before actingAuto mode uses a second AI model to judge each action, and Anthropic says that does not guarantee safetyAuto mode
Permission rulesAllow, ask or deny specific tools and commands; deny is checked firstA deny rule does not match the same program called by its full path or inside sh -cPermissions
SandboxThe operating system limits what shell commands can touchCovers shell commands only; file tools, MCP servers and hooks run outside itSandbox
HooksScripts that run before a tool call and can block itA hook set on file edits does not stop Claude changing the same files through a shell commandHooks
ContainerCommands run inside a container, edits appear in your repoNo system is completely immune, even a dev containerDevcontainer

This page is about Claude Code security in the narrow sense: securing the tool itself. Studies of the code that AI tools write are in AI-generated code vulnerabilities.

02Which mode you are in right now

Since Claude Code v2.1.283, interactive terminal and VS Code sessions start in auto mode. Manual mode, whose config value is default, asks before Bash commands except read-only ones. It starts with read-only permissions and asks before edits, tests and commands.

To change the mode of a running session, press Shift+Tab in the terminal; VS Code has a mode indicator and the desktop app a mode selector. Administrators can turn auto mode off for an organization.

When you start Claude Code in a folder it has not seen, it shows a workspace trust dialog. If you start it in your home directory, trust is held for that session only, so start from a project subdirectory instead.

03Where the guards stop

Auto mode also allows some things by default: installing dependencies from lockfiles, pushing to any branch of the working repo, and reading .env and sending credentials to a matching API. The full list is on the auto mode page.

04Published advisories

Claude Code's GitHub repository carries security advisories, more than the six below. A CVE is a public ID number for a known vulnerability. Each row says in plain words what the advisory describes.

CVEWhat the advisory describes
CVE-2025-52882The editor extensions (VS Code, JetBrains) accepted connections over a websocket, a channel that stays open between a page and a program, from attacker-controlled webpages
CVE-2025-55284The list of commands Claude could run without asking was too broad, so a file could be read and its contents sent over the network without confirmation
CVE-2026-24887A command injection, meaning a program tricked into running a command it was not meant to run, went through find and bypassed the approval prompt
CVE-2026-33068Settings committed in a repository could set bypassPermissions, the mode that skips prompts, and the trust dialog was silently skipped
CVE-2026-54316A pre-approved huggingface.co host in WebFetch gave a hidden path for sending out data Claude could access
CVE-2026-55607A sandbox escape, meaning a command leaving its restricted area, through confusion between git worktrees (extra checkouts of one repo in other folders); it needed a cloned malicious repository with prompt injection

The advisories say users on Claude Code's standard auto-update received the fixes automatically. For the CVE-2026-33068 row, read the current docs too: a bypassPermissions value set in a project's .claude/settings.json or settings.local.json does not take effect today, and the session starts in Manual mode.

One incident sits outside the advisories. A public issue reported that rm -rf deleted all files in a user's home directory on WSL2 (Linux running inside Windows) on 21 October 2025. The reporter saw the command and interrupted it, but the files were already gone. Claude Code's undo, called checkpoints, does not track files that only Bash commands changed, so use Git for those.

05Does Claude collect your data?

Claude Code runs locally, but it sends all prompts and model outputs over the network. Session transcripts are stored locally in plaintext under ~/.claude/projects/ for 30 days by default. Transcripts you share through /feedback, /bug or /share are kept for 5 years.

Training depends on your plan. On commercial plans, Anthropic does not train on code or prompts sent to Claude Code unless the customer opted in. Consumers on Free, Pro, Max or Ultra choose whether data trains future models. If you do not allow training, retention stays at 30 days.

06The shortest safe setup

Claude Code security comes down to four steps you can take in a few minutes.

  1. Press Shift+Tab to switch to manual mode while you are still learning what Claude does.
  2. Add a deny rule for secret files, for example Read(./.env).
  3. Turn on the sandbox with /sandbox.
  4. Leave auto-update on: the advisories note that users on auto-update got the fixes automatically.

For a protection script that blocks edits to .env before they run, see hooks. The step-by-step version of this list is in how to run Claude Code safely. If you are thinking about turning prompts off, read what the flag does first.

07Other tools in this section

Claude Code is one of several agents. The same questions for the others are answered in Is Claude Code safe?, Is Cursor safe?, Is Codex safe?, Is Copilot safe? and Is Claude safe?. For Cursor's own record, see Cursor security. The risks all coding agents share are in AI agent security.

Claude Code security settings limit what the tool can do; they are not a record of what already ran on your Mac. To see what Claude Code actually ran on your Mac, Artificial Immunity's free, open-source core watches its sessions and every program start and reports what it finds.

FAQ

Is Claude safe and secure?

Claude Code ships with several guards: permission modes, rules, an optional sandbox and hooks. None of them is complete, and Anthropic's docs say so: auto mode does not guarantee safety, and the sandbox reduces risk but is not a complete isolation boundary.

Does the Claude code have security issues?

Yes, and they are public. The project's GitHub advisories list, for example, an overly broad list of pre-approved commands, a command injection through find and a sandbox escape that needed a malicious cloned repository. The advisories say users on auto-update received the fixes automatically.

Does Claude collect your data?

Claude Code runs locally but sends all prompts and model outputs over the network. On commercial plans Anthropic does not train on your code or prompts unless you opted in. Consumers on Free, Pro, Max or Ultra can choose whether data trains future models.

Can I trust Claude with my code?

Trust it with the work, not with unchecked access. Claude Code reads project files as needed, and in auto mode it can read .env and send credentials to a matching API. Add a deny rule for secret files such as Read(./.env).

How safe is it to use the Claude code?

Manual mode starts with read-only permissions and asks before edits, tests and commands. Skipping prompts with --dangerously-skip-permissions, which is the same as bypassPermissions mode, is meant only for isolated environments such as containers or VMs.

What is Claude security?

On this page it means the controls around Claude Code on your machine: modes, permission rules, the sandbox and hooks. Anthropic also uses the word for its own compliance credentials such as ISO 27001:2022 and SOC 2.

Sources

  1. Claude Code docs: security
  2. Claude Code docs: permission modes
  3. Claude Code docs: permissions
  4. Claude Code docs: sandboxing
  5. Claude Code docs: data usage
  6. Claude Code docs: MCP
  7. Claude Code security advisories (GitHub)
  8. Artificial Immunity
Running Claude Code on your Mac every day? Artificial Immunity watches the Mac where your agents work.Get the free core