Skip to content

nstun: block cloud-local service destinations#282

Open
carrerasdarren-cell wants to merge 1 commit into
google:masterfrom
carrerasdarren-cell:security/block-cloud-local-services-20260716
Open

nstun: block cloud-local service destinations#282
carrerasdarren-cell wants to merge 1 commit into
google:masterfrom
carrerasdarren-cell:security/block-cloud-local-services-20260716

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown

Summary

  • reject IPv4 link-local destinations in nstun's authoritative SSRF gate
  • reject AWS's reserved fd00:ec2::/32 instance-local service range
  • add focused boundary tests for blocked and adjacent addresses

Rationale

nstun creates host-side sockets for destinations requested by the jailed process. Its destination gate already rejects loopback, broadcast, IPv6 link-local, and IPv6 site-local addresses, but it permits IPv4 169.254.0.0/16 and AWS's IPv6 instance-local service range.

That leaves cloud metadata and other host-provided services reachable through the parent-side network bridge. Common IMDS endpoints include 169.254.169.254 and [fd00:ec2::254]. AWS reserves the full fd00:ec2::/32 range for instance-local services.

The IPv4 check blocks the RFC 3927 link-local range, matching the existing IPv6 link-local policy. The IPv6 check is limited to AWS's documented reserved range; neighboring ULA space remains allowed.

Testing

  • make nstun_ip_test
  • full Linux build with the project's -Werror flags
  • focused boundary test under AddressSanitizer and UndefinedBehaviorSanitizer
  • privileged local integration proof with temporary VM-only addresses:
    • parent could reach simulated 169.254.169.254; jailed request was blocked
    • adjacent IPv4 control remained reachable from the jail
    • parent could reach simulated fd00:ec2::254; jailed request was blocked
    • fd00:ec3::254 remained reachable from the jail
  • no-network nsjail smoke command
  • git diff --check

No real cloud metadata endpoint or third-party service was queried during testing.

@google-cla

google-cla Bot commented Jul 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.

@carrerasdarren-cell

Copy link
Copy Markdown
Author

@googlebot rescan

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