A software company says it found 1,122 public copies of Claude Code's local settings file on GitHub that contained secrets. Sam and Kabarza explain how choosing "Yes, and don't ask again" saves the command — API key and all — into .claude/settings.local.json, when that file misses the .gitignore, and what to do if you have already pushed a key.
00:00 1,122 public files with secrets
00:22 Why API keys stay off GitHub
00:57 What happens when keys get stolen
01:12 How "Yes, and don't ask again" leaks your keys
02:19 When the file isn't git-ignored
02:57 What Claude Code is meant to do
03:33 Best practice: keep keys out of Claude
03:46 Already pushed a key? Rotate it
04:21 Outro
Have you ever pushed an API key to GitHub by accident?
Taken from Cmd+ AI Ep 73, our weekly live show covering AI, design and dev. Catch us live every Friday and join in the banter.
#ClaudeCode #APIKeys #GitHub #Security #Anthropic
Transcript
Basically, this software company said itfound 1,122 public copies of this file thatcontained secrets. Command A I. Claude code has been secretly pushing your API keys up to GitHub for everyoneto see. So let's go through exactly why it's happening and what you can do aboutit to prevent it happening in future. For the normie, when youwhen you make an app, you probably need some API keys fromanother provider. And those API keys you want to store them in a file in anenvironment .env file, and you do not want to push that to GitHub. You haveyour files on your computer or on a server and you put everything on GitHubexcept some secretive stuff that you don't put on GitHub because if you putit on GitHub, other people can also read it.And if they read your API keys, they can use your credit. You don't want to dothat. We spoke last week about or the weekbefore about people open code getting hacked and all everyone's API keys totheir open AI accounts and their Gemini accounts and then everyone got thesebilling notifications because everyone was using that like they stole theiropen AI account. There's a little roundabout way where you canaccidentally end up pushing your API keys to GitHub. But what's happening isis that when you you might have used Claude and it might have like somethinghas blocked like the the the action that it's taking is blocked because it wantsyou to say yes, whether it's deleting a file, whether it's pushing to Git,whether it's doing something that the auto mode doesn't like, doesn't want todo, it needs your permission. There's three options. You can say yes, you cansay yes and don't ask again, and you can say no, you know? But what if when youclick say yes and don't ask again, it takes the the the prompt that you gaveit and puts that into a little file called claude/settings.local.json.And and that command that you gave it contained an API key, which by the waywe'll get into, but you shouldn't be putting your API keys into cloud anywayas as handy as it is, you should be not putting any API keys in cloud.This is one particular reason why. It will put that API key in this fileand if it's not get ignored, which is a way of ignoring certain files that havesensitive information and from getting pushed up to git,if it does if it's not get ignored, it'll then push it up there. So cloudcode is not abstracting or or um redacting the part the the API key orpassword before it puts it into settings.local. Basically, this softwarecompany said it found 1,122 public copies of this file thatcontained secrets. So they these are all public files with API keys. They didn'ttest the API keys, but that's a lot of repos that have APIkeys. What cloud code is meant to do is then add that file to the git ignore.But there are some instances where let's say you've already created that folderor you've already created that file, then it won't add it to the git ignore.If you've copied a .cloud folder over and it alreadyand you've not managed it through you've not managed that instance through cloud,then it's not going to add it to the git ignore.So there's a few little ways as to how that cloud file might not get put intothe git ignored and then you push it up to git and then it's for everyone tosee. It's an opportunity for us to talk about what good best practices are. Andultimately that comes down to not putting API keys into cloud.And it's not necessarily a cloud specific problem. If you have alreadypushed your API key to git, then you just need to rotate it. Like it's in thehistory of git. There's you you think if by just removing that file you that'severything's fine. If you push an API key, the the simple thing to do is justrotate that API key. I've done it. We've all done it. Git will I think it'scalled Git Guardian. Git will email you and say API keys detected and whateverand you need to deal with it like that. But you know, I've tried in the pastjust to kind of rewrite the history and do this and that and the other. Justfreaking just rotate the API keys. This is part of a larger conversation on myshow Command AI which we stream live every single Friday. We discuss the newsand all things related to AI and the world of design and dev. Catch us nextweek and join in the banter or click one of these videos which we think you'lllove. Command AI.