Check if an IP address is internal (loopback, private RFC 1918, link-local, or unspecified). This is a broader check than [`is_always_blocked_ip`] — it includes RFC 1918 private ranges (`10/8`, `172.16/12`, `192.168/16`), CGNAT (`100.64.0.0/10`, RFC 6598), other special-use ranges, and IPv6 ULA (`fc00::/7`) which are allowable via `allowed_ips` but blocked by default without one. Used by the pro
(ip: IpAddr)
| 166 | /// Used by the proxy's default SSRF path and the mechanistic mapper to detect |
| 167 | /// when `allowed_ips` should be populated in proposals. |
| 168 | pub fn is_internal_ip(ip: IpAddr) -> bool { |
| 169 | match ip { |
| 170 | IpAddr::V4(v4) => is_internal_v4(v4), |
| 171 | IpAddr::V6(v6) => { |
| 172 | if v6.is_loopback() || v6.is_unspecified() { |
| 173 | return true; |
| 174 | } |
| 175 | if is_link_local_ip(IpAddr::V6(v6)) { |
| 176 | return true; |
| 177 | } |
| 178 | // fc00::/7 — IPv6 unique local addresses (ULA) |
| 179 | if (v6.segments()[0] & 0xfe00) == 0xfc00 { |
| 180 | return true; |
| 181 | } |
| 182 | // Check IPv4-mapped IPv6 (::ffff:x.x.x.x) |
| 183 | if let Some(v4) = v6.to_ipv4_mapped() { |
| 184 | return is_internal_v4(v4); |
| 185 | } |
| 186 | false |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /// IPv4 internal address check covering RFC 1918, CGNAT (RFC 6598), and other |
| 192 | /// special-use ranges that should never be reachable from sandbox egress. |
no test coverage detected