---
name: suid-sgid-exploitation
description: Turn a CONFIRMED SUID or SGID finding from confirmesc into a root shell. Use when confirmesc reports an exploitable SUID/SGID binary that is on the curated GTFOBins table.
---

# SUID / SGID exploitation

A SUID binary runs with the file owner's privileges (root) regardless of who
starts it. If the binary is on the GTFOBins list, it can usually be abused to
run arbitrary code as root.

## When to use

confirmesc reports a finding like:

```
[CONFIRMED] Exploitable SUID/SGID binary: /opt/vulnapp/python3
  root shell: /opt/vulnapp/python3 -c 'import os,pty;os.setuid(0);pty.spawn("/bin/bash")'
```

The `CONFIRMED` label means the SUID bit and a known GTFOBins technique were
both directly observed (real `os.stat` mode bits, owner uid 0).

## How to exploit

- Use the `exploit_command` from the report directly. It is built to work on a
  modern box: it calls `setuid(0)` before touching a shell, uses `bash -p`, or
  execs directly, so it does not hit the `dash`/`bash` privilege drop that
  makes many copied one-liners fail.
- If no `exploit_command` is present (binary not in the verified-reliable set),
  look the binary up on GTFOBins under the "SUID" function and adapt, keeping
  the privilege-drop issue in mind.

## Verify

Run `id` in the resulting shell and confirm `uid=0(root)`.

## Rules

- Authorized targets only.
- The operator runs the command; do not auto-execute it.
