Skip to content

run timeout sends kill(-1, SIGTERM) — kills ALL processes on the host, not just the sandbox #32

Description

@xulis

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

  1. Create a policy with a short timeout:
resources:
  memory_max: "64M"
  pids_max: "32"
  cpu_max: "50000 100000"
  timeout_ms: 5000
  1. Run a command that exceeds the timeout:
finsafe --policy timeout.yaml run -- sleep 10
  1. 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.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions