Skip to content

fix(tools): dead egress grants, and the socket boundary forge actually has - #391

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/sandbox-dead-egress-grant
Aug 18, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
fix/sandbox-dead-egress-grant

Conversation

@mohitranka

@mohitranka mohitranka commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #390 — both failures in the Linux sandbox enforcement suite. They had different causes, and only one was a security problem.

Neither fix makes CI green on its own: the two tests live in the same job, so both are here.


1. A dead egress grant made bwrap refuse to start

Not a security bug — a wrong explanation.

A grant can outlive the proxy that backs it. The session's egress proxy dies and takes its socket file with it, while the grant is still attached to the next command. bubblewrap_invocation then asked bwrap to --bind a source that no longer exists:

bwrap: Can't find source path /tmp/.tmp841Pcn/egress.sock: No such file or directory

bwrap refused to start, so the command never ran, and the caller was handed the generic sandbox explanation:

blocked by the sandbox: writes are confined to the workspace, and .git/.forge are read-only inside it.

Nothing in that suggests the egress proxy died — it sends you to look at file permissions for a networking failure.

A vanished socket is now treated the way a missing relay already is a few lines below: drop the grant and run with no route out, which is what a dead proxy means. Still fails closed — no relay is bound and --unshare-net is unchanged. The difference is whether the command runs and reports the truth, or refuses to start and reports something misleading.

2. The reachability test asserted a guarantee forge does not make

This one is a real gap, and the fix is to state the boundary honestly rather than to pretend.

--ro-bind / / exposes every host path read-only, and a read-only mount does not stop connect() — it checks the inode, not MNT_READONLY. So only the directories masked with a tmpfs are actually covered. The test probed $HOME, which is not masked, so it asserted something that was never true on Linux.

It could not have been caught locally either: the enforcement tests are #[cfg(target_os = "linux")], so on a macOS machine they compile out and the suite looks green — the same "green where it tested nothing" pattern as the installer suite in #389.

Split into the two things that were conflated:

  • The assertion now probes a masked directory — /run when the test can write there (the WSL2 job runs as root), /tmp otherwise. This is the guarantee forge makes and the one that matters: docker.sock is root on the host, and $XDG_RUNTIME_DIR under /run/user/$UID is where ssh-agent and gpg-agent live. The in-workspace control is kept so it cannot pass vacuously.
  • The $HOME case survives as an #[ignore]d test that reproduces the gap, so it stays executable rather than degrading into a comment. cargo test -- --ignored checks whether a kernel or mask change has closed it. If it ever stops reproducing, it fails and tells you to promote it back to an assertion.

SandboxPolicy now documents covered vs not covered explicitly.

Why the gap isn't simply closed here

Closing it needs a path-aware mechanism the mount namespace does not have:

mechanism verdict
seccomp-bpf cannot — a filter sees args[6] as scalar registers and cannot dereference the sockaddr_un * to read the path
seccomp user-notification should not — seccomp_unotify(2): "must not be used to make security policy decisions about the system call, which would be inherently race-prone"
Landlock LANDLOCK_ACCESS_FS_RESOLVE_UNIX right primitive, wrong decade — restricts connect(2) on pathname sockets, but it is ABI 9; ABI 5 shipped in 6.10, 6 in 6.12, 7 in 6.15, and the CI runner is on 6.8
mount masking / read allowlist what forge does today; closing the class this way means replacing --ro-bind / / with an allowlist, which is a much larger change with real breakage risk

Adopting Landlock opportunistically is the tracked follow-up in #390.


Verification

cargo test --workspace --all-targets --locked   2133 passed, 0 failed
cargo clippy --workspace --all-targets --locked -- -D warnings   clean
cargo fmt --all -- --check                      clean

The enforcement suite itself cannot run locally (needs bubblewrap, and is Linux-only), so CI is the check that matters here — that is the point of the change.

A grant can outlive the proxy that backs it: the session's proxy dies and
takes its socket file with it, while the grant is still attached to the next
command. bwrap was then asked to bind a source that no longer exists, refused
to start, and the caller got the generic

    blocked by the sandbox: writes are confined to the workspace, and
    .git/.forge are read-only inside it.

which points at the wrong thing entirely — nothing about that message
suggests the egress proxy died.

A vanished socket is now treated the way a missing relay already is: drop the
grant and run with no route out, which is what a dead proxy means. Still fails
closed, just legibly.

