fix: handle cross-mount resolv.conf symlinks in sandbox#32
Merged
Conversation
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/sandbox/linux.go">
<violation number="1" location="internal/sandbox/linux.go:464">
P2: This logic unconditionally mounts a tmpfs over any directory found to be on a different device than root. If `resolv.conf` targets a path within `/dev` or `/proc` (e.g., `/dev/shm/resolv.conf`), this will overwrite the critical `--dev-bind` or `--proc` mounts established earlier (lines 438-439) with an empty tmpfs, breaking the sandbox's device access or process visibility.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/sandbox/linux.go">
<violation number="1" location="internal/sandbox/linux.go:453">
P2: Exclude `/run` and `/sys` from the special mount logic when `defaultDenyRead` is enabled, as they are already explicitly bound.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/sandbox/linux.go">
<violation number="1" location="internal/sandbox/linux.go:456">
P2: Disabling this fix in `defaultDenyRead` mode breaks DNS on systems (like WSL) where `resolv.conf` points to a path not in `GetDefaultReadablePaths` (e.g., `/mnt/wsl`).
Instead of disabling the fix globally for `defaultDenyRead`, you should allow it but specifically exclude paths that are already bound in that mode (like `/run` and `/sys`). This ensures `resolv.conf` works in both modes while avoiding overwritten binds.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
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
On WSL (and other systems where
/etc/resolv.confis a symlink to a path on a separate mount point), DNS-related reads fail inside the sandbox. This requires fixes at two layers: bwrap (mount setup) and Landlock (filesystem access control).The root cause is that bwrap's
--ro-bind / /is a non-recursive bind mount that doesn't capture child mount points. On WSL,/etc/resolv.conf -> /mnt/wsl/resolv.confbecomes a dangling symlink in the sandbox because/mnt/wsl(a 9p mount from the WSL hypervisor) isn't included. Additionally, even with the file made available via mounts, Landlock blocks reads to the resolved path since/mnt/wslisn't in the allowed system paths.Changes
linux.go):sameDevice+intermediaryDirshelpers; walk from/to target's parent,--tmpfsat the mount boundary,--dirfor deeper subdirs,--ro-bindthe target filelinux_landlock.go): add read rule for the resolved symlink target's parent directory