Description
When a run command exceeds resources.timeout_ms, finSAFE executes kill(-1, SIGTERM) which sends SIGTERM to every process on the host (all PIDs except itself), instead of only terminating the sandboxed process tree (e.g. via cgroup).
Environment
- finSAFE 0.9.34 (personal CLI, install.sh)
- Linux 6.8.0-124-generic, x86_64, Ubuntu 24.04
- cgroup v2 (finsafe.slice), bwrap available
Steps to reproduce
- Create a policy with a short timeout:
resources:
memory_max: "64M"
pids_max: "32"
cpu_max: "50000 100000"
timeout_ms: 5000
- Run a command that exceeds the timeout:
finsafe --policy timeout.yaml run -- sleep 10
- Observe: the SSH session running the command is disconnected, and the parent shell is killed.
Evidence (strace)
13822 kill(-1, SIGTERM) = 0
13821 +++ killed by SIGTERM +++
13816 +++ killed by SIGTERM +++
13818 +++ killed by SIGTERM +++
13817 +++ killed by SIGTERM +++
13804 +++ killed by SIGTERM +++
The strace shows kill(-1, SIGTERM) — the parent test script (PID 13791), the SSH session, and unrelated processes all received SIGTERM.
Expected behavior
Timeout should terminate only the sandboxed process (and its descendants), e.g. via the cgroup cgroup.kill or by killing the sandbox PID. The host shell/SSH session must be unaffected.
Impact
- Running
finsafe run with a timeout in a CI job or over SSH kills the whole session (and any other processes on the machine).
- Any process on the host can be SIGTERMed — in the worst case, a long-running server process gets terminated. (SIGKILL would be even worse.)
Description
When a
runcommand exceedsresources.timeout_ms, finSAFE executeskill(-1, SIGTERM)which sends SIGTERM to every process on the host (all PIDs except itself), instead of only terminating the sandboxed process tree (e.g. via cgroup).Environment
Steps to reproduce
Evidence (strace)
The strace shows
kill(-1, SIGTERM)— the parent test script (PID 13791), the SSH session, and unrelated processes all received SIGTERM.Expected behavior
Timeout should terminate only the sandboxed process (and its descendants), e.g. via the cgroup
cgroup.killor by killing the sandbox PID. The host shell/SSH session must be unaffected.Impact
finsafe runwith a timeout in a CI job or over SSH kills the whole session (and any other processes on the machine).