Part of the online platform of OpenCode, the open-source AI coding agent, has been compromised. Attackers stole some users' API keys and ran up AI usage charges on those accounts. The incident turned the problem of API key security in AI coding agents into a very concrete bill.

What happened?

OpenCode is an open-source coding agent that has emerged as an alternative to Claude Code and Cursor. Attackers broke into part of the project's online platform and took users' keys. The keys were then used to rack up spending on the victims' accounts with their AI providers. The most striking part of the story emerged during the investigation: the AI tools that analysts turned to for help examining the malicious code repeatedly refused to look at it.

Why does it matter?

A coding agent works differently from a traditional development tool. It reads files, runs commands, reaches out to the network, and uses provider keys while doing so. In other words, a single tool has access to your source code, your terminal, and a paid API account all at once. An IDE extension used to see, at most, your code. Today an agent can modify your code, install packages, and drain an account tied to your credit card.

This setup carries the familiar logic of supply chain attacks over to a new target. Fake or hijacked packages on npm and PyPI have for years gone after the environment variables on developers' machines. In the agent ecosystem, keys are often gathered in a single configuration file or platform account. An attacker who compromises one platform can reach many users' keys in a single move. A stolen key is also highly valuable: model calls translate directly into money, and the abuse is usually noticed only when a bill or quota alert arrives.

Being open source cuts both ways here. The code is open to anyone's scrutiny, which is a good thing. But open code does not mean that the infrastructure around it, such as account systems, plugin distribution, and cloud services, is secure. The attack most likely targeted this surrounding layer rather than the core code. That distinction calls for users to question the assumption that "it's open source, so it must be safe."

Why is the AI tools' refusal a problem?

The most notable detail of the incident played out on the defensive side. Investigators turned to AI assistants to understand the suspicious code. The assistants judged the content to be malicious and declined to help. Safety filters are designed to block the generation of attack code. The problem is that the same filter can also stop a defender who is trying to analyze that code.

This is an old dilemma of dual-use knowledge. The same piece of code sits on the table for a malware analyst and for the person who wrote the malware. Filters often read the surface pattern rather than the intent. As a result, attackers use their own tools without limits, while defenders have to rephrase refused requests or fall back to manual analysis. This asymmetry decides the pace: in incident response, minutes matter.

The answer may not be loosening the filters. A more sensible path is to offer separate access tiers for verified security teams. Some providers have launched programs aimed at cybersecurity researchers. But their scope and access are still limited, and small open-source teams will find it hard to get into them.

What should developers do?

There are concrete steps on the defensive side, and most of them are boring but effective:

  • Give the agent a separate key with limited permissions and a spending cap, not the key to your main account.
  • Set a monthly budget ceiling and an anomalous-usage alert in the provider dashboard.
  • Use a secrets manager instead of keeping keys in plain-text configuration files.
  • Vet third-party plugins and connectors the way you would vet an npm package.
  • At any sign of trouble, rotate the key immediately; don't wait for the incident details.
RiskTraditional IDE extensionCoding agent
File accessUsually read/writeRead, write, command execution
Network accessLimitedBroad, often automatic
Money at stakeUsually noneDirect API bill
Key concentrationLowHigh, gathered in one place

What's next?

The first thing to watch is how transparently the OpenCode team explains the scope and root cause of the incident. The second is how providers will handle cost refunds and automated detection for stolen keys. The third is whether model makers will build finer-grained mechanisms to distinguish security analysis requests. On this topic, OWASP's risk list for LLM applications offers a good starting framework.

In my view, the real lesson is this: the authority granted to agents is growing faster than the trust model developers are used to. Short-lived, narrowly scoped, capped keys should therefore be the default, not an option. As for safety filters that slow down defenders too, that is a separate problem that still has no owner and needs solving.