加固:executor 拒绝容器自身来源的 /exec;token 移出仓库

- 隔离只 unshare mount+pid,命令与 executor 同 net ns,能打到 127.0.0.1:9000;此前全局 token 一经泄漏,会话内即可借 /exec 以任意会话 cwd 起命令、绕过隔离读他人数据。现 /exec 先于鉴权拒绝源地址为回环/本机网卡的请求(403),/health 不设限;core 在另一容器、源地址非本机,不受影响。

- 实测:容器内带合法 token 调用 403、容器内 /health 200、core 侧新 token 200 且 session 隔离与技能执行正常。

- token 不再硬编码:compose 改用 ${EXECUTOR_TOKEN:?...} 从 .env 读取(.env 已 gitignore,附 .env.example 模板;未设置直接报错,杜绝静默无鉴权)。旧值已轮换(旧 token 401,新 token 200)。

- 本机集成测试用 EXECUTOR_ALLOW_LOCAL_ORIGIN=1 放行回环来源(executor/smoke-test.js、app/test/remote-exec.test.js),生产不得设置;ARCHITECTURE §2/§6 同步。
This commit is contained in:
2026-09-11 21:17:02 +08:00
parent 3e389747c8
commit 2f96414c49
7 changed files with 47 additions and 6 deletions
+1
View File
@@ -10,6 +10,7 @@ const TASK_ROOT = SELF + '/.taskroot';
require('fs').mkdirSync(TASK_ROOT, { recursive: true });
process.env.EXECUTOR_CWD = TASK_ROOT;
delete process.env.EXECUTOR_TOKEN; // 主实例不带 token,鉴权单独测
process.env.EXECUTOR_ALLOW_LOCAL_ORIGIN = '1'; // 本机集成测试:连接必为回环,放行自身来源(生产不设)
const { spawn } = require('child_process');
const path = require('path');