8000 fix(sandbox2): admit inet and netlink in the none-box seal and bring lo up by gominimal-aw-bot[bot] · Pull Request #1883 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(sandbox2): admit inet and netlink in the none-box seal and bring lo up - #1883

Merged
norrietaylor merged 2 commits into
mainfrom
inbox-patch/issue-819-none-box-loopback-41e4f80fe29341de
Oct 4, 2026
Merged

norrietaylor merged 2 commits into
mainfrom
inbox-patch/issue-819-none-box-loopback-41e4f80fe29341de

Conversation

@gominimal-aw-bot
@gominimal-aw-bot gominimal-aw-bot Bot commented Oct 3, 2026 •
Copy link
Copy Markdown
Contributor

Summary

A --network none box could not open AF_INET/AF_INET6 sockets, making its own loopback (127.0.0.1) unusable. The none-box socket-family filter (SocketSeal::Full) admitted only AF_UNIX and refused AF_INET/AF_INET6 with EAFNOSUPPORT.

Fix

  • build_socket_family_filter (crates/sandbox2/src/lib.rs): the none seal 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 no box holds, per NET-083). AF_VSOCK remains refused. A fresh network namespace already holds only lo, 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 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). Best-effort: a box whose lo stays down still runs, just without loopback.
  • Fail-closed gate (SocketSeal::in_netns, crates/sandbox2/src/network.rs): the relaxed none seal 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, none falls back to a new UnixOnly seal (AF_UNIX alone). Unit tests cover both paths.
  • lo failure is logged at warn: bring_lo_up runs only in a fresh netns, and its error is appended to the box's closure report as lo-down errno N. The daemon's report watcher now reads every line and logs that line at warn.
  • Doc comments updated in network.rs (SocketSeal::Full, NetPlan::none) and nsenter.rs (seal_none_box).
  • Tests: unit tests updated (none_plan_refuses_vsock_family, every_box_refuses_namespace_bypass_families); 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.

Verification

  • cargo fmt --all --check — passes
  • cargo clippy --workspace --locked — passes (only pre-existing warnings in unrelated crates)
  • cargo build --workspace --locked — passes
  • cargo test -p sandbox2 --lib — 47 passed, 0 failed (includes the two modified unit tests)

Follow-up

Routing-Key: inbox-route/I_kwDOSUhdos8AAAABUwzE8g

Summary by CodeRabbit

  • New Features
    • Sandboxed applications can now create IPv4 and IPv6 sockets, and loopback connections work where supported.
  • Bug Fixes
    • Network restrictions continue to block connections to external addresses when a sandbox has no network access.
    • Full network access now permits local and internet socket families confined to the sandbox, while still refusing socket families that could bypass network isolation.

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>
@gominimal-aw-bot
gominimal-aw-bot Bot requested a review from a team as a code owner October 3, 2026 10:22
@gominimal-aw-bot gominimal-aw-bot Bot added the agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. label Oct 3, 2026
@coderabbitai
coderabbitai Bot commented Oct 3, 2026 •
Copy link
Copy Markdown
Contributor

Review in Change Stack →

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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: b98cc11b-326 8000 d-4d1d-8497-ac1828621f55
📥 Commits

Reviewing files that changed from the base of the PR and between 3bf6b09 and 61ba9cf.

📒 Files selected for processing (4)
  • crates/minimald/src/nsenter.rs
  • crates/minimald/tests/netns_root_integration.rs
  • crates/sandbox2/src/lib.rs
  • crates/sandbox2/src/network.rs

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.


📝 Walkthrough

Walkthrough

The 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.

Changes

None-plan network behavior

Layer / File(s) Summary
Socket-family policy and checks
crates/sandbox2/src/network.rs, crates/sandbox2/src/lib.rs, crates/minimald/src/nsenter.rs
The none seal allows Unix, IPv4, IPv6, and netlink socket families. Tests check native and compat socket filters and refusal of unlisted families, including vsock and packet sockets.
Best-effort loopback setup
crates/sandbox2/src/lib.rs
The Linux exec path attempts to bring lo up before taking box credentials. Socket and flag-query failures do not stop execution.
Network namespace integration checks
crates/minimald/tests/netns_root_integration.rs
The probe checks IPv4 and IPv6 socket creation, successful loopback TCP connectivity, and an external connection failure with ENETUNREACH. Attach mode checks IPv4 socket creation.

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
Loading

Suggested reviewers: norrietaylor

Merge Risk: ⚪ Minimal · up to 61ba9

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)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 4 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: the none-box seal admits inet and netlink socket families, and the change brings lo up.
Description check ✅ Passed The description explains the change and rationale, lists implementation details, and reports verification results. It omits the template’s Checklist section, but the description is otherwise complete.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the loopback light,
Then sockets hop through tunnels tight.
IPv4 and six join in the queue,
While outside paths say “not for you.”
The bunny nods: the tests came through.

Comment @coderabbitai help to get the list of available commands.

@gominimal-aw-bot gominimal-aw-bot Bot added the agent:resolve Consent gate: pr-conflict-resolver may rewrite this branch label Oct 3, 2026
…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.
@norrietaylor norrietaylor changed the title fix: admit inet/netlink families in none-box socket seal and bring lo up fix(sandbox2): admit inet and netlink in the none-box seal and bring lo up Oct 4, 2026
@norrietaylor
Copy link
Copy Markdown
Member

/review

@minimal-foundry
minimal-foundry Bot commented Oct 4, 2026 •
Copy link
Copy Markdown
Contributor

Approved: 1 finding, none above this repo's threshold at fd064dcecd7c.

Nothing to do.

Clobber: none. git log on the touched files shows the two head commits are the PR's own history (61ba9cf9 "admit inet/netlink... bring lo up" and fd064dce "gate the none-box seal on a fresh netns and warn when lo stays down"); the prior 53109047 T64 seal work is not reverted.

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — 1 finding, 1 inline.

8000
Comment thread crates/minimald/src/nsenter.rs Resolved
@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 4, 2026
@norrietaylor norrietaylor left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at fd064dc: minimal-review approved at head, 0 open threads, all lanes green.

@norrietaylor
norrietaylor added this pull request to the merge queue Oct 4, 2026
Merged via the queue into main with commit ab870b9 Oct 4, 2026
35 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/issue-819-none-box-loopback-41e4f80fe29341de branch October 4, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. agent:resolve Consent gate: pr-conflict-resolver may rewrite this branch review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0