Sudo Curl Privilege Escalation
The sudo curl
command might be vulnerable to privilege escalation (PrivEsc).
Investigation
If current user is allowed to execute the command above as root privilege, we can read arbitrary files in the target system or can add our SSH key in the root home directory by abusing the asterisk (*
).
I found this setting on Robots room on TryHackMe.
Exploit
Option 1. Read Files
As above, we can read the content of the /etc/shadow
as root.
Option 2. Add SSH Key
We can also add our SSH public key to /root/.ssh/authorized_keys
.
First, generate SSH keys in our local machine:
Next, in target machine, write the content of this public key:
Now, we can write this content to /root/.ssh/authorized_keys
via curl
:
By this, we can login SSH as root, using our private key: