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.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Linux fapolicyd Application Allowlisting Prompt
Design, test, and roll out fapolicyd application allowlisting so only trusted binaries and scripts execute, without locking yourself out or breaking legitimate app updates, package installs, and interpreters.
-
Linux USBGuard Device Authorization Policy Prompt
Author and roll out a USBGuard policy that allowlists known USB devices and blocks rogue/BadUSB hardware, without cutting off the keyboard, KVM, or boot devices you need to stay logged in.
-
Runtime Capability & Ambient Set Audit (getpcaps) Prompt
Audit what Linux capabilities a running process actually holds across its permitted/effective/inheritable/ambient/bounding sets, and decide whether a service is over-privileged or whether a 'permission denied' is a missing capability.
-
Linux Capabilities Audit & Hardening Prompt
Audit POSIX file capabilities and per-process capability sets to find binaries and services that hold more privilege than they need, then drop them — replacing blunt setuid-root with least-privilege capabilities.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.