8000 nstun: reject unspecified SOCKS5 UDP relay endpoints by GovernableIntelligence · Pull Request #396 · google/nsjail · GitHub
[go: up one dir, main page]

Skip to content

nstun: reject unspecified SOCKS5 UDP relay endpoints - #396

Draft
GovernableIntelligence wants to merge 1 commit into
google:masterfrom
GovernableIntelligence:socks5-udp-relay-validation
Draft

GovernableIntelligence wants to merge 1 commit into
google:masterfrom
GovernableIntelligence:socks5-udp-relay-validation

Conversation

@GovernableIntelligence
Copy link
Copy Markdown

Summary

Reject successful IPv4 SOCKS5 UDP ASSOCIATE replies whose advertised relay address is unspecified (0.0.0.0) or whose relay port is zero. Validate the reply before allocating the UDP socket or draining queued guest datagrams, and use the existing association teardown on rejection.

Concrete relay endpoints remain supported, including explicit loopback, a relay IP distinct from the TCP proxy IP, and IPv4 relay transport for IPv6 guest destinations.

Reason for the guard

At baseline commit d1d9af34c61daf834b843d58100a108c7cc2c574, the negotiated IPv4 relay address and port were copied unchanged into later sendto() destinations. In a separate Linux 6.18.57 loopback-only namespace experiment, sendto() to 0.0.0.0 reached an owned listener bound to 127.0.0.1; IP_PKTINFO reported 127.0.0.1 as destination. That experiment motivates validating a successful server reply rather than relying on platform routing behavior.

Scope: This is endpoint/input hardening. The experiment did not establish unauthorized host-service access, guest control of the configured SOCKS proxy, a jail-boundary violation, or a sandbox escape.

Regression evidence

  • Pinned baseline: 6 valid relay controls passed; all 6 invalid relay cases demonstrated the pre-fix behavior (each allocated a UDP socket and attempted a send).
  • Patched source: 12/12 relay cases passed, repeated twice with identical results. All 6 rejected cases made zero socket or send attempts, released the association and control descriptor, and established a fresh association on retry without replaying stale queued data.
  • Sanitizers: all 12 relay cases passed with AddressSanitizer, UndefinedBehaviorSanitizer, and leak detection enabled.
  • Build and existing offline regressions: full build passed; 7 CLI cases, 4 nstun unit binaries, and the path-containment test passed (12 offline checks).
  • Integration exercise: a scratch integration with open PR nstun: prevent SOCKS5 UDP control-channel busy loops #387 resolved conflicts and passed both its control-reader target and all 12 relay cases. This is an integration exercise, not a merged or hosted result.

Not verified: Five namespace-dependent checks were blocked identically on baseline and patched builds: four failed with EPERM writing child UID maps and one failed with EPERM mounting tmpfs. They are environmental blocks, not passing tests. Public-network checks in the broader make test target were not run. PR-level hosted CI is pending.

Compatibility and upstream overlap

  • A SOCKS proxy that advertises 0.0.0.0 as shorthand for its UDP relay must instead return a concrete reachable address; a zero reply port is also rejected.
  • Explicit 127.0.0.1, a separate loopback relay, and a relay IP different from the TCP proxy IP remain valid.
  • Open PR nstun: prevent SOCKS5 UDP control-channel busy loops #387 improves control-reply framing but does not validate the successful IPv4 relay tuple. If it lands first, perform this guard after its complete reply parse.
  • Merged PR nstun: validate UDP reply peers #316's incoming relay-peer validation is unchanged.

Proposed against upstream master as a narrowly scoped guard with an accompanying relay regression harness. Author and committer: David Boyd. Commit: af73faf905f1dad34c63531e4f3afb92249a1f2b.

@google-cla
google-cla Bot commented Nov 17, 2026
Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0