加固: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:
@@ -42,6 +42,8 @@ process.env.EXECUTOR_ISOLATION_BASE = ISO;
|
||||
process.env.EXECUTOR_SKILLS_DIR = SKILLS;
|
||||
delete process.env.EXECUTOR_URL; delete process.env.EXECUTOR_TOKEN;
|
||||
delete process.env.EXECUTOR_LOG_LEVEL;
|
||||
// 本机集成测试:core 与 executor 同机,连接必为回环,需放行容器自身来源(生产不设)。
|
||||
process.env.EXECUTOR_ALLOW_LOCAL_ORIGIN = '1';
|
||||
require(path.join(ROOT, 'executor/server.js'));
|
||||
|
||||
// 2) core 侧模块
|
||||
|
||||
Reference in New Issue
Block a user