Protect your Anthropic API key from theft
Stolen Anthropic API key burned an indie app's credits · Security incident · X · @ThePurePath · Oct 12, 2026
What happened
The builder behind PurePath says someone got hold of their Anthropic API key and ran up roughly $500 of model usage. A follow-up post says support called the credits non-refundable.
How to prevent it
Keep provider keys server-side only, set a hard monthly spend cap and rotate any key that may have been exposed. See our API key guide.
Fix prompt for your own AI tool
Copy this into your own AI tool (Cursor, Lovable, Claude Code, Bolt…). It's general guidance written by us. Review what the AI suggests before applying it.
I'm a beginner and want to make sure my API keys are safe in my Anthropic API project. 1) Search the code for hardcoded keys or tokens and for secrets in variables that ship to the browser (NEXT_PUBLIC_, VITE_, REACT_APP_). List the file and line, but don't print the values. 2) For each one, tell me whether it's meant to be public (like a Supabase anon key) or secret. 3) For secret ones, show me how to move them to server-side env vars and call the provider through a server route. 4) Give me the steps to rotate each exposed key in the provider's dashboard and set a spending limit. 5) Make sure .env is in .gitignore and in my AI tool's ignore file. Don't change anything until I've approved your plan. Never ask me to paste API keys, passwords or .env contents; tell me where to check them myself.
Why this keeps happening: leaked secrets & api keys
Secret keys placed in front-end code, mobile bundles or public repositories can be found by automated scanners and abused, often running up large bills on AI or cloud accounts before anyone notices.
A quick checklist before you ship
- Keep secret keys only in server-side environment variables, never in browser or app code.
- Set spend limits and usage alerts with every AI and cloud provider.
- Turn on secret scanning and push protection for your repositories.
- If a key leaks, revoke and replace it first; deleting the file is not enough.
More on this: every leaked secrets & api keys story and our related guide.
Tools involved
Related stories
- Roll every secret you stored in Railway
Railway: intruder may have read customer environment variables - Rotate any AI key you saved in a hosted tool
OpenCode Console breach: saved AI provider keys may be exposed - If you self-host vLLM 0.16 to 0.20 with async scheduling and pipeline parallelism, update to 0.21.0 or later
vLLM: async scheduling with pipeline parallelism could put fragments of one user's context into another user's response, fixed in 0.21.0
Source: original post on X ↗. Summarised in our own words; numbers are as stated by the source. Browse all stories.