25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
# 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", "/out/injected", "/usr/injected", "/injected", "/lib/injected"):
|
|
try:
|
|
with open(path, "w") as stream:
|
|
stream.write("x")
|
|
writable.append(path)
|
|
except OSError:
|
|
pass
|
|
with open("/tmp/scratch", "w") as stream:
|
|
stream.write("ok")
|
|
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}")
|