🛡️ Sentinel: Fix incomplete IPv4 validation in NetworkUtils (#452)

Fixes incomplete IPv4 validation - adds bounds checking for p3 and p4 octets to prevent edge-case bypasses like '192.168.evil.com'.
This commit is contained in:
Yu-ga
2026-04-05 21:34:47 +09:00
committed by GitHub
parent e6a111a85c
commit e7f6a95e21
@@ -34,6 +34,10 @@ object NetworkUtils {
if (ipv4Parts.size == 4) {
val p1 = ipv4Parts[0].toIntOrNull() ?: return false
val p2 = ipv4Parts[1].toIntOrNull() ?: return false
val p3 = ipv4Parts[2].toIntOrNull() ?: return false
val p4 = ipv4Parts[3].toIntOrNull() ?: return false
if (p1 !in 0..255 || p2 !in 0..255 || p3 !in 0..255 || p4 !in 0..255) return false
if (p1 == 127) return true // Loopback: 127.x.x.x
if (p1 == 10) return true // Class A Private: 10.x.x.x