The pager with superpowers
The Orizzonti travel agency gave the web team five sudo rules, one for each “small problem” solved with a ticket. They all look harmless. One of them, though, hands out a root shell in practice. Read the rules, look at what the scripts really launch and find the wrong one.
Lab 8 of 9 in the Privilege Escalation path. If you get stuck you have 3 hints, from the vaguest to the most precise: they cost 0, 50 and 150 XP.
What you learn
Objectives complete themselves while you work in the terminal; each one is worth experience points:
- List the sudo rules of your user (100 XP)
- Understand why the suspicious rule was created (the ticket) (100 XP)
- Consult the memo on programs that launch other programs (150 XP)
- Read what the suspicious script really launches (200 XP)
Topics: privesc, sudo, audit.
Commands you will use
The terminal is simulated and understands about forty Linux commands. In this lab you will mostly need these:
cat: prints the contents of a file: the most direct way to read configurations, notes and logs.sudo: runs a command with another user’s privileges, usually root; with -l it lists what you are allowed to do. Every rule that is too broad is a risk.
The simulated environment
You work in a simulated Linux shell, in the home folder of the user runner: invented files and folders, no network target.
Besides the home folder there is a complete simulated system, with configuration files, logs, users and permissions to examine.
The defensive lesson
Once the lab is solved, the write-up explains what went wrong and how to protect yourself:
A pager or editor launched with sudo runs as root and, from inside, can start other programs that inherit the same power: a “harmless” rule on less, vi, man or similar is worth a root shell. The name of a wrapper script says nothing; what it launches is what counts. Defensive lesson: to read logs give a group read access to the logs or use tail; to edit a file use sudoedit; forbid programs that launch other programs, restrict execution from inside wherever possible and review the sudo rules every time a ticket is closed.
Before and after this lab
To unlock it you must have solved:
- Too many capabilities (Privilege Escalation, medium)
- Who am I and what can I do? (Privilege Escalation, medium)
After this lab you can move on to:
- Final audit: the hotel's chain (Privilege Escalation, hard)
The Privilege Escalation path
Privilege Escalation is an audit path here: you are on a server as a normal user and you check whether some misconfiguration lets you gain more privileges than you should have. You examine sudo rules, programs with the SUID bit, credentials forgotten in the history and in files, and secrets passed as process arguments. These are the same checks that people who harden systems run, and each lab ends with the principle that sums them all up: least privilege.