AI agent · September 24, 2026

OpenCode server's upgrade endpoint let any webpage install an attacker's npm package

Datadog Security Labs and Anomaly disclosed on 24 September 2026 that opencode serve and opencode web, in npm, pnpm or Bun installs of OpenCode 1.14.30 through 1.18.21, exposed a /global/upgrade endpoint that accepted any npm package specifier and did not check the request's origin. A webpage could make the browser post to it and install an attacker's package, running its install scripts with the user's access to keys and tokens. The fix is in 1.18.22; no CVE was assigned.

DisclosedSeptember 24, 2026
AffectedOpenCode, opencode-ai, Anomaly
TypeAI agent
StatusResolved

What was exposed

Code execution as the user running OpenCode, and with it everything that account can read: provider API keys configured for OpenCode, Git and cloud credentials, SSH keys and .env files. When OpenCode is installed through an npm-compatible manager, the endpoint ran the equivalent of npm install -g opencode-ai@<target>, and npm accepts a remote tarball URL as the target. Because the server parsed a text/plain body as JSON and did not check Origin, a cross-site HTML form could submit the request. The advisory says password protection with OPENCODE_SERVER_PASSWORD did not help once the browser had cached the Basic credentials, since a top-level form navigation sends them. Datadog's write-up shows code execution through a package preinstall script; it does not report credential theft or exploitation in the wild.

Am I affected?

You are affected only if all of these held: you ran OpenCode 1.14.30 to 1.18.21; you used opencode serve or opencode web; OpenCode was installed with npm, pnpm or Bun (curl, Homebrew, Chocolatey and Scoop installs are not affected); the server had no password or the browser had cached it; and you visited an attacker-controlled page while it ran. Datadog suggests checking the install method with ls -l "$(command -v opencode)". Look in global npm packages for an opencode-ai install that did not come from the npm registry.

What to do now

  1. Update OpenCode to 1.18.22 or later.
  2. Set OPENCODE_SERVER_PASSWORD whenever you run the OpenCode server, especially on a network.
  3. If you ran an affected server while browsing untrusted sites, check that your global opencode-ai install came from the npm registry and rotate provider API keys and tokens on the machine.
  4. Stop opencode serve when you are not using it.

Keys to rotate

Guides to the credentials this incident put at risk:

Timeline

  1. OpenCode 1.14.30, the first affected release, ships, according to Datadog. Source
  2. Datadog Security Labs reports the issue through a GitHub security advisory. Source
  3. Anomaly merges the fix (PR #44686) and publishes OpenCode 1.18.22, then asks Datadog to delay publication by a month. Source
  4. Anomaly publishes GHSA-632h-h47v-g4x4 (high) and Datadog publishes its write-up; Datadog notes that 38.9% of OpenCode npm downloads from 17 to 23 September were still vulnerable versions. Source

Indicators

From the advisories listed below. Use them to search your logs, lockfiles and workflow runs.

  • POST requests to /global/upgrade with a target that is a URL rather than a version number.
  • A globally installed opencode-ai resolved from a non-registry tarball.

What this changes for credential handling

  • A self-update endpoint on a local agent server became a package-install primitive for any website. BotPassword is built so that compromising the agent's process does not also give access to the user's stored keys.

Frequently asked questions

Am I affected by the OpenCode incident?

You are affected only if all of these held: you ran OpenCode 1.14.30 to 1.18.21; you used opencode serve or opencode web; OpenCode was installed with npm, pnpm or Bun (curl, Homebrew, Chocolatey and Scoop installs are not affected); the server had no password or the browser had cached it; and you visited an attacker-controlled page while it ran. Datadog suggests checking the install method with ls -l "$(command -v opencode)". Look in global npm packages for an opencode-ai install that did not come from the npm registry.

What was exposed in the OpenCode incident?

Code execution as the user running OpenCode, and with it everything that account can read: provider API keys configured for OpenCode, Git and cloud credentials, SSH keys and .env files. When OpenCode is installed through an npm-compatible manager, the endpoint ran the equivalent of npm install -g opencode-ai@<target>, and npm accepts a remote tarball URL as the target. Because the server parsed a text/plain body as JSON and did not check Origin, a cross-site HTML form could submit the request. The advisory says password protection with OPENCODE_SERVER_PASSWORD did not help once the browser had cached the Basic credentials, since a top-level form navigation sends them. Datadog's write-up shows code execution through a package preinstall script; it does not report credential theft or exploitation in the wild.

Which keys should I rotate?

Rotate any Anthropic, OpenAI, GitHub credentials that were reachable from affected systems, starting with the ones that can publish code or reach production.

Keep keys out of reach of the next compromised package

BotPassword is in early access. Request an invite and we'll email you when your spot opens.