Node.js - Insecure Deserialization : DVNA
Lab :
Vulnerability name :
A8 - Insecure Deserialization
Deployment :
docker option
Networking :
Vulnerable App IP: 172.17.0.2
Kali machine IP : 172.17.0.1
Note:
I was using docker container, if you want to check container IP you can use the below command
Understanding Application Behaviour :
The vulnerable function located at this url
we can see that the application is sharing with us the json data format as below
copying json data to a file & uploading that file to the application to see how the app is handling the request
the app is redirecting us to the product page, and if we follow the redirection we can see that the app is printing the json data that we uploaded
Triggering the Vulnerability :
I tried first to inject the following payload which just execute remote command "ls" to see if the application would print the output of the command in the table
but got an error message
However, it might be that the app executed our command successfully but it's not processing the output correctly, or we are in a blind injection situation, so I tried another method to check for blind Injection , one example can be using ping
command, and ask the app to ping our host by forwarding this payload :
and capturing icmp
packets on our host using this command
and after we uploading the ping payload we can see that the app is successfully executed our command!
Reverse Shell - BASH TCP :
hosting the following shell.sh using python SimpleHTTPServer
passing the following payload to the app ( the payload just curl the shell.sh file, to check that the application can fetch the file correctly )
and we can see that the app fetched our file
now passing this payload to first fetch the file (curl
) & execute it (by piping it to bash
)
and we got the shell on our host!
Reverse Shell - Node.js :
for a stable shell, we can rely on JS
reverse shell, I've tried using the nodejsshell.py
script (https://github.com/ajinabraham/Node.Js-Security-Course/blob/master/nodejsshell.py) which generates the JS
payload for us
Running the script
now we can place the revers shell JS
payload inside the function body
of the serialized payload (as described in this article :https://opsecx.com/index.php/2017/02/08/exploiting-node-js-deserialization-bug-for-remote-code-execution/)
the final payload would be like this
and we got the shell !
Last updated
Was this helpful?