The idea
Calla has a signed engagement against Quillon Analytics and a foothold on their reporting box as rowan, an
ordinary account. No root password, no obvious hole — but Quillon left the data team one convenience: rowan may
run the nightly backup, tar, as root with no password.
That is the whole way up. Escalation is often one line, and the line here is a backup
command — because tar can be told to run another program at a checkpoint, and sudo runs tar as root. You
will read the rule, abuse it with the real GTFObins tar escape, and end at uid=0.
Steps
-
The foothold, and the wall it stops at
You are on Calla's Kali box. The foothold is an SSH login on the reporting box at
10.0.1.20asrowan. Click Start to open a shell there, confirm who you are withid, then try the classic prize —/etc/shadow, the file of password hashes — and watch it refused. That wall is what the sudo rule will get you past.kali:~# ssh box
-
What the box lets you run as root
Before reaching for an exploit, read what you have already been given.
sudo -llists whatrowanmay run withsudo, as whom, and whether a password is asked. Read it as an attacker, not an admin: the question is not "what am I allowed to do" but "which of these can run a program I choose".A rule is only safe if the command it grants does one fixed thing and cannot launch another. Many cannot help it — an archiver, an editor, a pager and a dozen others all have a way to shell out, which is exactly what GTFObins catalogues.
kali:~# ssh box 'sudo -l'
-
The checkpoint that runs a command
tarcan print progress every so many records — a checkpoint — and--checkpoint-action=exec=…runs a command at each one. That is a legitimate feature (a progress hook), but run as root by sudo, the command it executes is root too.So you archive anything (
/dev/nullinto/dev/nulldoes nothing), ask for a checkpoint at the first record, and hand the action the command you actually want. To prove control cleanly, runid; swap it for/bin/shand the same line drops you into an interactive root shell.kali:~# ssh box 'sudo tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action="exec=id"'
-
Own the box
Root reads anything. Point the same escape at
/etc/shadow— the filerowanwas refused in step one — and read it as root. These hashes are the real loot: the material a cracking step feeds on, and proof the box is yours.kali:~# ssh box 'sudo tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action="exec=cat /etc/shadow"'
-
What Quillon's admin should change
Calla's finding is not "tar is dangerous" — tar is fine. It is that a NOPASSWD rule for a general-purpose program is a root shell handed to anyone who holds that account. The fixes, in order of how much they help:
- Grant a wrapper, not a tool. If the data team needs the nightly backup, let them run one small script that
does exactly that one backup —
(root) NOPASSWD: /usr/local/sbin/nightly-backup— nottarwith any arguments they like. The script takes no caller input it passes to a shell. - Never grant a GTFObins binary.
tar,vi,less,awk,find,envand many more can all spawn a command; none belongs in a sudo rule. GTFObins is the list to check a proposed rule against before you write it. - Scope and log it.
sudologs every command it runs to the auth log, so Quillon's own SOC would seerowanrunningtar … --checkpoint-action=exec=…— an archiver asked to execute a command is the tell. Least privilege stops the escalation; the log is how you catch an attempt at it.
One more honest line: running any of this against a system whose owner has not authorised you in writing is unauthorised access, an offence under laws like the UK Computer Misuse Act and the United States' CFAA. Calla has a signed engagement; that permission is the only thing separating this from a crime.
kali:~# ssh box 'sudo -l | grep -i tar'
- Grant a wrapper, not a tool. If the data team needs the nightly backup, let them run one small script that
does exactly that one backup —
Run these steps on real machines