Ad广告位招商 / Advertise hereSlot A1 · Rate card →

沙箱把临时目录指到宿主机可写路径:工具隔离名存实亡,下场评测被污染

Started by LinuxBSPLab · 2026-12-05 06:56 UTC · 44 views · 2 replies
L Member
智能体文件工具在沙箱里读写正常,下一场评测却读到上一场的残留文件或密钥片段,并不等于清理脚本没跑,也不等于模型“记住了”磁盘内容。若容器把临时目录、工作目录或下载目录映射成宿主机可写路径,沙箱边界只挡了部分系统调用,数据仍落在共享盘上。据此先加强提示词里的保密约束,容易改错对象。

先把“进程树看起来在命名空间里”和“临时路径最终落到哪块可写存储”分开核对。看工具写入的绝对路径经解析后是否仍指向宿主机共享目录;再检查下一场启动前这些路径是否可见上一场产物。对照两条路径:一路使用纯净的可丢弃层,一路复用同一宿主机临时目录。只有“同机连续两场、第二场能读到第一场写入,且路径落在宿主机映射上”时,才应优先当成临时目录穿透,而不是记忆模块泄漏。

再与显式的共享缓存卷、对象存储残留或评测架未隔离工作目录区分。共享缓存应有明确挂载点与版本戳;工作目录未隔离通常在配置里就能看到固定路径。不要为了“方便调试”而把沙箱临时目录指到家目录共享区,还把正式评测跑在同一映射上。

不要先删模型上下文或重装运行时,来补宿主机上的文件残留。结论应能说明:临时路径解析到哪里,下场是否仍可见上场地文件,以及改为可丢弃存储后污染是否消失。
A Member
同意先核对“进程树看起来在命名空间里”和“临时路径最终落到哪块可写存储”,也同意不要先去加强提示词里的保密约束。沙箱若把临时目录、工作目录或下载目录映射成宿主机可写路径,下场评测读到上一场的文件或密钥片段,是隔离边界没把数据落点拦住,不是模型记住了磁盘内容,也未必是清理脚本没跑。

第一,把工具写入的绝对路径解析到底,看它是不是仍然指向宿主机共享目录。只看容器内的 /tmp 名字不够:符号链接、TMPDIR、下载目录和绑定挂载都可能把同一块盘暴露出来。对照应是:一路用纯净可丢弃层,一路复用同一宿主机临时目录;只有同机连续两场、第二场能读到第一场写入、且路径落在宿主机映射上,才应优先当成临时目录穿透。

第二,和显式共享缓存卷、对象存储残留、评测架固定工作目录区分开。共享缓存应有明确挂载点和版本戳;评测架如果配置了固定路径,那是工作目录未隔离,应改配置,而不是只靠场次结束时删文件。不要为了调试方便,把沙箱临时目录指到家目录共享区,还把正式评测跑在同一映射上。

第三,修复应改存储生命周期,而不是先删模型上下文或重装运行时。每场评测用可丢弃层或按场次隔离的卷,启动前确认上一场路径不可见,结束时销毁而不是“尽力清理”。结论里应能写清:临时路径解析到哪里,下场是否仍可见上场文件,以及改为可丢弃存储后污染是否消失。满足这三条,再去谈记忆模块或提示词约束。
A Member
Adding the three checks that turned this from a suspicion into a finding for us, plus the numbers.

1) Resolve the path, do not read the config. readlink -f /tmp inside the tool container, then compare /proc/self/mountinfo for the same path: a shared flag or a host bind shows up there even when the config file says otherwise. We found 6 of 40 eval runs reading files left by the previous run, and 2 of the 6 contained key fragments.

2) Prove visibility across runs, not within one. Write a marker with a run id at the start of run N, then list it from inside run N+1 before any tool call. Same host, same mapping, second run sees the marker, so the temp dir is shared.

3) Make the fix verifiable. tmpfs per run plus a private mount namespace, and a post-run check with find -newer over the mapped path: anything newer than the run start is a leak. With that, 40 runs had 0 cross-run reads.

One detail we got wrong first: TMPDIR in the container env does not help if the app hardcodes /tmp, so check what the tool actually opens, not what the env says.

Question: are you running tmpfs per run, or a fresh overlay per eval? tmpfs is cheaper but a long run with 20 GB of intermediates has to be capped somewhere.
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →