Skip to content

Blog

OpenCode Console was hacked: how safe are the API keys you give coding agents?

7 min read

On October 17 (US time), the open-source coding agent OpenCode disclosed a security incident on X. It said there had been “a security breach linked to a large-scale distillation attack” the night before, and that 1.4% of OpenCode Console users had been affected. The affected users were some of those who had connected external AI providers. OpenCode said it was working with Anthropic, OpenAI and Google to resolve the incident.

OpenCode has more than 217,000 stars on GitHub. By the company's account, 16 million developers use it every month. Within two days, the notice passed 2.74 million views and 11,000 likes. So how safe are the API keys you connect to a coding agent?

OpenCode's security incident notice on X, posted October 17 (US time), with 2.74 million views as of October 19 (X @opencode).
OpenCode's security incident notice on X, posted October 17 (US time), with 2.74 million views as of October 19 (X @opencode).

In short, the problem was not the OpenCode app but the keys entrusted to Console.

There are two ways to use OpenCode. One is the OpenCode app, which runs in a terminal or on the desktop. API keys you enter there are stored in a configuration file on your own computer (~/.local/share/opencode/auth.json). The other is OpenCode Console, which runs on the web. Once OpenAI, Anthropic or Google keys are added to a team workspace, team members use the models through Console without ever seeing the keys.

This time, the problem was on the Console side. Co-founder Dax Raad replied, “This is about OpenCode Console, not OpenCode itself, and those keys never even reach us.” In other words, keys entered in the app do not pass through OpenCode's servers. OpenCode emailed every affected user on the morning of October 17 and said that anyone who did not receive the email was not affected.

An API key belongs to whoever holds it.

An API key does not go through a second check the way a login does. Anyone who has the key string can send requests that are billed to the key owner's account. So when a key leaks, the damage shows up directly on the bill.

That is exactly what happened. Developer Colin Parsons posted on X on October 17 that $281 had been drained from an OpenAI key and $168 from an Anthropic key, starting at 2 a.m. US Eastern Time. Both keys were used only for OpenCode. Other keys were untouched, according to the post. Preston Zeller said a forgotten key set up for OpenCode had been charged more than $1,700 overnight. Zeller added that a usage limit thought to be in place had never actually been set.

A post about charges drained overnight from OpenAI and Anthropic keys used only for OpenCode (X @colinparsonscom).
A post about charges drained overnight from OpenAI and Anthropic keys used only for OpenCode (X @colinparsonscom).

OpenCode is issuing refunds to affected users. Dax Raad asked those affected to send an email and said refunds were already under way. OpenAI's Thibault Sottiaux also said on October 19 that OpenAI had worked with OpenCode to restore OpenAI API customers' accounts and refund the credits drained in the attack.

A distillation attack siphons off a model's answers through someone else's account.

Distillation is a method of collecting large volumes of answers from a strong model to train another model. AI companies commonly use it as a legitimate technique to make their own models smaller and cheaper. Using it covertly on someone else's model is a different matter. On February 23, 2026, Anthropic disclosed that DeepSeek, Moonshot and MiniMax had used about 24,000 fake accounts to hold more than 16 million exchanges with Claude and extract its capabilities. They targeted agentic reasoning, tool use and coding, and they split their requests across fake accounts and proxy services to avoid detection.

Someone else's API key is ideal material for this kind of attack. The key owner pays, and the requests come from a legitimate user's account. However, OpenCode has not yet said how this breach connects to a distillation attack, or who was behind it.

Attackers run their agents around the clock.

The attacks continued after the notice. On October 18, Dax Raad wrote, “They have been attacking our systems nonstop for the last 48 hours,” and “We need to run agents 24/7 too, because they are.” The post passed 1.44 million views. Even Raad's own personal account was under attack, the co-founder said the day before, calling it “a whole new world of hacking with AI.”

A post by OpenCode co-founder Dax Raad on October 18, with 1.44 million views as of October 19 (X @thdxr).
A post by OpenCode co-founder Dax Raad on October 18, with 1.44 million views as of October 19 (X @thdxr).

The defenders, if anything, had a harder time getting help from AI. Asked whether the latest models' cyber safeguards had got in the way, Dax Raad replied, “It was pretty frustrating in the middle of investigating the incident. The models helped for a while and then started refusing.” On October 6, Anthropic said that general models such as Claude Opus 5.5 carry conservative safeguards that block most cyber tasks. It also expanded its Cyber Verification Program, which lifts these restrictions, after review, for security teams doing defensive work such as incident response. OpenCode said things improved after it was approved for Daybreak Blue, through which OpenAI lifts restrictions for defensive use. On October 19, it wrote, “Daybreak was crucial, and it is still running.”

Give each tool its own key.

The incident also exposes gaps in key management. A copied key stays valid even after you delete it from Console. It stops working only when you revoke it in the provider's dashboard. Budget limits inside Console also cannot stop requests that do not go through Console. So when you give a key to a coding agent, a few rules are worth following.

  1. Create a separate key for each tool and agent. If one leaks, you only need to revoke that key, and you can see right away where the leak came from.
  2. Set usage limits and alerts on the provider side. Limits inside a tool are useless once a key has been copied.
  3. Revoke keys you are not using. The key drained of $1,700 was also one its owner had forgotten about.
  4. Where possible, use login tokens instead of long-lived API keys. Dax Raad explained that when you connect to OpenCode by logging in, it uses OAuth tokens by default.

A post that drew attention on Hacker News over the weekend, “If you don’t run your own LLM proxy, how do you know whats going on?” (167 points, 114 comments), makes the same point. It argues that running your own LLM proxy gives you logs of which key called which model and when. It also lets you give each agent its own virtual key instead of your main API key. Proxies such as the open-source LiteLLM support virtual keys and per-key budgets.

Much is still unknown.

As of October 19, OpenCode had not disclosed which system was breached or how, how many keys were exposed, or how many people the 1.4% represents. It said only that keys may have been exposed. It has not confirmed that any were actually copied and used. The losses users have posted are also their own claims. The incident is still ongoing, so the details may change.

As coding agents spread, API keys end up scattered across terminals, web dashboards and CI settings. Attackers are already running agents nonstop, so when a single key leaks, the damage piles up overnight. I think knowing where you have put each key, and being able to block it right away on the provider side, will become a basic skill for anyone using agents.

https://x.com/opencode/status/2111519637049319818