You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
【安全评审】动态插件的 vm "沙箱"存在宿主进程逃逸,PoC 已验证:一次批准 = 完整 RCE
#1441
// L6-7: This keeps cooperative packages inspectable and disposable but is// not containment: host-realm helper functions remain an escape route.// L217-219: vmTimeoutMs only bounds the SYNCHRONOUS portion; an async body// escapes it — acceptable under the module's trust stance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
概述
cordis_define/cordis_run让模型编写并运行"动态插件"。插件宿主半在一个node:vm沙箱里求值,但该沙箱不是安全边界(仓库注释自认),且沙箱内放置了宿主函数(TextEncoder/btoa/atob),通过标准构造器逃逸即可拿到宿主进程的process—— 获得完整用户权限:任意命令执行、任意文件读写、密钥窃取(如.env中的DEEPSEEK_API_KEY)、持久化后门。我已用 PoC 实测验证,并非理论推测。
攻击链
证据
1. 仓库自认的非 containment 注释(
packages/extensions/cordis-host-runner/src/sandbox.ts):2. 逃逸源进入沙箱(
sandbox.tsL137-140):宿主函数对象的
.constructor指向宿主Function—— 这是 Node 官方文档明示的 vm 边界("The vm module is not a security mechanism")。3. PoC(Node 22.19 实测,无副作用):
实测输出:
false/N:\...真实路径.../function—— 逃逸成立,spawnSync 与 readFileSync 均可达。4. 执行点(
lifecycle.tsL28):动态插件在宿主进程内以ctx.plugin(guardedPlugin(plugin, ...))启动,apply 的函数体位于 vm realm,逃逸代码同步执行于第一次 apply,cordis_run的批准是唯一闸门。为什么现有防线挡不住
ctx.plugin),逃逸后直接获得进程权限,工具层防线对其不可见;关于定位
我理解这是设计内的信任立场("API 塑形而非安全边界"、信任等级与 bash 相当),注释写得坦诚。本帖的诉求不是"这是 bug 快修",而是:
产品的用户侧叙事("沙箱" + "批准")与实际信任模型之间存在落差。 用户以为代码被隔离、操作被审批,实际上一次批准即授予进程级权限。这个落差需要被决策、被文档化、或者被消除。
三个可选方向(恳请维护者决策)
.env等敏感环境 + IPC 通信;贡献意向
我计划提交一个守卫插件(严格拒绝模式):挂载于工具执行管线,扫描
cordis_define的代码参数,拦截构造器链 /eval/new Function/ 逃逸源函数引用等模式(初始规则集含全部 PoC 模式),附测试与文档。若维护者倾向方向 1 或 2,该插件仍可作为过渡防线。如有表述或事实错误,欢迎指正;PoC 已在本地实测,随时可提供复现步骤。
All reactions