Fixes one of the two failures in #390. The other is a genuine confinement gap
and is left failing deliberately.
@github-actions
github-actions Bot enabled auto-merge (squash) August 18, 2026 14:03
…e gap

The reachability test asserted that no host Unix socket is reachable from
inside the sandbox. That is not what the mount model provides. `--ro-bind / /`
exposes every host path, and a read-only mount does not stop `connect()` — it
checks the inode, not MNT_READONLY — so only the directories masked with a
tmpfs are actually covered.

The test probed $HOME, which is not masked, so it asserted a guarantee forge
does not make and had never passed on Linux. It could not have been caught
locally either: it is #[cfg(target_os = "linux")], so on a macOS machine it
compiles out and the suite looks green.

Split into the two things that were conflated:

- The assertion now probes a masked directory (/run when writable, /tmp
  otherwise). That is the guarantee forge makes and the one that matters:
  docker.sock is root on the host, and $XDG_RUNTIME_DIR under /run/user/$UID
  is where ssh-agent and gpg-agent live. The in-workspace control is kept so it
  cannot pass vacuously.

- The $HOME case survives as an #[ignore]d test that reproduces the gap, so it
  stays executable rather than becoming a comment. Run with --ignored to check
  whether a kernel or a mask change has closed it.

Deliberately not silenced. SandboxPolicy now documents covered vs not covered
and why closing it needs a path-aware mechanism the mount namespace lacks:
seccomp-bpf cannot dereference the sockaddr_un pointer, seccomp_unotify(2)
says it must not be used for security policy decisions, and Landlock ABI 9's
LANDLOCK_ACCESS_FS_RESOLVE_UNIX is the right primitive but far newer than the
kernels forge runs on. Tracked in #390.
@mohitranka mohitranka changed the title fix(tools): drop a dead egress grant instead of failing to start fix(tools): dead egress grants, and the socket boundary forge actually has Aug 18, 2026
@github-actions
github-actions Bot merged commit 0b84962 into main Aug 18, 2026
8 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
…y has (#391)

* fix(tools): drop a dead egress grant instead of failing to start

A grant can outlive the proxy that backs it: the session's proxy dies and
takes its socket file with it, while the grant is still attached to the next
command. bwrap was then asked to bind a source that no longer exists, refused
to start, and the caller got the generic

    blocked by the sandbox: writes are confined to the workspace, and
    .git/.forge are read-only inside it.

which points at the wrong thing entirely — nothing about that message
suggests the egress proxy died.

A vanished socket is now treated the way a missing relay already is: drop the
grant and run with no route out, which is what a dead proxy means. Still fails
closed, just legibly.

Fixes one of the two failures in #390. The other is a genuine confinement gap
and is left failing deliberately.

* test(tools): assert the socket boundary forge actually has, record the gap

The reachability test asserted that no host Unix socket is reachable from
inside the sandbox. That is not what the mount model provides. `--ro-bind / /`
exposes every host path, and a read-only mount does not stop `connect()` — it
checks the inode, not MNT_READONLY — so only the directories masked with a
tmpfs are actually covered.

The test probed $HOME, which is not masked, so it asserted a guarantee forge
does not make and had never passed on Linux. It could not have been caught
locally either: it is #[cfg(target_os = "linux")], so on a macOS machine it
compiles out and the suite looks green.

Split into the two things that were conflated:

- The assertion now probes a masked directory (/run when writable, /tmp
  otherwise). That is the guarantee forge makes and the one that matters:
  docker.sock is root on the host, and $XDG_RUNTIME_DIR under /run/user/$UID
  is where ssh-agent and gpg-agent live. The in-workspace control is kept so it
  cannot pass vacuously.

- The $HOME case survives as an #[ignore]d test that reproduces the gap, so it
  stays executable rather than becoming a comment. Run with --ignored to check
  whether a kernel or a mask change has closed it.

Deliberately not silenced. SandboxPolicy now documents covered vs not covered
and why closing it needs a path-aware mechanism the mount namespace lacks:
seccomp-bpf cannot dereference the sockaddr_un pointer, seccomp_unotify(2)
says it must not be used for security policy decisions, and Landlock ABI 9's
LANDLOCK_ACCESS_FS_RESOLVE_UNIX is the right primitive but far newer than the
kernels forge runs on. Tracked in #390.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…y has (#391)

* fix(tools): drop a dead egress grant instead of failing to start

A grant can outlive the proxy that backs it: the session's proxy dies and
takes its socket file with it, while the grant is still attached to the next
command. bwrap was then asked to bind a source that no longer exists, refused
to start, and the caller got the generic

    blocked by the sandbox: writes are confined to the workspace, and
    .git/.forge are read-only inside it.

which points at the wrong thing entirely — nothing about that message
suggests the egress proxy died.

A vanished socket is now treated the way a missing relay already is: drop the
grant and run with no route out, which is what a dead proxy means. Still fails
closed, just legibly.

Fixes one of the two failures in #390. The other is a genuine confinement gap
and is left failing deliberately.

* test(tools): assert the socket boundary forge actually has, record the gap

The reachability test asserted that no host Unix socket is reachable from
inside the sandbox. That is not what the mount model provides. `--ro-bind / /`
exposes every host path, and a read-only mount does not stop `connect()` — it
checks the inode, not MNT_READONLY — so only the directories masked with a
tmpfs are actually covered.

The test probed $HOME, which is not masked, so it asserted a guarantee forge
does not make and had never passed on Linux. It could not have been caught
locally either: it is #[cfg(target_os = "linux")], so on a macOS machine it
compiles out and the suite looks green.

Split into the two things that were conflated:

- The assertion now probes a masked directory (/run when writable, /tmp
  otherwise). That is the guarantee forge makes and the one that matters:
  docker.sock is root on the host, and $XDG_RUNTIME_DIR under /run/user/$UID
  is where ssh-agent and gpg-agent live. The in-workspace control is kept so it
  cannot pass vacuously.

- The $HOME case survives as an #[ignore]d test that reproduces the gap, so it
  stays executable rather than becoming a comment. Run with --ignored to check
  whether a kernel or a mask change has closed it.

Deliberately not silenced. SandboxPolicy now documents covered vs not covered
and why closing it needs a path-aware mechanism the mount namespace lacks:
seccomp-bpf cannot dereference the sockaddr_un pointer, seccomp_unotify(2)
says it must not be used for security policy decisions, and Landlock ABI 9's
LANDLOCK_ACCESS_FS_RESOLVE_UNIX is the right primitive but far newer than the
kernels forge runs on. Tracked in #390.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…y has (#391)

* fix(tools): drop a dead egress grant instead of failing to start

A grant can outlive the proxy that backs it: the session's proxy dies and
takes its socket file with it, while the grant is still attached to the next
command. bwrap was then asked to bind a source that no longer exists, refused
to start, and the caller got the generic

    blocked by the sandbox: writes are confined to the workspace, and
    .git/.forge are read-only inside it.

which points at the wrong thing entirely — nothing about that message
suggests the egress proxy died.

A vanished socket is now treated the way a missing relay already is: drop the
grant and run with no route out, which is what a dead proxy means. Still fails
closed, just legibly.

Fixes one of the two failures in #390. The other is a genuine confinement gap
and is left failing deliberately.

* test(tools): assert the socket boundary forge actually has, record the gap

The reachability test asserted that no host Unix socket is reachable from
inside the sandbox. That is not what the mount model provides. `--ro-bind / /`
exposes every host path, and a read-only mount does not stop `connect()` — it
checks the inode, not MNT_READONLY — so only the directories masked with a
tmpfs are actually covered.

The test probed $HOME, which is not masked, so it asserted a guarantee forge
does not make and had never passed on Linux. It could not have been caught
locally either: it is #[cfg(target_os = "linux")], so on a macOS machine it
compiles out and the suite looks green.

Split into the two things that were conflated:

- The assertion now probes a masked directory (/run when writable, /tmp
  otherwise). That is the guarantee forge makes and the one that matters:
  docker.sock is root on the host, and $XDG_RUNTIME_DIR under /run/user/$UID
  is where ssh-agent and gpg-agent live. The in-workspace control is kept so it
  cannot pass vacuously.

- The $HOME case survives as an #[ignore]d test that reproduces the gap, so it
  stays executable rather than becoming a comment. Run with --ignored to check
  whether a kernel or a mask change has closed it.

Deliberately not silenced. SandboxPolicy now documents covered vs not covered
and why closing it needs a path-aware mechanism the mount namespace lacks:
seccomp-bpf cannot dereference the sockaddr_un pointer, seccomp_unotify(2)
says it must not be used for security policy decisions, and Landlock ABI 9's
LANDLOCK_ACCESS_FS_RESOLVE_UNIX is the right primitive but far newer than the
kernels forge runs on. Tracked in #390.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandbox: pathname Unix sockets outside /run and /tmp are reachable (needs Landlock RESOLVE_UNIX)

1 participant