Scale · founder · 5 min read

The OpenCode Breach: Why Saving API Keys in Your AI Tool Is a Risk

OpenCode disclosed that attackers reached provider keys for 1.4% of Console users. What happened, what to do today, and how to store keys safely.

On October 17, OpenCode, the popular open-source AI coding agent, disclosed that attackers had accessed a legacy system it was in the middle of decommissioning. The company says third-party provider keys saved in some users’ Console workspaces may have been exposed. It puts the number at about 1.4% of Console users and began emailing them on October 18.

If you use OpenCode, the first thing to check is your inbox. If you use any AI tool that stores your OpenAI, Anthropic or Google keys for you, the rest of this applies too.

What happened

OpenCode’s statement says the attackers got into an older system, not the main product. The company calls it a large-scale distillation attack, meaning the goal was likely to harvest keys and use paid model access at scale. It says the incident is ongoing, so details may change, and that it is working with Anthropic, OpenAI and Google on cleanup.

The exposed item is the key you paste into the Console so OpenCode can call a model on your behalf. Your source code is not mentioned in any of the reporting we found.

Who is affected is simple: only users who received an email from OpenCode. If you didn’t get one, the company says you weren’t hit. If you only use the open-source CLI with keys in your own environment, you were not part of the Console exposure.

What to do today

If you got the email, work through this in order. It takes about fifteen minutes.

  1. Revoke the key at the provider. Go to the OpenAI, Anthropic or Google dashboard and delete the key. Deleting it in OpenCode is not enough.
  2. Create a new key and give it a clear name and, if the provider allows, a spending cap.
  3. Update every place the old key lived. Your other tools, your app’s environment settings, any automation. A dead key breaks them silently.
  4. Check usage. Look for requests or spend you don’t recognize over the last few days. Report anything odd to the provider.

If you didn’t get the email, it is still a good moment to rotate keys you haven’t touched in months.

Why this keeps happening

Every AI coding tool wants your model key. Some store it on their servers so it follows you between devices. That is convenient, and it makes the tool a high-value target, because one break-in yields keys for thousands of accounts, each tied to a credit card.

An API key is not a password in the usual sense. It has no second factor. Whoever holds it can spend your money and read whatever your usage exposes. A key with no spending limit is an open tab.

How to store keys more safely

You don’t need to be technical for most of this.

Prefer keys on your own machine

If a tool offers both “store in the cloud” and “store locally”, choose local unless you truly need to switch devices. It shrinks what a vendor breach can reach.

Use separate keys per tool

One key per tool means one revocation when something goes wrong, and your other tools keep working. It also tells you which tool leaked when you see odd usage.

Set spending limits and alerts

Both OpenAI and Anthropic let you cap monthly spend. Set it to roughly what you actually use plus a margin. A stolen key then costs you a bounded amount, not a surprise invoice.

Keep keys out of your project files

This is a separate risk we covered in our guide on environment files and coding agents. Keys pasted into code or chat history travel further than you think.

What this means for choosing tools

Open source is not the same as safe, and this breach shows why. The CLI’s code can be audited by anyone, but the hosted Console is a business with servers, and servers get breached. Judge a tool on how it handles your secrets, not only on its license.

Questions worth asking before you paste a key anywhere: Where is it stored? Is it encrypted? Can I use the tool without storing it? Does the company publish what happened when something goes wrong? OpenCode deserves credit for disclosing quickly and emailing affected users directly. That is better than many vendors manage. We’ll update this page when the full post-mortem lands.

The bottom line

Check for the OpenCode email, rotate any key you stored with the Console, and set spending caps everywhere. The same hygiene protects you from the next vendor breach, whichever vendor it is.

Related guides

Recommended next step

Was this helpful?