fix(native-sidecar): use one universal resolve-beneath walk for host-mount confinement#1670
Merged
Conversation
|
🚅 Deployed to the agentos-pr-1670 environment in agentos
🚅 Environment agentos-pr-1670 in rivet-frontend has no services deployed. |
…mount confinement Replace the Linux openat2(RESOLVE_BENEATH) path and the separate macOS cap-std fallback with a single portable resolve-beneath walker. gVisor/runsc (Rivet Compute) does not support openat2(RESOLVE_BENEATH), so a guest chdir/stat into a host mount returned ENOENT under runsc while passing under runc. The walker descends one component at a time with plain openat(2) (O_NOFOLLOW), keeps its own ancestor-fd stack for .., expands symlinks manually, and rejects absolute components/targets as escapes. - Delete src/macos_fs.rs and drop the cap-std dependency - Move the universal resolver into plugins/host_dir.rs as the confine module - Point filesystem.rs at crate::plugins::host_dir::confine - Document why openat2 is not used across the affected modules and AGENTS.md
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.
openat2(RESOLVE_BENEATH)path and the macOS cap-std fallback with one portable resolve-beneath walker (theconfinemodule inplugins/host_dir.rs) used on every platform, fixing gVisor/runsccreateSessionfailures (openat2(RESOLVE_BENEATH)is unsupported under runsc, so a guestchdir/statinto a host mount returnedENOENT).stat/existsuseresolve_parent_beneath+fstatat;chown/utimesusefchownat/utimensat(AT_SYMLINK_NOFOLLOW)on the anchored parent fd; search-only intermediate/parent dirs get anO_PATHtraversal-anchor fallback.chmodstays leaf-O_RDONLY(documented:fchmodathas noAT_SYMLINK_NOFOLLOW, so a read-free chmod can't be TOCTOU-safe).real_path/ancestor-symlink-follow escape), depth-bounded against a recursion DoS, with special-file rejection and partial-dest cleanup; the mapped-runtime existence checks are confined (no ancestor-symlink existence-bit leak);read_dirno longer swallows classification errors.src/macos_fs.rs, drops thecap-stddependency, and documents the confinement invariants incrates/CLAUDE.md+crates/native-sidecar/CLAUDE.md.