Your AI Agent's API Keys May Have Leaked. Here's What to Do in the Next Hour
Published 2026-10-19 · Updated 2026-10-19 · By The Is My Agent Safe team
Short answer
Stop the agent first with openclaw gateway stop. Then revoke each leaked key in your provider's console and create a replacement: OpenAI's API keys page, or the Claude Console for Anthropic. Make a new Gateway token, put the new keys into OpenClaw, set a hard spend limit, and check your usage page for charges you don't recognize.
- Contain: stop the Gateway so nothing keeps using the old keys.
- Revoke and replace: new key at the provider, old key deleted or disabled, new key in OpenClaw.
- Cap the damage: hard spend limits, then check usage for activity you didn't run.
- Find the leak: public repos, pasted chats, third-party tools, an exposed Gateway or plaintext config.
As of 19 Oct 2026, OpenCode says a security breach affected 1.4% of users of OpenCode Console, its hosted service, and The Hacker News reports that OpenAI, Anthropic or Google keys saved there may have been exposed. OpenCode has emailed affected users to revoke and replace those keys with each provider, which is what the steps below walk through.
First 10 minutes: stop the agent
If you think a key leaked, assume someone else can use it right now. OpenClaw's incident response steps start with containment. On the machine where your Gateway runs:
openclaw gateway stop
This stops your agent from making new requests with the old keys while you replace them. If you run OpenClaw in Docker, stop the container instead.
If the leak came through an exposed Gateway, close that too. Set gateway.bind to loopback and remove the public route. Our exposure guide walks through it.
How do I rotate (revoke and replace) my keys?
Do this for every key the agent could see: model providers, channels such as Telegram or Discord, and any tool or webhook tokens. Key rotation means making a new key and killing the old one.
OpenAI
- Open the API keys page in the OpenAI platform.
- Create a replacement key.
- Revoke the old key. OpenAI's advice for a suspected leak is to rotate immediately.
- If misuse continues, contact OpenAI through help.openai.com.
Anthropic (Claude API)
- Open the API keys page in the Claude Console (
platform.claude.com/settings/keys). - Click the three-dot menu next to the key and choose Disable or Delete. Disable can be undone. Delete is permanent.
- Click Create key for the replacement, and choose an expiry date.
- If you still see activity you don't recognize, contact Anthropic support.
Other providers and channels
Use the same pattern in that provider's console or settings: revoke or regenerate the key, then create a new one. If a provider lets you disable a key before deleting it, disabling is the quicker first move.
Your Gateway token
Make a new Gateway token too, since anyone with the old one can connect to your agent:
openclaw doctor --generate-gateway-token
Then update any device or remote client that connects with the old token.
Put the new keys into OpenClaw
If you use OpenClaw's secret store, set the new value without typing it on the command line. With no --value, OpenClaw asks for it in a hidden prompt:
openclaw secrets store set OPENAI_API_KEY --kind secret
If your keys live in your config or a .env file, replace them there instead. Then start the Gateway again with openclaw gateway start.
Can someone run up my bill?
Yes. A leaked key lets someone spend your quota. OpenAI warns this can mean unexpected charges, data loss and lost API access. Cap it now:
- OpenAI: set a monthly spend limit for your organization or project and turn on hard enforcement. Alerts alone don't stop traffic. OpenAI notes that spend can slightly exceed the limit, and that a hard limit can also block your own requests.
- Anthropic: if your organization has custom rate limits, set usage and spend limits in the Console. Otherwise, check your auto-reload settings, since auto-reload refills credit automatically.
- Check usage. Look at each provider's usage page for activity you didn't run, and contact their support if you find any.
How did my keys leak?
The common routes, from OpenAI's and Anthropic's own guidance and OpenClaw's docs:
- A public code repository. A key committed to GitHub is easy to find. Anthropic works with GitHub's secret scanning: if a Claude key shows up in a public repository, Anthropic deactivates it and emails you. If you got that email, this is how it leaked.
- Pasted somewhere. Keys in chats, emails, forum posts or support tickets.
- A third-party tool. Anthropic points out that giving your key to another tool gives its developer access to your account.
- An exposed Gateway. If your Gateway was reachable from the internet, anything it holds could have been read.
- Plaintext on disk. Keys in config files that other users or backups can read.
Before you restart for good, check OpenClaw's logs for anything you didn't do:
openclaw logs openclaw security audit --deep
How do I stop it happening again?
- Keep keys out of code. Use environment variables or a secret store, not hardcoded values.
- Find plaintext copies with
openclaw secrets audit --check. It reports keys stored in plaintext and broken references. - Give new keys an expiry date. Both OpenAI project keys and Anthropic keys support one.
- Use a separate key per project or tool, so one leak doesn't expose everything.
- Keep hard spend limits on.
- Keep your Gateway on loopback, and re-run
openclaw security audit --deepafter every change.
The OpenClaw security checklist covers the rest.
Frequently asked questions
How do I rotate my OpenAI or Anthropic API key?
For OpenAI, create a replacement on the API keys page, switch your apps to it, then revoke the old key. If you think it leaked, OpenAI says to rotate it immediately. For Anthropic, open the API keys page in the Claude Console, use the three-dot menu to disable or delete the key, then click Create key.
Can someone run up my bill?
Yes. A leaked key lets someone use your quota, which OpenAI warns can cause unexpected charges. Set a hard monthly spend limit, check your usage page, and contact the provider's support about usage you didn't make.
Does OpenAI have hard spend limits?
Yes, for organizations and projects, with hard enforcement turned on. Spend alerts alone don't stop traffic. OpenAI notes spend can slightly exceed the limit because enforcement isn't instant, and a hard limit can also block your own requests.
How did my keys leak?
Common routes are a key committed to a public repository, a key pasted into a chat, email or support ticket, a third-party tool you gave the key to, an agent Gateway reachable from the internet, or a config file other people can read.
How do I stop it happening again?
Keep keys out of code and plaintext config, run openclaw secrets audit --check, give keys an expiry date where your provider allows it, set hard spend limits, and keep your Gateway reachable only from your own machine.
Sources
- OpenCode on X: Console security breach notice (Oct 17, 2026)
- The Hacker News: OpenCode Console breach may have exposed OpenAI, Anthropic, and Google API keys (Oct 19, 2026)
- OpenAI Help: best practices for API key safety
- Claude Help Center: what to do if you suspect your API key has been compromised
- Claude docs: authentication (disable, delete and expire keys)
- Claude Help Center: API key best practices
- OpenClaw docs: operator incident response
- OpenClaw docs: openclaw secrets (CLI)
- OpenClaw docs: secrets, storage and logs
Get the weekly plain-English agent security brief
Agents & AI Security, explained: one short email a week. Free. Unsubscribe any time.
We'll only use your email to send the newsletter. Privacy policy.