fix: isolate /run with tmpfs and recreate /var/run symlinks in sandbox#54
Merged
fix: isolate /run with tmpfs and recreate /var/run symlinks in sandbox#54
Conversation
Previously, buildDenyByDefaultMounts bind-mounted the entire host /run read-only, then overlaid /run/user with a tmpfs for D-Bus isolation. This left host sockets (Docker, Podman, containerd, libvirt, etc.) accessible inside the sandbox. Unix socket connections bypass filesystem read-only restrictions, so any exposed socket with matching permissions allowed full sandbox escape (e.g., docker run with host filesystem mounts). Replace the blanket --ro-bind /run /run with --tmpfs /run (allowlist approach), selectively mounting only: - /run/systemd/resolve/* when /etc/resolv.conf is a symlink into /run - /run/user/<uid>/bus for the filtered D-Bus proxy socket This matches the existing SSH key protection pattern (--ro-bind /dev/null over sensitive files) but is more robust: unknown sockets are excluded by default rather than requiring explicit deny rules.
On modern Linux distros, /var/run is a symlink to /run and /var/lock is a symlink to /run/lock. Many programs (virsh, systemctl, etc.) hardcode /var/run paths. The sandbox already recreates symlinks for /bin, /sbin, /lib, /lib64 but was missing /var, causing programs to fail with "No such file or directory" even when /run paths were correctly configured. Fixes #53
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.
Summary
This PR includes two fixes for
/runhandling in the Linux sandbox:Isolate
/runwith tmpfs to prevent sandbox escape (d1afb06) - Replace blanket--ro-bind /runwith--tmpfs /runand selectively mount only what's needed. Previously, host sockets (Docker, Podman, containerd, libvirt) were accessible inside the sandbox, allowing full escape via Unix socket connections which bypass read-only mount restrictions.Recreate
/var/runand/var/locksymlinks (d7b3404) - On modern Linux distros,/var/run -> /runand/var/lock -> /run/lock. Many programs (virsh, systemctl, etc.) hardcode/var/runpaths and fail without these symlinks. Follows the same pattern already used for/bin -> usr/bin,/lib -> usr/lib, etc.Fixes #55
Fixes #53
Test plan
./greywall -- docker psfails to connect (socket no longer exposed)./greywall -- ls /var/run/resolves correctly inside sandbox./greywall -- virsh -c qemu:///system listconnects successfully (with libvirt allowRead/allowWrite config)make testpasses/var/runis a real directory (not a symlink) that no symlink is created