Skip to content

fix(network): allow localhost connect on declared open ports in proxy mode - #1701

Open
Frankie-Xu wants to merge 6 commits into
nolabs-ai:mainfrom
Frankie-Xu:feat/1652-localhost-whitelist
Open

fix(network): allow localhost connect on declared open ports in proxy mode#1701
Frankie-Xu wants to merge 6 commits into
nolabs-ai:mainfrom
Frankie-Xu:feat/1652-localhost-whitelist

Conversation

@Frankie-Xu

Copy link
Copy Markdown
Contributor

Linked Issue

Refs #1652

This PR intentionally does not close #1652 — it delivers a focused Phase-1 subset (proxy-mode localhost connect on declared ports + CLI range flags). Port 0 cross-platform semantics and dynamic bind→connect remain for maintainer direction.

Summary

In Linux proxy mode, seccomp previously allowed localhost connect only to the nono proxy listener port. That blocked legitimate localhost IPC to ports the profile already declared via open_port / listen_port (and ranges), while macOS ProxyOnly already permitted those connects.

This change:

  • Allows loopback connect/sendto/sendmsg/sendmmsg to declared bind/open ports and ranges in the Linux supervisor (still fail-closed for non-loopback and undeclared ports).
  • Adds --open-port-range / --listen-port-range CLI flags (with allow-port-range / allow-bind-range aliases) matching existing profile keys.
  • Adds CapabilitySet::merged_localhost_port_ranges() as a pure merge helper over client-provided grants (no library policy).

Agent Disclosure

This PR was prepared by an AI coding agent on behalf of Frankie-Xu.

Consulted:

  • AGENTS.md / CONTRIBUTING.md (library vs CLI boundary, DCO, unwrap policy)
  • Issue Improve support for localhost whitelisting #1652 discussion (Phase-1 plan; seeking direction on port 0 / dynamic tracking)
  • crates/nono-cli/src/exec_strategy/supervisor_linux.rs (decide_network_notification)
  • crates/nono-cli/src/proxy_runtime.rs, cli.rs, capability_ext.rs, supervised_runtime.rs
  • crates/nono-cli/src/tool-sandbox/platform/{linux,macos}.rs
  • crates/nono/src/capability.rs (grant merge helper only)

Confirms compliance with repository coding and security requirements for this scoped change.

Test Plan

  • make fmt-check
  • make clippy
  • make test / make ci locally (macOS); Linux supervisor unit tests for declared-port connect allow/deny
  • scripts/test-list-aliases.sh / scripts/lint-docs.sh
  • CI on GitHub (fork PRs need maintainer workflow approval)

Checklist

  • An issue exists and is linked above
  • All commits are signed-off, using DCO
  • All new code follows the project's coding standards (CLAUDE.md) and is covered by tests
  • Public-facing changes are paired with documentation updates (CLI --help / alias inventory; no broader docs change required for this subset)

Agent Compliance Check

  • I am not prohibited from contributing under this policy
  • An issue already exists
  • I disclosed that I am an agent in the issue discussion
  • I described my intent and approach in the issue discussion
  • I reviewed repository coding and security rules for the affected area
  • I provided required attribution for reused or adapted code
  • I did not use forbidden patterns such as unwrap/expect
  • I used NonoError where required
  • I validated and canonicalized all relevant paths (N/A for this network-port change; no new path grants)
  • This PR matches the approved or disclosed issue scope (focused Phase-1 subset; larger items explicitly deferred)

Made with Cursor

@Frankie-Xu

Copy link
Copy Markdown
Contributor Author

CI approve requested — fork PR needs maintainer workflow approval. Local make ci is green on macOS (clippy/fmt/tests/audit/alias+docs lints); Linux supervisor unit coverage is included in the suite.

@github-actions github-actions Bot added bug Something isn't working nono nono-cli size/medium labels Aug 21, 2026
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

PR Review Summary

Size

Metric Value
Lines added +547
Lines removed -25
Total changed 572
Classification Large (> 300 lines)

Affected crates

  • crates/nono (core library) — careful review required. This is the security-critical sandbox primitive. A bug here bypasses OS-level isolation for every downstream user.
  • crates/nono-cli — CLI changes. Verify argument parsing, flag documentation, and UX behaviour across supported platforms.

Blast radius — Contained

This PR touches: source code


Updated automatically on each push to this PR.

@nogent-nolabs-ai nogent-nolabs-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nogent code review

1 medium severity bug found: --listen-port-range is ignored when building the capability set.

Automated code + security review. CI already covers clippy, rustfmt, tests, cargo-audit and commit-lint.

Comment thread crates/nono-cli/src/capability_ext.rs
@Frankie-Xu
Frankie-Xu marked this pull request as draft August 21, 2026 10:56
@Frankie-Xu

Copy link
Copy Markdown
Contributor Author

Converting to draft to honor the 1–2 open PR limit. While it's a draft I'll fix the --listen-port-range bug nogent found (parsed into allow_bind_range but never added to the capability set). No action needed from reviewers now.

Frankie-Xu and others added 6 commits August 26, 2026 17:48
… mode

Align Linux seccomp supervisor with macOS ProxyOnly semantics for pre-declared
open_port and listen_port grants, merge single-port open_port into seccomp
allowlists, and add --open-port-range / --listen-port-range CLI flags.

Signed-off-by: Frankie-Xu <frankie-xu@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Frankie-Xu <92643488+Frankie-Xu@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Frankie-Xu <92643488+Frankie-Xu@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
CLI --listen-port-range and profile listen_port_range were parsed but
never added to CapabilitySet, so Landlock/Seatbelt/seccomp ignored the
declared bind grant. Store them as bind-only tcp_bind_port_ranges
(mechanism, not policy) and switch remaining chunks_exact(2) call sites
to as_chunks for Clippy 1.98.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Frankie-Xu <92643488+Frankie-Xu@users.noreply.github.com>
Loopback is required for connect in proxy mode, not for bind. Servers
typically listen on 0.0.0.0, which is not loopback, so requiring it
would break listen_port.

Signed-off-by: Frankie-Xu <92643488+Frankie-Xu@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Bare cat looks up PATH, which other unit tests temporarily poison.
That left provider-stdin.json empty under the parallel test runner.

Signed-off-by: Frankie-Xu <92643488+Frankie-Xu@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@Frankie-Xu
Frankie-Xu marked this pull request as ready for review August 26, 2026 10:09
@Frankie-Xu
Frankie-Xu force-pushed the feat/1652-localhost-whitelist branch from a2d8319 to 2d37486 Compare August 26, 2026 10:09

@nogent-nolabs-ai nogent-nolabs-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nogent code review

No blocking issues or findings identified; the network-port sandbox extension is fully covered by tests and correctly implemented.

Automated code + security review. CI already covers clippy, rustfmt, tests, cargo-audit and commit-lint.

Comment thread crates/nono-cli/src/exec_strategy/supervisor_linux.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve support for localhost whitelisting

1 participant