Too many capabilities
The Spiga d'Oro farming cooperative has removed the SUID bit from almost everything and feels safe. But Linux has another way to give a program powers without making it SUID: capabilities. Run the audit: compare the ones assigned with the list of authorised programs and find out which one reads what should stay private.
Lab 7 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, 40 and 100 XP.
What you learn
Objectives complete themselves while you work in the terminal; each one is worth experience points:
- Check the SUID programs: nothing unusual (100 XP)
- Read the list of programs allowed to have capabilities (100 XP)
- List the capabilities assigned to programs (getcap) (150 XP)
- Inspect the suspicious program without running it (150 XP)
Topics: privesc, capabilities, 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.find: searches for files by name, type or permissions across a whole folder tree; in an audit it turns up keys, forgotten copies and programs with dangerous permissions.strings: extracts the readable text from a binary file: it reveals passwords and addresses left inside a program.
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:
Giving a program root-like powers does not need the SUID bit: a capability such as cap_dac_read_search lets it read any file without being root, and find -perm never shows it. Whoever checks only the SUID programs misses the problem. Defensive lesson: add getcap to the periodic audit, compare the result with the approved list, give each program only the capability it really needs (cap_net_bind_service for a low port, never cap_dac_read_search) and remove any that has no written justification.
Before and after this lab
To unlock it you must have solved:
- Passwords in the logs (Privilege Escalation, medium)
- Executables with the SUID bit (Privilege Escalation, medium)
After this lab you can move on to:
- The pager with superpowers (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.