Skip to content

fix(security): the host sandbox declares a noexec /tmp it never applies #798

Closed

Description

@dan-petty

Context & Rationale

The host sandbox policy declares /tmp as size=64m,noexec (sandbox/models.py:373), but only the size reaches bubblewrap (sandbox/host.py:60-68, :365-369). Bubblewrap has no noexec option for a tmpfs, so the flag is dropped without a word. In a repro, a script written to the sandbox's /tmp ran.

The output-cap test (tests/test_host_sandbox.py:172) uses a writer that exits by itself after 50 KB, so it never tests that the process is killed.

Found while checking the #663 fix.

Scope & Deliverables

  • Deliverable:
    • The host sandbox either enforces noexec on /tmp or stops declaring it, and the sandbox docs say which.
    • The output-cap test uses an endless writer and asserts that the process ends well before the timeout.
  • Constraint: no RLIMIT_NPROC and no fork-bomb tests (AGENTS.md).

Strategic Alignment


Generated by Claude Code

Activity

  1. added
    type/security
    scope/security
    priority/p3-low
    on Oct 1, 2026
  2. added this to the v0.2.32 milestone on Oct 8, 2026
  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.32 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: URLs and host keys read by the library that dials, ollama hardening, and pull-request test-quality tooling. Position 4 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #698. The host sandbox reads the same SandboxPolicy as the container runners (sandbox/models.py:382-391); #698 asks that dropping noexec here keeps it for containers. Found by the 2026-10-08 backlog review.

  5. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1502, merged into release/v0.2.32 as 630fb2d.

    Summary

    Bubblewrap has no noexec option for a tmpfs. The host sandbox read the same SandboxPolicy as the container runners (/tmp as size=64m,noexec), so only the size reached bubblewrap and noexec was dropped without a word. Inside the sandbox, /proc/self/mounts showed /tmp as rw,nosuid,nodev,size=65536k, and a script written to /tmp ran.

    The host sandbox cannot enforce noexec: the confined child has no capability to remount /tmp, and Landlock would need a dependency outside the standard library. So the host now stops declaring it:

    • DEFAULT_HOST_SANDBOX_POLICY (src/devops_cli/sandbox/host.py) declares /tmp as size=64m, and HostSandbox defaults to it. The container policy DEFAULT_SANDBOX_POLICY keeps size=64m,noexec, as feat(cli): sandbox enforcement audit declared vs engine vs enforced (devops sandbox audit) #698 asks.
    • _tmpfs_mount_args replaces the hand-written size regex. docker.utils.parse_bytes (an existing dependency) turns size into --size <bytes>. Any other option (noexec), and any size that parse_bytes refuses (size=50%), raises a SandboxValidationError naming the option and path instead of being dropped.
    • HostSandbox.__init__ builds the tmpfs arguments once, so a policy that bubblewrap cannot apply fails when the sandbox is constructed, not halfway through execute().
    • SECURITY.md, item 6: the host sandbox's /tmp is a private 64 MiB tmpfs mounted nosuid and nodev, which the confined command can write to and execute from.

    The output-cap test now shows the kill. Its old writer exited by itself…

    5 file(s) changed.

    How it was verified

    Check runs at 4eeb227:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Service Image: skipping
    • Dependency Freshness: skipping
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping

    Acceptance Criteria of docs/agent/tasks/task-798-host-sandbox-declares-a-noexec-tmp-it-never-applies.md:

    • The host stops declaring noexec. test_host_sandbox_default_policy_mounts_tmp_as_declared shows that the default host policy declares /tmp as size=64m and that the arguments mount it with --size 67108864 --tmpfs /tmp.
    • An option bubblewrap cannot apply is refused. test_host_sandbox_refuses_a_tmpfs_option_bubblewrap_cannot_apply constructs host sandboxes whose policies declare size=64m,noexec and size=50%, and expects a SandboxValidationError naming noexec and size=50%.
    • Containers keep noexec. DEFAULT_SANDBOX_POLICY in src/devops_cli/sandbox/models.py is unchanged, and tests/test_sandbox_lifecycle.py still pins its size=64m,noexec tmpfs.
    • The docs say which. SECURITY.md item 6 says that the host sandbox's /tmp allows execution, and why.
    • The cap kills an endless writer. test_host_sandbox_kills_an_endless_writer_at_the_output_cap (bubblewrap-marked) runs a shell loop that ignores SIGPIPE, with a 30 s timeout and a 1024-byte cap. It asserts that the run fails without timing out, keeps at most 1024 bytes, reports the cap, and ends within 1 s. That is under the reap's 1 s grace, so the test fails if the kill at the cap is removed (the run then takes about 1.06 s, or about 2.09 s with no kill at all).
    • No RLIMIT_NPROC and no fork bombs. No test sets a process limit or spawns processes without bound.
    • Release. changelog.d/798.md records the change under ### Security.
  6. added a commit that references this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p3-lowscope/securitytype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions