Sudo Git Privilege Escalation
Sudo git is vulnerable to privilege escalation.
Last updated
Sudo git is vulnerable to privilege escalation.
Last updated
If we can commit the git repository as root, we may be able to escalate privileges.
Create a Payload
Set Git Config
Commit the Repository
Before committing, we need to start a listener in local machine.
Then commit with sudo.
Now we should get a shell in local terminal.
If we can apply the patch for the git repository, we can update the content of arbitrary file.
Assume we are currently "user1" user then we want to escalate to be "user2". First we create a new SSH key.
New SSH keys (private/public) are generated under /home/user1
.
Next, add the content of id_rsa.pub
into authorized_keys.
.
Then create a patch.
After that, replace the name “user1” with “user2” in the patch file.
Now we can apply the patch as root. This command update the target user’s ("user2") authorization_keys
to allow us to login with SSH key as "user2".