Java Detect SSRF: How to detect 0177.1

455 Views Asked by At

I want to detect SSRF by validation if a host is localhost. But I cannot detect the addresses "0177.1" as localhost.

I tried this code to detect if a host is a localhost.

public static boolean isLocalAddress(InetAddress address) {
    if (address.isAnyLocalAddress() || address.isLoopbackAddress()) {
        return true;
    }
    try {
        return NetworkInterface.getByInetAddress(address) != null;
    } catch (SocketException e) {
        return false;
    }
}

I have tried it with many addresses and it detects all of them except "0177.1".

0

There are 0 best solutions below