mirror of
https://github.com/yuga-hashimoto/openclaw-assistant.git
synced 2026-08-14 07:02:02 +00:00
🛡️ 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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user