Repository navigation
fix(sandbox2): admit inet and netlink in the none-box seal and bring lo up - #1883
Conversation
The none-box socket-family filter (SocketSeal::Full) previously admitted only AF_UNIX, refusing AF_INET and AF_INET6 with EAFNOSUPPORT. A fresh network namespace already holds only lo, so admitting the inet families the namespace confines does not weaken the seal — it lets the box use its own loopback, which was the reported defect: a --network none box could not open AF_INET/AF_INET6 sockets at all. The filter now admits AF_UNIX, AF_INET, AF_INET6, and AF_NETLINK (the same set the confined-families seal admits, minus AF_PACKET which stays refused by the missing CAP_NET_RAW per NET-083). AF_VSOCK remains refused. Additionally, the pre-exec closure now brings lo up before dropping CAP_NET_ADMIN, since a none box has no provider to do this from outside (the networked path does it in switch.rs:207). This is best-effort: a box whose lo stays down still runs, just without loopback. The integration test's C probe now asserts AF_INET/AF_INET6 sockets succeed, a bind-and-connect on 127.0.0.1 succeeds, a connect to a non-loopback address fails with ENETUNREACH, and AF_VSOCK still fails with EAFNOSUPPORT. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthroughThe none-plan socket seal now allows Unix, IPv4, IPv6, and netlink sockets. The Linux exec path attempts to enable loopback before dropping box credentials. Tests check socket creation and network reachability. ChangesNone-plan network behavior
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant ExecPath
participant bring_lo_up
participant LoopbackInterface
participant BoxProcess
ExecPath->>bring_lo_up: attempt loopback setup
bring_lo_up->>LoopbackInterface: query and set interface flags
ExecPath->>BoxProcess: take credentials and continue execution
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change is mergeable after normal checks, including the root integration probe where that environment is available. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
A rabbit checks the loopback light, Comment |
…lo stays down The relaxed none seal admits inet, inet6 and netlink only because the box's own network namespace confines them. Make that explicit and fail closed: SocketSeal::in_netns falls back to a new unix-only seal wherever the box is not in a fresh namespace of its own. The launch passes its unshare decision, and the nsenter shim passes whether its join set includes the box's netns. bring_lo_up now runs only in a fresh netns and returns its error. The closure appends a lo-down line to its report, and the daemon logs it at warn. The report watcher now reads every line, so the appended line does not replace the cover line.
|
/review |
|
Approved: 1 finding, none above this repo's threshold at Nothing to do. Clobber: none. |
There was a problem hiding this comment.
Approved at fd064dc: minimal-review approved at head, 0 open threads, all lanes green.
Summary
A
--network nonebox could not openAF_INET/AF_INET6sockets, making its own loopback (127.0.0.1) unusable. The none-box socket-family filter (SocketSeal::Full) admitted onlyAF_UNIXand refusedAF_INET/AF_INET6withEAFNOSUPPORT.Fix
build_socket_family_filter(crates/sandbox2/src/lib.rs): thenoneseal now admitsAF_UNIX,AF_INET,AF_INET6, andAF_NETLINK— the same set the confined-families seal admits, minusAF_PACKET(which stays refused by the missingCAP_NET_RAWno box holds, per NET-083).AF_VSOCKremains refused. A fresh network namespace already holds onlylo, so admitting the inet families the namespace confines does not weaken the seal.bring_lo_up(new,crates/sandbox2/src/lib.rs): the pre-exec closure now bringsloup before droppingCAP_NET_ADMIN, since a none box has no provider to do this from outside (the networked path does it inswitch.rs:207). Best-effort: a box whoselostays down still runs, just without loopback.SocketSeal::in_netns,crates/sandbox2/src/network.rs): the relaxednoneseal applies only when the box is really in a fresh network namespace of its own. The launch passes its unshare decision (socket_family_filter_for_plan(plan, isolate)), and the nsenter shim passes whether its join set includes the box's netns (injection_socket_filter). On any other path,nonefalls back to a newUnixOnlyseal (AF_UNIXalone). Unit tests cover both paths.lofailure is logged at warn:bring_lo_upruns only in a fresh netns, and its error is appended to the box's closure report aslo-down errno N. The daemon's report watcher now reads every line and logs that line atwarn.network.rs(SocketSeal::Full,NetPlan::none) andnsenter.rs(seal_none_box).none_plan_refuses_vsock_family,every_box_refuses_namespace_bypass_families); the integration test's C probe now assertsAF_INET/AF_INET6sockets succeed, a bind-and-connect on127.0.0.1succeeds, a connect to a non-loopback address fails withENETUNREACH, andAF_VSOCKstill fails withEAFNOSUPPORT.Verification
cargo fmt --all --check— passescargo clippy --workspace --locked— passes (only pre-existing warnings in unrelated crates)cargo build --workspace --locked— passescargo test -p sandbox2 --lib— 47 passed, 0 failed (includes the two modified unit tests)Follow-up
AF_NETLINKtoNETLINK_ROUTEin both seals (seccomp check onsocket()'s protocol argument, test thatNETLINK_AUDITis refused): https://github.com/gominimal/inbox/issues/849Routing-Key: inbox-route/I_kwDOSUhdos8AAAABUwzE8g
Summary by CodeRabbit