Skip to content
← All guides

Is Claude Code safe? Security defaults, risks and setup

What Claude Code can do on your Mac by default, the protections Anthropic documents, the real risks, and a short checklist for a safer setup.

5 min read

Claude Code is reasonably safe to run when you use its permission system and review what it asks to do. It is not safe to run blind. It can read your files, edit them and run shell commands as your user, so the risk comes from what you approve, what it reads and how widely you grant access. Anthropic’s own security page says no system is completely immune to all attacks.

What it can do by default

Claude Code runs on your machine with your user account’s access. The security page says that in Manual mode it starts with read-only permissions. When it needs to edit files, run tests or execute commands, it asks first, and you choose once or always. A built-in set of read-only commands such as ls, cat and git status runs without asking.

The page also says Auto mode is the built-in starting mode for interactive terminal and VS Code sessions. In Auto mode a separate classifier model reviews actions instead of you and blocks the ones it judges unsafe. Your explicit ask and deny rules still apply. Check which mode you are in before you assume prompts will appear. Permissions guide

Two limits matter. The working directory boundary is a permission prompt, so a Bash command you approve can still write anywhere your user account can. And Accept Edits mode auto-approves file edits and a fixed set of filesystem commands like rm, mv and cp inside the working directory.

The documented protections

  • Permission rules. Allow, ask and deny rules decide which tools and commands run. Configure them with /permissions.
  • Sandboxed Bash. Turn on filesystem and network isolation for Bash commands with /sandbox. Sandbox guide
  • Network approval. In Manual mode, curl and wget prompt by default, and most tools that make network requests need approval.
  • Command injection detection. In Manual mode, Claude Code asks before running a Bash command it cannot fully analyze.
  • Trust prompts. Interactive sessions show a workspace trust dialog for a new folder, and servers in .mcp.json have their own approval prompt. A -p session shows neither.
  • Web fetch summaries. For most WebFetch fetches, a separate model call reads the page and Claude receives its answer instead of the raw page.
  • Credential storage. Keys and tokens go in the macOS Keychain when available.

The real risks

Prompt injection. Text in a web page, issue, file or tool result can try to steer the agent. The docs recommend reviewing suggested commands, avoiding piping untrusted content to Claude and using virtual machines for scripts and tool calls, especially around external web services.

Broad permissions. An allow rule like Bash(git *) or a bypass flag removes the check you were relying on. The docs say you are responsible for reviewing proposed code and commands before approval. The skip-permissions flag

Keys in logs. Transcripts under ~/.claude/projects/ are plaintext. If a tool reads a .env file or a command prints a credential, that value is written to disk. They are kept for 30 days by default. Where history and logs live

MCP servers. Anthropic says it does not security-audit or manage any MCP server. Project-scoped servers live in .mcp.json, but servers at other scopes, claude.ai connectors and plugins can add more, so reviewing .mcp.json alone does not show every server a session can load.

Data sent to the model provider. Claude Code sends all your prompts and model outputs over TLS 1.2 or later. Retention depends on your plan. The data usage page lists the consumer and commercial terms.

A short setup checklist

  1. Run /status and note the permission mode and settings sources.
  2. Add deny rules for credential files, for example Read(./.env).
  3. Turn on /sandbox for Bash.
  4. Review .mcp.json and installed plugins before trusting a folder.
  5. Keep allow rules narrow. Avoid broad Bash patterns and bypass flags.
  6. Set CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 and consider a shorter cleanupPeriodDays. Environment variables
  7. Protect shared branches on your Git host, since a push is accepted whoever sent it.
  8. Skim a recent session after anything consequential.

Report suspected vulnerabilities through Anthropic’s HackerOne program rather than publicly.

Checked against the vendor documentation on November 25, 2026. Security · Data usage · Claude directory · Settings

What Excellent adds

Excellent’s free scan reads supported logs on the Mac and reports findings for review. It reads the session logs of Claude Code, Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code. For a local report without installing an app, run the free scan. Its script uses Python 3.9 or later when your Mac has it and the shell when it doesn’t, reads the logs locally and makes no network requests. See a sample report.

Excellent Pro adds checks before supported actions. Claude Code can display an ask prompt. It blocks or asks before the risky actions it checks for, such as your email going to a website, keys typed into commands, deleting protected folders, reading key files and a push to main. Pro can also configure Claude Code’s native Mac sandbox from your file and folder rules, with a plan to review first. Pro is US-only for now. Agent coverage · Sandbox setup · Pricing

Related guides

View all