← All challenges
mediumsecurity~25 min

Defuse a SUID privilege escalation

A legacy report tool is setuid-root AND world-writable, so any user can overwrite it and their code runs as root. Find the misconfiguration and fix the permissions without breaking the tool.

Scenario

During an audit of web1 you find this in /usr/local/bin:

$ ls -l /usr/local/bin/legacy-report
-rwsrwxrwx 1 root staff 48120 Mar  3  2024 /usr/local/bin/legacy-report

Two problems are stacked on top of each other:

  • the setuid bit is on (s in the owner's execute slot): whoever runs this file, it executes as root;
  • the file is group- and world-writable: anyone on the box can replace its contents.

Together that's a complete privilege escalation: write a shell into the file, run it, you're root. This exact pattern (a forgotten in-house tool with sloppy permissions) is one of the most common findings in real privesc audits.

Your job

Write the commands in fix.sh that defuse the binary without breaking it:

  • remove the setuid bit; the tool works fine as a normal user
  • make sure only root can modify it (no group write, no world write)
  • regular users must still be able to run it
  • it stays owned by root (root:staff or root:root; the owner is what matters)

How it's graded

Evaluated: your chmod/chown commands are applied to a model of the filesystem, then the resulting mode, ownership, and per-user access are checked, the same resolution a real kernel does.

Teaches: SUID auditing and least-privilege file modes, a staple of every Linux hardening checklist and privesc CTF.

What gets checked

Your solution is verified against each of these:

  • The setuid bit is gone; the tool no longer runs as root
  • Neither group members nor anyone else can modify the binary
  • Regular users can still run the tool
  • The binary is still owned by root

Solve it in your browser

No setup, no install. Write your solution in the editor and hit Check. The in-house engine renders and grades it instantly, then issues your proof the moment every check passes.

Solve in browser →

Prefer your own lab?

  1. Build the fix locally. New to the tooling? See setting up your lab.
  2. Push your topology file, device configs, and any playbooks to a public repo (GitHub or GitLab).
  3. Submit the repo link. We review it by hand, confirm it works, and issue your proof page.
Submit your solution →