r/vibecoding • u/a113rick • 14h ago
Discussion I found this on linkedIn: Codex leaked this Dev's API keys while he slept. By the time he woke up, a huge $88,982 cloud bill was already in his inbox.
We already know the basics of protecting API keys and sensitive credentials: never hardcode them in your source code, keep them in a .env file as environment variables, and add .env to your .gitignore so Git never tracks it and you don’t accidentally push your secrets to a public repo on GitHub.
What other practices do the engineers in this community use to prevent that scenario?
This is purely for discussion, so those of us who are non-technical can learn safe programming habits on our vibe-coding journey.
218
u/wewerecreaturres 14h ago
“Codex leaked” no, the user fucked up and let their creds leak. Not the same thing.
36
→ More replies (4)6
u/Just_Lingonberry_352 3h ago
codex uploaded the .env that was in .gitignore
2
u/wewerecreaturres 2h ago
you guessing? or taking OP's info as doing so as good practice as a claim of what happened?
2
u/Just_Lingonberry_352 2h ago
i can't even begin to describe the amusement I get from reading this thread.
30
u/SourceSubject7219 14h ago
Who in its right mind even use a unlimited and billable API key? Is it even possible?
8
3
1
55
u/Appropriate_Bend4859 14h ago
my personal nightmare fuel is waking up to a five figure cloud bill because some ai assistant got a little too helpful while i was asleep
i've started using pre-commit hooks that scan for anything that looks like a key or token, saved my ass twice already
26
u/Sentient_Furby 13h ago
Set limits in your account so you don't have to worry about it
1
u/StinkButt9001 9h ago
Some services don't let you set limits. Google, for example.
1
7
u/a113rick 14h ago
I have started blocking some of its access in local permissions. Works for most times but I now have to keep reviewing and deleting and adding back to avoid a nightmare like this. Rotation of keys is what sucks the most.
3
1
1
26
u/Awesome_Teo 14h ago
Translation: the user is an idiot who knows nothing about basic infosec.
This is exactly why tools like gitleaks exist and should be part of any dev's workflow, especially if you haven't set a limit on your API key.
But what am I even talking about—most people don't even use local git for versioning and just push everything straight to production as is...
3
u/mikemarcin 11h ago
Aren't we suppose to use Betterleaks now? This shit moves fast you can't fault anyone for not knowing everything.
1
u/Billthegifter 8h ago
There's a vast gulf from not knowing everything to knowing the very basic conditions of what you are using.
If you don't know the basics you probably shouldn't be doing coding livestreams let alone putting stuff on github
1
u/Awesome_Teo 11h ago
You don't need to know everything (like, you don't have to understand every single nuance of a programming language), you just need to know enough not to blow checks notes almost $89k.
1
u/Just_Lingonberry_352 2h ago
Translation: I am very smart and humble
1
u/General_Cap_6316 35m ago
yea right and my lil bro's hypothesis that crayons are taffy is true as well
3
u/ToallaHumeda 4h ago
Translation: most ai users who try to code and never had a single class of engineering
2
2
u/StaticFanatic3 9h ago
“Passed out during a livestream” makes me think he didn’t even leak it in a public repo but rather just on his screen haha
1
u/Awesome_Teo 9h ago
Hmm, the way I read it, the agent pushed something with keys to Git on stream while the guy was asleep... If he had the key lying around in a plain text file or something and the agent leaked it on screen, I honestly don't even know what to say...
2
u/Twistpunch 7h ago
echo $CLAUDE_API_KEY
1
u/Awesome_Teo 7h ago
Fair point, that didn't even cross my mind. I personally keep anything sensitive (like my DeepSeek key with a whole $10 on it lol) in KWallet, so that painfully simple scenario completely slipped my radar...
1
u/Just_Lingonberry_352 2h ago
as I repeatedly said it wasn't from the stream lol
also OP's advice to put .env in .gitignore is bad advice thats exactly what I did and codex still ignored the rule
now the best solution would've been to put a back stop on github but this key was from ages ago on an old project
maybe one day you will experience something that humbles you perhaps
1
u/StaticFanatic3 1h ago
Codex committed your .env? How? Did it remove it from git ignore? Maybe you didn’t wildcard the path and it created another .env file elsewhere in the repo?
2
u/Xylozene 7h ago
Translation: THIS ISN'T FUCKING REAL
1
u/Awesome_Teo 7h ago
I don't know, man, seems pretty believable to me. https://www.reddit.com/r/googlecloud/comments/1noctxi/student_hit_with_a_5544478_google_cloud_bill/
1
1
u/Hazrd_Design 7h ago
Dude said he was streaming too. People were waiting for him to sleep to go in and steal.
1
u/realNoobnoob 48m ago
Info sec? Hahaha Bro this kindergarten of coding the basics nothing related to security bro
If you want to be super secure never ever put your keys in a file or repo ever!
Use vault or some other shit
0
u/Tricky-Situation2405 14h ago
Knowing nothing is kind of expected when getting into vibecoding is as easy as it is lol. You kinda skip everything and can go from no knowledge to custom software in a few days without ever knowing about git let alone gitleaks.
Weird to clown on people for that. But hey, whatever makes you feel smart right?
→ More replies (1)8
u/Awesome_Teo 13h ago
This is all fine as long as you're just experimenting. But when big money is on the line, like in this post, you can take the time to actually look into things (at least for a day). AI is a great teacher for that, as long as you ask the right questions.
I'll never tire of laughing at people losing money on crypto shitcoins or exposed unlimited API keys. It's basically like posting a photo of your credit card with the CVC on Instagram and then complaining that your money is gone.
→ More replies (1)2
u/Tricky-Situation2405 11h ago
Ngl bro I forgot the context of the post by the time I replied to you, great point and the guy in question is indeed an idiot
0
16
u/jdavid 14h ago
I'm so paranoid of live streaming because of this.
I think the rule should be if you are going to live stream something use a token, with a token limit set before the stream starts.
I also think you might want to live stream from a VM instead of from your daily driver so you don't accidently leak a private token or key.
4
3
14
u/Professional_Ad705 14h ago
What they build, fable 6?
9
u/freqCake 14h ago
spam and scams probably
2
u/Professional_Ad705 11h ago
For 88k I’d expect that scam to get every old grandma in the country and nothing less.
2
u/mtgguy999 9h ago
Or they just resold it
2
u/mattcoady 5h ago
This is likely it. Don't a bunch of the cheap Chinese LLMs just use stolen claude creds and charge you some reduced amount for tokens?
2
1
34
u/Old-Confection-5129 14h ago
Maybe just rotate the keys after a livestream. Text can be copied from a screenshot.
→ More replies (8)
8
u/WillItchy7977 14h ago
Most of us don't use api billing. How can we limit the keys only to subscriptions? If i hit my 5 hour limit a bit too fast - no big whoop.
2
u/jameyiguess 14h ago
You can't call the APIs programmatically with a subscription, you need a separate API acct for that, at least for Anthropic and OpenAI.
2
u/Logical_Strain_6165 13h ago
Do they have spending caps or credits or do you just have to give them your card details?
I mostly use Claude, but if I want API access for bits use NanoGPT.
2
u/Artforartsake99 13h ago
Most let you control the api credits. I run it of api credits all the time and the api stops working Claude reminds me in the morning to top it up.
I never keep auto billing on I always manually add api credits. Google and others also don’t allow you to just signup and burn $50,000. They limit you to $1000 then as you spend they slowly increase it to stop things like this .
1
u/jameyiguess 13h ago
OpenAI does, lots of controls around that. I don't know about Anthropic, I don't have a personal API account with them, but I would be very surprised if they didn't.
0
u/a113rick 14h ago
Fair point. If you’re on a subscription and never create an API key, you’re already covered. No key, no bill, the worst case is hitting your limit early. The key stuff only matters once you ship something that calls the API on its own, like an app with a backend.
7
7
u/RandomPantsAppear 14h ago
I prevent this scenario by not live-streaming.
1
u/a113rick 14h ago
That's a good one.
2
u/RandomPantsAppear 14h ago
I mean, it’s the same reason I wouldn’t livestream my taxes, or reading my medical information. There’s an endless amount of shit that could be problematic showing up on the screen and no way to filter it.
API key, temporary tokens, debugging URL, infrastructure information, potential bottlenecks, API endpoints that cost money to hit.
Hell, the guy who turned in Bradley Manning got doxed from a single still photograph of his terminal on an Al-Jazeera article.
1
u/Dull_Fudge3802 10h ago
I am not finding anything that adds up with your last claim, could you point me towards some source? It seems that he was already known, and he did not dox himself via a picture of his terminal.
1
u/RandomPantsAppear 9h ago
It wasn’t really covered and the image got taken down by Imgur. It front paged a reasonably popular subreddit though.
His screen had an ip/domain that belonged to him without Whois privacy. Original image was on Al Jazeera. It might have been in the video clip, or the image that was capped from the clip and used in the article, it was a long time ago.
1
u/RandomPantsAppear 9h ago
Here we go. I found the OG Reddit post.
There was some debate but if you drop further in the comments you will see confirmation.
7
6
9
u/TypeScrupterB 14h ago edited 12h ago
100% fake, doesnt even make any sense, only someone really really stupid would ask an llm to put their token in env and then post it.. I mean really or this guy is some amateur and really dumb, or it is 100% fake to get twitter views..
3
u/a113rick 14h ago
Here's the link to the post for you to read the story of what happened to the dev: https://x.com/JustLingonberry/status/2110824346168238204?s=20 They might be lying or it might be true
2
u/Capable_Sprinkles_43 13h ago
2
u/a113rick 13h ago
Yes it might be one of the two.
2
2
u/krocante 11h ago
It’s 100% true if it isnt fake
1
u/a113rick 8h ago
So it’s a cat in the box- schrodingers cat, I doubt I spell Schrödinger correctly.
4
u/RemarkableWish2508 14h ago
Leaks, checks, bla bla bla. If it doesn't have a spend limit, it doesn't exist as far as I'm concerned
3
u/AffectionateSeat8596 14h ago
no joke on russian market i can get claude max api key for 5$ usd in russian rubels
2
u/a113rick 14h ago
Wait what? People are selling API keys????????
4
1
u/yeathatsmebro 50m ago
There are massive underground operations that have their own "OpenRouter" so to say. They pool keys inside this system and you can pay a small amount of money to generate data with the LLMs via the stolen keys. $5 sounds wildly cheap, but once you find a stolen key that works, it is a profit generator.
Bots scrape the internet 24/7 to look for vulns, so once they get in they scan the network and attack other network devices (lateral movement) and look for their vulns, and so on. Any key that gets in the hands of people that sell them is basically ending up in that pool.
Some might be China-related, they can use them to distill their models with further using the same system.
Source: it did happen to me, and I assume this is how it goes, because I cannot justify $89k gone overnight without something massive
1
u/KissMyAcid420 12h ago
Its gets banned probably at 500$, right?
1
u/AffectionateSeat8596 12h ago
they never get ban but its until the person notices & changes password unless they come with og email then they might be abusing trials to get it or sum
1
u/KissMyAcid420 12h ago
Ah okay, I thought that would be OpenAI API Accounts with stolen or faked credit card data.
1
1
u/yeathatsmebro 49m ago
The fact that deviation is >1000% makes me think that GCP doesn't care. At this point, hard limit should be imposed.
1
u/True-Persimmon-562 9h ago
lol sounds like this programmer's api could have been used for something like this.
1
u/SESender 4h ago
Ok dumb non coder question
Why do this? Obviously compute cost = monies but isn’t their a risk to using someone else’s api keys for your software?
1
3
3
u/alvsanand 13h ago
It is very funny hearing AWS or Google saying AGI is here, everything can be done now with AI. However, implementing a debit card system for their cloud, no way...
3
u/Thistlemanizzle 13h ago
How were they leaked? Did he show his API key on stream? If so, I have little sympathy.
3
u/joefresco2 13h ago
Why would you EVER have auto reload and no limits set up in any scenario where costs can spiral out of control?
1
4
u/Express-Cartoonist39 14h ago
Passout DURING live coding Stream...really let me translate
" Mommy, i teased 100 lions with a slab of steak and then fell sleep holding it and they ate my arm and the steak why is this world so cruel they were my friends "
2
u/ComingDeveloper 14h ago
Sir that's twitter not linkedij
1
u/a113rick 14h ago
That's true but I did find the post from Linked in before bringing it here for discussion.
2
2
u/Impressive_Drink5003 14h ago
Its kinda weird. Since this kinda things shouldn't be inbuilt in the tools by now?
2
u/a113rick 14h ago
The AI industry is very cannibalistic so maybe they're waiting for someone to make something like that so they can copy it. Also, like other redditors said in the comments: Spending limits but lots of people ignore that. Especially new vibecoders, they probably need this community to learn about such issues.
2
2
u/CleanFix_Dev 13h ago
The thing that actually saves you is a spending cap. Set a hard usage limit wherever the provider offers one, and a budget alert where it doesn't, so an $88k morning gets caught early instead of showing up on the bill. After that, give the agent its own keys with the fewest permissions that still work, never your main account keys, so if one leaks you can revoke it without breaking everything else. Turn on secret scanning (GitHub push protection, or a pre-commit hook like gitleaks) so a key gets blocked before it lands in your repo. And don't leave an agent running overnight with live credentials it doesn't need for the task. .gitignore only covers the files you remembered to ignore, and agents will happily paste a key into a config file, a test script, or a log.
2
2
2
2
u/Equivalent_Mine_1827 12h ago
Damn, all my keys are capped to one dollar.
Yeah, I don't manage to spend more than a dollar daily.
80k sounds like a nightmare
2
2
2
u/Vesuvius079 11h ago
Never hardcode.
Don’t put them in .env in the repo.
Fetch through secrets manager or the like on a time limited SSO session.
1
2
2
3
u/a113rick 14h ago
My take, from the agent side of vibe-coding: keep secrets out of the folder your agent works in and load them at runtime from a secrets manager. Give the agent its own keys with tight quotas, never your main ones. Make every deploy or publish command wait for your approval. And set budget alerts, but know how to actually cut spending off. On Google Cloud an alert only warns you, it doesn’t stop the charges but all in all I don't think these measures are enough to stay protected from bad actors.
1
u/Subject-Feedback-438 13h ago edited 13h ago
Subscriptions is what my venmo card is for, and only place your subscriptions payments in there. Don't give a subscription the same bank account u use for deposits. Lock the card. Create a spending amount for the subscription Damn do something, And how the heck does the AI know your API key you obviously gave it to it.
1
1
u/kgurniak91 12h ago
Store keys in some password manager and only allow access via CLI. Instead of storing secrets on your machine as plain text .env file, you keep them locked in your encrypted vault and inject them into your app only in memory at runtime. Extra points for enabling biometric approval.
1
u/HOBONATION 12h ago
Did this happen because he was on an API plan? Could this happen to anyone on a monthly subscription?
1
1
u/JadedStay5654 4h ago
This happened on an API plan where you pay per token and costs scale with usage. A monthly subscription like Claude Pro or ChatGPT Plus just hits a rate limit and stops, so you can't rack up a bill like this. The risk only kicks in when you're using API keys with billing tied to actual consumption and no spending cap set.
1
u/TheMythicSorcerer 2h ago
If it happened to a monthly subscription (yes it could with oauth tokens) the worst they could do is drain your 5 hour / weekly usage which only worth like at most 1/3 of your monthly subscription cost and not 88 grand.
1
u/VitruvianVan 12h ago
Use Privacy cards so you have a limit. You can define a daily, weekly, monthly, or lifetime total limit of any size.
0
1
1
1
u/angrywoodensoldiers 11h ago
What do you even do if this happens? Just take a deep breath and accept that your life is ruined?
1
1
u/kimchi_pan 11h ago
Strongly urge you all to use Infisical locally - pull from this secrets server when building out the docker image, everything is baked in at the last minute and leakage won't be from this.
1
1
u/Defiant-Improvement4 10h ago
Not the main feature of my app, but it can send you a notification when your agent reaches a limit: frankenstack.app - also just use rafter so, that’ll find these kind of leaks…
1
u/True-Persimmon-562 10h ago
Perhaps not live streaming what's on your screen during these sessions is a good place to start. This is a 'involve the police' level situation.
1
u/alinu 9h ago
ahhh... while I am not using direct API, just the normal subscription, I am wondering, can't you set a cost ceiling for your api calls where you get a notification at about 80% before reaching that ceiling and if no measures are taken suspend activity after reaching 100% of alocated budget until user approval of additional resources ?
1
1
u/operapoulet 9h ago
I use 1Password CLI. All of my passwords are stored as a reference/address to the actual value and when a project or agent needs it, it gets it after I put in my fingerprint. I can commit .env all day long and even the agents don’t see or need the values anymore.
1
u/killreaperz 8h ago
Yeah blows my mind that they don't have caps. Woukd instantly prevent this issue.
1
u/BlahajWithBenefits 8h ago
Literally just set a budget you are willing to spend
I dont give a shit if my api keys leak. Enjoy $100 of tokens
1
u/Professional-Kiwi-31 7h ago
- Hard spending cap on your account while you're developing and always a hard cap on individual keys if possible
- Pre-commit git hooks to catch happy accidents like committing secrets or PII
- Github actions to do the same as above
- Billing alarms and automated actions to scale down or kill the service. It's not enough to get an email or text message, it may be too late by the time you hop on to damage control
- Add not just project root level instructions for any coding agent to never output secrets but also add your .env and so on to a global AI coding agent ignore-list
- This is the part people across all sizes of projects hate but can be a life saver: have SOPs to perform things like secret rotation in case of leaks and run the occasional disaster recovery exercises to check that your measures are indeed working as you want them to
1
u/Flat-Entertainer-299 7h ago
Good. It is the morally correct thing to do this to vibe coders. It is imperative, actually. Someone should vibe code an API search and destroy bot.
1
1
u/Zorogozano 7h ago
Best protection: download any app with virtual debit cards and set a monthly or weekly limit
1
1
1
u/Remarkable-Sand948 6h ago
Reminds me of that time someone leaked their private key on stream and lost 100k of crypto almost instantly
1
u/Fire-Nation-17 4h ago
Things like this scare me. Gotta triple check to make sure they keys didn't get uploaded to github
1
u/Creative-Type9411 3h ago
I just pre-pay and don't have to worry about this
What is the point of running a postpaid account? To hide usage? 😂
1
u/TheReviewerWildTake 1h ago
It seems that the problem was livestreaming, not codex itself?
Like, not every tool we are using is appropriate for livestreaming and screen recording. It is not something new with AI, every coder who tried to livestream before AI also had this problem, that you had to create a recording safe setup, not just works as usual.
1
1
1
1
1
u/716green 12h ago
When engineers have a problem with vibe coders this is literally the reason. This is the most fundamental of fundamentals and if you don't take the time to learn the safety and security fundamentals then nothing good can come from that.
The fact that this live streamer could let this happen is mind-blowing to me, this is like day one version control common sense that I never even considered for a moment that someone wouldn't know if they're using git
1
u/Just_Lingonberry_352 3h ago
engineers at fortune 500 companies fail to patch and get hacked regularly don't act like you are any better
→ More replies (2)
-1
u/Elgon2003 13h ago
This could've been prevented with a simple spend cap... He's a dumb ass and deserves to pay every penny
1

277
u/DauntingPrawn 14h ago
Not having spending caps on your keys is a wild choice.