/

CVE-2026-22812

Severity:

HIGH RISK

(8.8)

Missing Authentication for Critical Functionality

CVE-2026-22812

Analyzed

Vulnerability type

Category:

Missing Authentication for Critical Functionality

CWE:

CWE-306, CWE-749, CWE-942

Impact:

Arbitrary Command Execution with User Privileges

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

OpenCode, an open source AI coding agent, previously started an unauthenticated local HTTP server that exposed endpoints capable of running arbitrary shell commands with the user's privileges.

Any local process—or even a website in the user's browser via permissive CORS—could abuse this interface to execute commands, making everyday browsing and local applications a potential trigger for code execution.

Affected context

The vulnerability affects OpenCode installations that automatically start the bundled HTTP control server without any authentication or access control checks.

The server listens on a local interface but accepts requests from:

  • Any local process running on the same machine
  • Any website in the user's browser, due to overly permissive CORS configuration

In such environments, the HTTP API includes endpoints that can trigger shell command execution as the current user.

Exploit preconditions

  • Attack surface: Local HTTP server exposed by the OpenCode agent.
  • Required access:
  • Any code or process running locally (including low-privilege applications), or
  • Any website visited by the user that can issue cross-origin requests.
  • Trigger point: Sending crafted HTTP requests to the OpenCode local server endpoints that forward input to the shell.
  • Why exploitation is possible:
  • No authentication or authorization is required for invoking critical command-execution functionality (CWE-306).
  • The HTTP server exposes sensitive methods to all local callers (CWE-749: Exposed Dangerous Method or Function).
  • Permissive CORS trusts arbitrary web origins, allowing browser-based code to access the API (CWE-942: Overly Permissive Cross-domain Whitelist).

Why this happens

At its core, this is a design-level access control flaw where a powerful automation API is exposed without authentication.

The OpenCode agent starts a local HTTP server that directly maps incoming requests to shell command execution with the user's privileges, but fails to:

  • Enforce authentication or session checks on those endpoints (CWE-306).
  • Restrict which functionality is available through the public API, thereby exposing dangerous shell-related methods (CWE-749).
  • Constrain which web origins are allowed to call the API, configuring CORS to effectively accept any site (CWE-942).

This combination turns the local control interface into a general-purpose remote shell accessible to any local code and cross-origin browser scripts.

Potential impact

  • Execution of arbitrary shell commands as the current user.
  • Exfiltration of local files, SSH keys, or API tokens accessible to the user account.
  • Installation of malware, backdoors, or persistence mechanisms on the system.
  • Modification or deletion of user data and source code repositories.
  • Lateral movement via credentials or SSH agents used by the developer account.
  • Abuse of the user's environment (e.g., Git, build tools, cloud CLIs) to impact connected services.

General mitigation guidance

Effective mitigation focuses on locking down high-privilege automation APIs and reducing trust in local and browser-based callers:

  • Enforce strong authentication for any HTTP endpoints that can run commands, modify files, or control the local environment.
  • Apply least-privilege API design by separating sensitive operations into restricted interfaces and avoiding direct shell access where possible.
  • Constrain network exposure of local control servers (e.g., bind explicitly to loopback where appropriate and avoid exposing ports to other users or containers).
  • Harden CORS policies by default-denying cross-origin access and only allowing explicitly trusted origins when truly necessary.
  • Introduce explicit user consent for high-risk actions (e.g., confirmation prompts before executing arbitrary shell commands).
  • Run helper components with minimized privileges rather than full user rights when they must process external input.

These patterns help ensure that local automation endpoints do not silently become remote shells.

How teams detect issues like this

Detection generally combines code-level analysis, configuration review, and runtime monitoring:

  • Static analysis and code review:
  • Flag handlers in HTTP servers that directly call shell execution APIs or system commands.
  • Look for HTTP routes that lack authentication/authorization middleware while invoking critical operations.
  • Identify permissive CORS configurations (e.g., wildcard origins, broad Access-Control-Allow-Origin policies).
  • Configuration and architecture review:
  • Map all local service ports, their consumers, and whether authentication is enforced.
  • Review threat models for any devtools or agents exposing HTTP APIs to ensure they are not implicitly trusted.
  • Runtime and network monitoring:
  • Monitor for unusual traffic patterns to local agent ports originating from web browsers or untrusted local processes.
  • Use host-based intrusion detection to flag unknown processes invoking sensitive local APIs or spawning shells.
  • Automated tooling:
  • Apply SAST or linters configured with rules for dangerous API exposure and insecure CORS.
  • Integrate security checks into CI to fail builds if critical functions are mapped to unauthenticated endpoints.

Sources

SourceLink
github.comgithub.com/anomalyco/opencode/security/advisories/GHSA-vxw4-wv6m-9hhh

Frequently asked

questions

Not directly in the traditional sense. The server listens locally, but any website visited by the user can issue cross-origin requests due to permissive CORS, effectively turning normal browsing into a potential remote trigger for local command execution.

An attacker needs either the ability to run code on the victim's machine (even as a low-privilege local process) or to lure the user into visiting a malicious or compromised website that can send HTTP requests to the local OpenCode server.

The most robust pattern is to require strong authentication and authorization for any endpoints that can execute commands or alter the local environment, minimize the exposed API surface, and avoid direct shell execution where a safer, higher-level abstraction can be used.

Treat local HTTP APIs as untrusted interfaces by default: design them with strict authentication, origin and caller validation, least-privilege operations, conservative CORS policies, and explicit user consent for dangerous actions, combined with regular security reviews of devtool architectures.

Find out what's already
exploitable in your codebase.