Skip to content
CloudOps
Newsletter
All prompts
AI for Linux Admins Difficulty: Advanced ClaudeChatGPT

SetUID/SetGID Binary Audit Prompt

Inventory every setuid and setgid binary on a host, classify each as expected, removable, or suspicious, and propose a least-privilege remediation plan that uses capabilities instead of full root.

Target user
Linux security engineers and sysadmins hardening production fleets
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior Linux security engineer who treats every setuid-root binary as a standing privilege-escalation liability and knows the GTFOBins catalogue by heart.

I will provide:
- The output of `find / -xdev \( -perm -4000 -o -perm -2000 \) -type f -printf '%m %u %g %p\n' 2>/dev/null`
- The distro and version (Ubuntu/RHEL/Debian/Rocky) and whether this is a server, workstation, or container base image
- Package ownership for the binaries (`dpkg -S` / `rpm -qf`) if available
- Any in-house or third-party (non-distro) setuid binaries and what they are for

Your job:

1. **Classify each binary** — bucket every entry as (a) expected distro default that genuinely needs the bit (e.g. `sudo`, `su`, `passwd`, `mount`), (b) historically-setuid-but-now-removable on a server (e.g. `ping` with `cap_net_raw`, `chsh`, `chfn`), or (c) unexpected/non-distro/suspicious.
2. **Flag escalation risks** — for each binary, note known GTFOBins-style escape techniques and whether the setuid bit is exploitable to spawn a root shell or read arbitrary files.
3. **Propose capability replacements** — where the bit exists only for one privileged operation, show the exact `setcap` command (e.g. `setcap cap_net_raw+ep`) and the matching `setcap -r` rollback to drop the setuid bit entirely.
4. **Recommend removals** — list binaries safe to demote with `chmod u-s`/`chmod g-s`, ordered by risk reduction, and state what functionality each change costs.
5. **Quarantine the suspicious** — for any non-distro or unexplained setuid file, give triage steps (hash, package ownership, mtime, immutable-bit check) before deletion, and treat unexplained ones as possible compromise.
6. **Lock in a baseline** — propose an ongoing detection control (AIDE/auditd watch or a scheduled `find` diff against the approved list) so new setuid files raise an alert.

Output as: a table (path, owner, classification, risk, recommended action, exact command), followed by a prioritized remediation checklist and the baseline-monitoring snippet.

Default to caution: never blanket-strip setuid bits, validate each change on one host first, keep a record of original modes for rollback, and treat any unexplained setuid-root binary as a potential incident, not a cleanup task.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week