caelum0x d8b8e09d1d fix(turnstile): close IPv4-compatible/NAT64/6to4 IPv6 SSRF bypass in upstream policy
UpstreamPolicy::is_public_v6 only decoded the IPv4-mapped IPv6 form
(::ffff:a.b.c.d). The three other standard encodings that embed a literal
IPv4 address — IPv4-compatible (::a.b.c.d), NAT64 (64:ff9b::/96), and 6to4
(2002::/16) — were not decoded, so a loopback/link-local/metadata/private
IPv4 address wrapped in one of those forms was treated as a public upstream
and approved for an admin-API tool's upstream_url, defeating the SSRF guard
this module's own doc comment exists for (a leaked admin token must not turn
Turnstile into an SSRF proxy). Ported the exact decode logic the sibling
Toolgate app's switchyard-egress::policy already uses for the identical
threat model. Proven with a regression test that failed pre-fix (confirmed
against real check_url calls) and passes post-fix; full workspace test
suite (73 tests) and clippy both clean, with the 3 pre-existing unrelated
clippy warnings confirmed present on main before this change too.
2026-11-06 00:11:13 +03:00
..