Repository navigation
fix(tools): dead egress grants, and the socket boundary forge actually has - #391
Merged
Merged
Conversation
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.
…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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_invocationthen asked bwrap to--binda source that no longer exists:bwrap refused to start, so the command never ran, and the caller was handed the generic sandbox explanation:
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-netis 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 stopconnect()— it checks the inode, notMNT_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:
/runwhen the test can write there (the WSL2 job runs as root),/tmpotherwise. This is the guarantee forge makes and the one that matters:docker.sockis root on the host, and$XDG_RUNTIME_DIRunder/run/user/$UIDis where ssh-agent and gpg-agent live. The in-workspace control is kept so it cannot pass vacuously.$HOMEcase survives as an#[ignore]d test that reproduces the gap, so it stays executable rather than degrading into a comment.cargo test -- --ignoredchecks 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.SandboxPolicynow 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:
args[6]as scalar registers and cannot dereference thesockaddr_un *to read the pathseccomp_unotify(2): "must not be used to make security policy decisions about the system call, which would be inherently race-prone"LANDLOCK_ACCESS_FS_RESOLVE_UNIXconnect(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--ro-bind / /with an allowlist, which is a much larger change with real breakage riskAdopting Landlock opportunistically is the tracked follow-up in #390.
Verification
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.