Skip to content

nstun: reject unspecified IPv4 guest sources - #368

Merged
robertswiecki merged 1 commit into
google:masterfrom
AdemVessell:fix/nstun-reject-unspecified-ipv4-source
Nov 20, 2026
Merged

robertswiecki merged 1 commit into
google:masterfrom
AdemVessell:fix/nstun-reject-unspecified-ipv4-source

Conversation

@AdemVessell

Copy link
Copy Markdown
Contributor

Summary

Reject IPv4 source 0.0.0.0 on the nstun guest TUN path.

Problem

The current source check accepts either the configured guest address or
0.0.0.0. A jailed process retaining CAP_NET_RAW can emit a source-zero
packet. Because nstun evaluates that actual source against GUEST_TO_HOST
rules, the packet can skip a source-qualified rule for the configured guest
and fall through to the default ALLOW action.

Fix

Require the source to equal ctx->guest_ip4, matching the point-to-point
interface configuration and the existing non-zero spoof handling.

Tests

  • configured guest source remains accepted;
  • a different non-zero source remains rejected;
  • source zero is rejected;
  • full nstun unit set and complete build pass;
  • an owned full-process nsjail replay blocks source zero after the patch.

Scope

This affects the opt-in nstun backend on current master when a workload
retains CAP_NET_RAW and policy uses a source selector. nstun is not present
in tag 3.6.

The TUN interface has one configured guest IPv4 address. Reject source 0.0.0.0 like any other source mismatch so raw packets cannot skip source-qualified GUEST_TO_HOST rules and fall through to the default allow action.

Add dispatch controls for the configured guest, a different non-zero source, and the unspecified source.
@AdemVessell

Copy link
Copy Markdown
Contributor Author

A quick follow-up on this nstun source-validation fix: the Docker workflow is still awaiting approval. Could a maintainer approve it and take a look when convenient? Happy to address any feedback. Thanks.

@robertswiecki

Copy link
Copy Markdown
Collaborator

Thank you!

@robertswiecki
robertswiecki merged commit f3f7e26 into google:master Nov 20, 2026
7 checks passed
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.

2 participants