
How can you secure Claude Code against configuration exploits? Protecting Anthropic’s Claude Code, an AI coding assistant, includes keeping credentials out of local settings: researchers found 1,122 public copies of its local settings file containing secrets. Checking configured commands and permissions can help you spot unexpected activity, while audits can uncover exposure that needs closer review. Here is how to check what runs, keep passwords out of saved commands and limit spending on exposed keys, as Cole Medin walks through the configuration safeguards.
Claude Code: Protecting Configuration From Exploits
TL;DR Key Takeaways :
- According to Google Threat Intelligence, attackers modified organizations’ Claude Code settings so that starting the tool downloaded backdoor malware.
- Check startup warnings, use
/hooksand/mcp, and inspect skills for unexpected instructions or scripts. - Apiiro reported finding 1,122 public copies of
settings.local.jsoncontaining at least one secret. - Set spending limits on API keys because exposed keys led to cumulative resource abuse of up to $1 million in the most severe cases.
- The Agent Config Audit skill can run in under 10 minutes, but its Archon codebase run produced many false positives that require review.
Attackers modified organizations’ .claude/settings.json files so that starting Claude Code downloaded backdoor malware, according to Google Threat Intelligence. The same campaign used AI-generated recruiter identities, fraudulent recruiter profiles on professional networking platforms and fraudulent meeting sites as social-engineering lures.
Anthropic’s Claude Code can read codebases, edit files and run commands. Its configuration can also connect it to external tools and define hooks, which run commands in response to events. That access makes the configuration worth inspecting.
Check Hooks, Servers and Skills
Start a new Claude Code session and check its startup warning. Claude Code warns you when a hook configured in settings.json will run a command without asking. If you created the hook, or downloaded it and trust it, you can continue. If you did not expect it, inspect the configuration.
Inside a session, this command shows hooks and the events they are tied to:
/hooks
Use the next command to see connected MCP servers, which give Claude Code access to external tools and services:
/mcp
Claude Code can also show the skills in its environment, and nearly every AI coding assistant has a command for seeing what is turned on. Skills contain instructions and can include scripts, so they deserve the same attention as hooks and server connections. Nearly anything built into a coding assistant can have a vulnerability, and checking these additions occasionally can help you spot unexpected changes.
Advance your skills in Claude Code configuration and skills by reading more of our detailed content.
- Anthropic Adds Persistent JavaScript Mods to Claude Code
- 15 Claude Code Tricks For Persistent Context, Projects, Lower Costs and More
- Master Anthropic’s Claude Code : Tools, Hooks & User Commands in One Guide
- 12 Hidden Claude Settings Most Developers Are Completely Ignoring
- New Claude Code 2.0 Agentic AI Coding Agent : The Secret Weapon Every Dev Needs
Control Which Actions Claude Code Takes
Claude Code has permission rules for allowing or denying tools and actions. In manual permission mode, it ordinarily asks for approval before changing project files or running shell commands, although certain read-only commands are exceptions.
In auto mode, a classifier reviews tool actions and blocks those it identifies as irreversible, destructive or outside the configured environment. Anthropic says auto mode does not eliminate security risks, so you still need to check what is configured to run.
Review command requests before approving them, especially when they contain credentials. An allowed command can also leave a copy of a password in local configuration, as described below.
Keep Credentials Out of Chats and Settings
Credentials you type directly into a coding-agent conversation can persist in plain-text conversation history, usually in a local JSONL file. If someone compromises your machine, a credential in that history is another secret they could extract.
A password can also end up in Claude Code’s .claude/settings.local.json. If the agent uses a password as a command argument and you allow that action, the command can be added to an allow list, leaving the password in plain text in a file usually stored within the repository.
Claude Code creator Boris Cherny says settings.local.json should not be pushed to source control and should be included in the ignore file. Accidental publication still happens: security company Apiiro reported finding 1,122 public copies containing at least one secret when it scanned GitHub repositories.
Cole Medin recommends putting credentials in a .env file and asking the agent to use the environment variable without reading the file. A hook can prevent Claude Code from reading that file, reducing the chance that the agent puts its contents into the conversation.
Limit Spending on Exposed API Keys
An exposed language-model API key can be used for LLMjacking: attackers consume resources charged to the key’s owner. Cole Medin cites a Cursor access key shared with Fireworks that was exposed, as a sign that keys can leak even when users are careful. Fraudulent charges exceeded $100,000 in a single day in some cases, while the most severe cases reached $1 million in cumulative resource abuse before remediation.
Millions of automated agents and scans worldwide look for exposed keys, and attackers can use AI to scale scanning and exploits. They may use local, uncensored language models to scan for credentials and stolen API keys to fund further scanning and attacks. Amazon set up dummy cloud instances to monitor traffic and observed thousands of scanners probing for exposed ports and other entry points.
Apply a spending or usage limit to every API key, whether it supports development testing or a production system. Weekly limits can cap spending over a period, while a permanent limit can cap a key’s total use; one OpenRouter example limits a key to $50 of tokens overall. A limit will not prevent exposure, but it can restrict the spending available through the key.
Audit the Agent’s Configuration
A broader audit can check for problems beyond the hooks visible in a Claude Code session, helping you understand what might go wrong with an agent. The Agent Config Audit skill is intended to inspect startup configuration, poisoned dependencies, secrets in local settings and conversation history, fake editor extensions, LLMjacking risks and hidden instructions in global rules or CLAUDE.md, with the aim of providing a comprehensive check.
To use it, download the skill’s SKILL.md file, add it to a codebase and ask the coding agent to perform an audit, or invoke the skill directly with a slash command. The skill is designed to focus mainly on the agent’s configuration rather than necessarily examining the whole codebase. If no hook blocks reads of .env, the audit will probably propose one.
The skill can run on a repository in less than 10 minutes. On the Archon codebase, where most issues from an earlier audit had already been fixed, it flagged many false positives and searched far back through Git commit history for leaked secrets. Review findings before treating them as confirmed problems.
We would be careful about treating a one-off audit as a fix. Configuration changes over time, so a clean check today says little about next month, especially when hooks, server connections and skills can change what an agent does. We would also read any third-party audit skill before running it. Skills can contain scripts as well as instructions, and a tool intended to find security problems deserves that scrutiny too.
Protecting your repository also means checking the instructions and access behind your coding agent, not just the files it edits. An audit can help you find overlooked exposure, though the Archon run shows why its findings need review. If you use coding agents and want to check the configuration behind their actions, the Agent Config Audit skill is well worth trying.
Media Credit: Cole Medin
Disclosure: Some of our articles include affiliate links. If you buy something through one of these links, Geeky Gadgets may earn an affiliate commission. Learn about our Disclosure Policy.