OpenCode RCE 漏洞分析 (CVE-2026-22812)

· 约 2 分钟 · 旧博客导入

之前看到了这个

【已复现】OpenCode 远程代码执行漏洞(CVE-2026-22812)安全风险通告

说是能shell

通告下面提到了github威胁情报的链接

Unauthenticated HTTP Server Allows Arbitrary Command Execution · Advisory · anomalyco/opencode

github链接上写的也是很清楚了,poc都有

image
image

复现一手

image
image
image
image

opencode应该用的人很多,因为似乎支持白嫖大模型

image
image

但是大伙也不用太担心,因为默认情况下opencode是监听127.0.0.1的,外部一般无法访问

image
image

接下来看看代码

根据github情报所说,服务端是在cli/cmd/tui/worker.ts:36启动的

image
image

对的对的,是用bun启动的,web框架用的是hono

跟进listen方法,处理http请求的是App对象

image
image

app对象里面就是一包中间件和路由了

image
image

找到/session/:sessionID/shell,跟进shell

image
image

组装命令

image
image

执行命令

image
image

其实我感觉既然能访问4096端口了,不如直接叫AI帮我shell一个

image
image

不过AI似乎会分析输入的是不是恶意命令,无所谓了,反正一般情况下是监听127.0.0.1的,很难直接在互联网见到开放的opencode,只有加上–mdns才有危险

image
image

看看官方是怎么修这个洞的,漏洞通报说1.0.216版本已经修好了

image
image
image
image

好像就加了个CORS策略?这好像没用吧

反正应该影响也不大,无所谓了

查找文章

↑↓ 选择 · Enter 打开 · Esc 关闭 查看全部结果