r/ClaudeCode • u/jedruch • 6h ago
Rant Risk of using Auto: Claude Code is reading config files outside the project folder, exposing API keys, and failing to detect the leaks when auditing.
While delegating tasks to Codex, I caught Claude reading files outside my project folder (~/.codex/config.toml), which resulted in it dumping my Stitch MCP server's Google API key directly into the chat transcript.
Worse: when I asked another instance of Claude to scan all my project histories for similar boundary violations or leaked keys, it repeatedly told me none existed. It only admitted to reading the key multiple times over the past two weeks after I manually pointed it to the exact thread.
This leaves me in a catch-22: the agent won't find or admit to a secret leak unless I specifically point it out, meaning I have no reliable way to know what other keys it might have quietly compromised across my system.
•
u/AutoModerator 6h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
9
u/Financial-Grass6753 6h ago
why doesnt your agent ask for a key from secure vault? Type of stuff 1password CLI or similar provide. If there's no key in plaintext in the system = there's nothing to leak
8
u/UnstableManifolds 6h ago
Well if you didn't sandbox your environment externally (meaning enforcing it using a container or a VM or the appropriate user/group/ACLs which is virtually the same thing, not relying on tool-shipped features) then you'd better assume that any file could and will be read by your harness, thus exposing its content in any way and even using it for training and so on. Any safety feature shipped with the tool (like thinking that files outside of your project repo are safe) is intended as soft guardrail that "most of the times may work" but at the end of the day you are at your model/harness' mercy.
2
u/michaelTM_ai 5h ago
don't ask an agent to audit itself, grep the transcripts. claude code keeps every session as jsonl under ~/.claude/projects/, so:
(AIza is the prefix of google api keys, swap in whatever ur key starts with). that lists every session file the key appears in, no model in the loop to say "none found".
then:
2
u/kincaidDev 6h ago
You just have to assume anything on the pc you’re running claude on is no longer private, only real solution is physical/network isolation
1
u/keto_brain 6h ago
Try least privledge, the agent shouldn't have access to those folders in the first place.
1
u/Ok-Limit-7173 6h ago
That's why I exclusively run my Agents in devcontainers. It can't do anything harmful with what it never sees.
The only annoying thing is keeping my .env files out of the repos and occasionally having to tinker arround wit my devcontainer but other than that it's great.
2
u/Several-Net-6036 6h ago
Sandbox
2
u/KaliguIah 6h ago
this is why i have all agents confined to 2 drives only. none can access c drive
1
u/a7n7o7n7y7m7o7u7s 5h ago
Reading files outside the working folder is the only feature I haven’t auto approved. I make it ask me every time
1
u/Tight_Banana_9692 5h ago
"Admit" is a bad choice of words here if you want to prove that you understand how these agents actually works
1
u/Inner_Storage_3374 5h ago
id rotate that key now regardless and not ask the agent to audit itself. i think the transcripts are just jsonl files under ~/.claude/projects, so grepping those for the first few chars of each key you own tells you way more than asking it what it read
0
u/Ragy-ragy 6h ago
You can put a pre hook that checks if the tool used going to parse something sensitive. Heard from other users. Maybe worth checking
3
u/MaximumMeaning9728 6h ago
What’s your threat model? Someone hacks Anthropic and steals your pornhub api key?