Repository navigation
🔒 fix(netguard): deny IPv6 cloud-metadata (fd00:ec2::254) even under allow-private-sinks (SEC-IMDS6) - #168
Conversation
…allow-private-sinks (SEC-IMDS6)
…254%zone can't bypass allow-private-sinks (SEC-IMDS6 F1)
There was a problem hiding this comment.
Pull request overview
Closes an SSRF netguard gap where enabling --allow-private-sinks unintentionally allowed the AWS IPv6 IMDS endpoint (fd00:ec2::254) because it is IPv6 ULA (IsPrivate()==true). The fix enforces an unconditional deny for that single /128 at both admission-time validation and dial-time enforcement, including a bypass fix for zoned literals (e.g. %eth0).
Changes:
- Add an unconditional deny-list entry for
fd00:ec2::254/128in admission (internal/validation/endpoint_guard.go) and normalize away IPv6 zones before prefix matching. - Add an unconditional dial-time rejection for
fd00:ec2::254in netguard (internal/sink/netguard/dialer.go) using zone-stripped equality. - Add regression tests covering unzoned and zoned IPv6 IMDS literals under
--allow-private-sinks, while keeping generic ULA allow-cases green.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/validation/endpoint_guard.go | Denies fd00:ec2::254/128 unconditionally and strips zones before deny-prefix matching to prevent zoned-literal bypass. |
| internal/validation/allow_private_sinks_test.go | Extends admission test matrix to assert IPv6 IMDS (zoned + unzoned) remains denied even when private sinks are allowed. |
| internal/sink/netguard/dialer.go | Adds dial-time hard deny for fd00:ec2::254, comparing after zone normalization, ensuring enforcement even under opt-in. |
| internal/sink/netguard/allow_private_sinks_test.go | Extends dial-time test matrix to cover IPv6 IMDS (zoned + unzoned) under the opt-in. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|




SEC-IMDS6 (P2/P3) — IPv6 cloud-metadata SSRF gap under --allow-private-sinks
Surfaced by the 2026-08-02 /project-audit (security lens). The SSRF netguard denied the IPv4 metadata IP (
169.254.169.254) unconditionally but NOT the AWS IPv6 IMDS endpointfd00:ec2::254— which is IPv6-ULA (IsPrivate()==true) and thus ALLOWED once--allow-private-sinksis on, despite the control's own comment promising metadata is always denied.Fix
Deny
fd00:ec2::254(single/128) unconditionally at BOTH layers — admission (endpoint_guard.go) and dial-time (netguard/dialer.go) — regardless of the opt-in. Narrow carve-out: legitimate ULA sinks (e.g.fd00::1) stay allowed. Zone normalization (WithZone("")) applied before the check so a zoned formfd00:ec2::254%eth0can't bypass it (Prefix.Contains/equality are zone-sensitive).Review
Independent review caught a P1 on the first pass — the zoned form
fd00:ec2::254%eth0bypassed the deny; fixed and fresh-re-reviewed → APPROVE. The re-review verified the P1 is closed at both layers and no other representation (uppercase/expanded/IPv4-mapped) bypasses it (all canonicalize vianetip.ParseAddr). Regression cases (unzoned + zoned, opt-in on → denied) added to both test matrices; ULA-allowed cases still green. Gates green.