test(runner): verify sandbox isolation with a hostile program suite

This commit is contained in:
shira committed 2026-10-11 08:59:59 +03:00
1 parent afee564bf4
commit e858280d91
38 files changed
+1359 -168

No files matched your search

+13 -5
View File
@@ -1,9 +1,11 @@
# Isolation probe: the root file system and the source are read-only, the
# scratch directory is writable, and runner files are not visible.
# Isolation probe: the root, the source, and the build output are read-only,
# only the scratch directory is writable, and no host file, runner file,
# secret, or process information is visible, neither on disk nor in the
# environment.
import os
writable = []
for path in ("/box/injected", "/usr/injected", "/injected", "/lib/injected"):
for path in ("/box/injected", "/out/injected", "/usr/injected", "/injected", "/lib/injected"):
try:
with open(path, "w") as stream:
stream.write("x")
@@ -12,5 +14,11 @@ for path in ("/box/injected", "/usr/injected", "/injected", "/lib/injected"):
pass
with open("/tmp/scratch", "w") as stream:
stream.write("ok")
visible = [path for path in ("/etc/passwd", "/run/secrets", "/opt/lincodex-runner", "/proc/1") if os.path.exists(path)]
print("isolated" if not writable and not visible else "writable=" + ",".join(writable) + " visible=" + ",".join(visible))
hidden = (
"/etc/passwd", "/etc/shadow", "/etc/hosts", "/run/secrets", "/run/secrets/runner_api_token",
"/opt/lincodex-runner", "/var/lib/lincodex-runner", "/proc/1", "/proc/self/environ",
"/proc/self/mounts", "/sys/fs/cgroup", "/dev/mem", "/dev/kmsg", "/root", "/home",
)
visible = [path for path in hidden if os.path.lexists(path)]
leaked = [name for name in os.environ if "RUNNER" in name or "TOKEN" in name or "SECRET" in name]
print("isolated" if not writable and not visible and not leaked else f"writable={writable} visible={visible} env={leaked}")