The impact caused by java deserialization is huge, now let’s analyze the remote dns access caused by java’s own chain;
In this blog post, I will try to clear up some doubts about deserialization vulnerability, and hope to reduce the condition of vulnerability exploitation by using existing tools. And I will focus on Java deserialization vulnerability research, but the same concept also applies to other languages. I will also focus on command execution vulnerabilities to keep the use simple.
Serialization is actually the state of the object at a certain time, that is, the state of the persistent object at that time; deserialization is to unfreeze the state of the object.If an attacker can affect variables and program objects in memory, they can affect the code flow that uses them.This is similar to the PHP deserialization;In Java, a serializable class can define a method called ‘readObject’ to perform special processing during deserialization (such as backward compatibility). This method can also be used for events that respond to the deserialization of objects of this class.
ok!First,we can see the getObject class in the URLDNS.java;So we will see that;
1 | URLStreamHandler handler = new URLDNS.SilentURLStreamHandler(); |
1 | HashMap ht = new HashMap(); |
1 | URL u = new URL((URL)null, url, handler); |
1 | ht.put(u, url); |
we can see that the handler is the URLStreamHandler and the ht is the HashMap;So we can see that;It uses the put function in the HashMap class .So we can see that;
1 | public V put(K key, V value) { |
We can see the put function;It uses the putVal function;So we can see that;The hash function is the flow;
1 | static final int hash(Object key) { |
it return the int;We can see that it use the function of key.hashCode;So we can see;The key is the :
1 | URL u = new URL((URL)null, url, handler); |
so we can see the hashCode function in the URL class;
1 | public synchronized int hashCode() { |
We can see that if the hashCode is not -1;we can use the function of hashCode in URLStreamHandler class;
1 | protected int hashCode(URL u) { |
We can see that the function of the corresponding function is to return the corresponding protocol; then we enter the getHostAddress method;
1 | protected synchronized InetAddress getHostAddress(URL u) { |
Enter the corresponding method here to trace; obviously we can pass judgments such as if; find that the getByName method is finally called, and check it;
This is equivalent to a dns request to confirm the ip address of the host;
The result is;
This vulnerability has no major harm, but it is mostly used to verify the existence of deserialization vulnerabilities; because this vulnerability does not use external references, it is the jdk itself, so it can often be used to verify the existence of deserialization; for follow-up Attack pavement;
This is a relatively simple chain. Let’s analyze it hand in hand first, and I will continue to analyze the complex chain later