mirror of
https://github.com/yuga-hashimoto/openclaw-assistant.git
synced 2026-10-19 10:04:04 +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:
parent
e6a111a85c
commit
e7f6a95e21
1 changed files with 4 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue