Integration: Claude Code
How do I secure Claude Code?
Updated
Short answer
Turn on Claude Code's sandbox, lock permission rules in managed settings, and check every action before it runs. Claude Code's permission rules match command text, and its sandbox is off by default and covers shell commands only. Harden AIF connects to Claude Code's PreToolUse hook and checks each tool call on the developer's machine before it executes, and blocks the dangerous ones.
What Claude Code can do on a developer's machine#
Claude Code runs as the developer. Whatever their account can do, the agent can do.
- Run shell commands:
git push, package installs,curl, database clients, cloud CLIs. - Read and edit files in the project, and anywhere a command can reach.
- Fetch web pages and call MCP server tools, whose output lands straight in its context.
- Touch credentials in
.envfiles, shell history and cloud config.
A poisoned README or issue can steer any of these. So can an honest mistake on a long task.
What Claude Code's own controls do, and what they miss#
- Permission rules allow, ask or deny tools and command patterns, and managed settings stop users overriding them. But the docs say a deny rule "isn't a security boundary around the program". The same action written another way gets past it.
- The sandbox limits what shell commands can read, write and reach on the network. Anthropic's docs say "The sandbox is off by default", and it covers shell commands only. File tools, MCP servers and hooks run outside it.
- Approval prompts put the decision on a developer who has clicked yes forty times today. (They will click yes again.)
- PreToolUse hooks run before every tool call and can deny it. That's the right place for a check. A hook is only as good as the code behind it, and the developer or the agent can edit the script unless you lock it down.
What Harden AIF checks before each Claude Code action#
AIF is a separate service on the developer's machine. Claude Code calls it through its PreToolUse hook before each action runs, so the check sits outside the agent and its context window. For each pending action, it:
- parses the command into a syntax tree and follows each value from its source to where it ends up, so a secret headed for a network call gets blocked however the command is written;
- judges secrets by their content, not their file name;
- checks destructive commands (recursive deletes, force-pushes to the default branch, piping
curlinto a shell, disk wipes) against where they actually run; - decodes base64 and hex before it decides, and sends dynamic code it can't resolve to a human;
- fails closed: if the check can't run, the action doesn't run.
When it blocks, the agent gets the reason and can retry a safe way. Every decision is recorded, and you can export the records to your SIEM.
Where Claude Code accepts a rewritten call, Harden can fix it instead of refusing: strip the secret, keep the work moving.
How to set up Harden for Claude Code#
These steps come from the Harden docs.
- Install AIF with
curl -fsSL https://aif.harden.run/install.sh | sh, then open a new shell. - Connect Claude Code with
aif configure --agent claude --validate. - Run
aif statusto check protection, the local model and activity history. - Run
aif demofor a safe demo, andaif showto open the local decision history.
For a fleet, follow the enterprise setup guide: create the organization, make an enrollment profile, push the package through your MDM and verify a pilot device. Start in shadow mode, so your team sees what agents do before anything gets blocked.
FAQ
Questions about Claude Code
Is Claude Code's sandbox enough on its own?
No. Anthropic's docs say the sandbox is off by default and covers shell commands only; Claude's file tools, MCP servers and hooks run outside it. Keep it on, and check every action at the hook as well.
Do Claude Code deny rules stop rm -rf?
They stop the command as Claude usually writes it. Anthropic's docs say a deny rule isn't a security boundary around the program, so the same delete written another way can get past it. A check that parses the command catches both.
Can Harden fix a Claude Code tool call instead of blocking it?
Yes, where Claude Code accepts a rewritten call. Harden can redact a secret from a command and let the safe version run, or block it and hand the agent the reason so it retries a safe way.