Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

test(security): cover NAT64 encodings in TestIsRestrictedIP_IPv6 (fixes #4092) (#4263)

Ziyang Guo9fe7de2c00eb
diff --git a/internal/utils/security_test.go b/internal/utils/security_test.go
index 30e55628e..694eaec3d 100644
--- a/internal/utils/security_test.go
+++ b/internal/utils/security_test.go
@@ -273,6 +273,19 @@ func TestIsRestrictedIP_IPv6(t *testing.T) {
{"Teredo", "2001:0000:4136:e378:8000:63bf:3fff:fdd2", true, "Teredo"},
{"6to4 private", "2002:c0a8:0101::1", true, "6to4"},
{"6to4 public", "2002:0808:0808::1", false, ""},
+ // NAT64 well-known prefix (64:ff9b::/96, RFC 6052) wrapping the
+ // cloud-metadata address — regression for issue #4092.
+ {"NAT64 metadata", "64:ff9b::a9fe:a9fe", true, ""},
+ // NAT64 local-use prefix (64:ff9b:1::/48, RFC 8215) wrapping the
+ // cloud-metadata address — refused outright, never globally routable.
+ {"NAT64 local-use metadata", "64:ff9b:1::a9fe:a9fe", true, "NAT64"},
+ // NAT64 wrapping an RFC1918 private address: blocked via embedded payload.
+ {"NAT64 private payload", "64:ff9b::ac10:0a01", true, "NAT64"},
+ // NAT64 wrapping a loopback address: blocked via embedded payload.
+ {"NAT64 loopback payload", "64:ff9b::7f00:0001", true, "loopback"},
+ // NAT64 wrapping a genuinely public address: the payload decides, not
+ // the wrapper, so this must pass.
+ {"NAT64 public payload", "64:ff9b::0808:0808", false, ""},
{"public IPv6", "2001:4860:4860::8888", false, ""},
}