Ordinary Linux executables such as editors, pagers, interpreters and archive tools become privilege escalation and evasion tools the moment they are granted through sudo, given the SUID bit or handed a file capability. GTFOBins is the public catalogue of those behaviours, and attackers and penetration testers use it as a lookup table once they land on a host. This guide is for Linux administrators and detection engineers who want to use the same catalogue the other way round: to find the risky grants on their own estate, remove them, and detect the abuse that remains possible. It stays on binaries and their configuration. For the wider escalation picture (kernel bugs, cron, containers) see the Linux Privilege Escalation Techniques Guide, and for baseline host settings see the Linux Server Hardening Guide.
Key takeaways
- The binary is not the vulnerability. GTFOBins says its entries are not exploits and the programs are not vulnerable in themselves; the risk is the privilege context you give them (sudo, SUID, capabilities).
- Treat GTFOBins as a deny list for grants. Any binary listed under the Sudo, SUID or Capabilities context should not appear in a sudoers rule, carry the SUID bit or hold a file capability without a written justification.
- Inventory beats detection. A per-image baseline of sudoers rules, SUID and SGID files and file capabilities removes most abuse paths before any alert is needed.
- Detect the transition, not the tool. auditd and EDR rules that flag an interactive shell or network connection spawned under an effective UID of 0 from a non-shell parent catch the pattern across hundreds of binaries.
- Service accounts are the usual holders. Broad NOPASSWD sudo rules for deployment, backup and monitoring accounts are where these grants accumulate, so review machine identities first.
What living-off-the-land on Linux means
Living off the land means using software already installed on the target instead of bringing new tools. A standard Linux server image ships with dozens of general-purpose programs that can read and write files, open sockets, load libraries or start a shell. When one runs with higher privileges than its caller, every one of those abilities is inherited, and nothing new appears on disk for allowlisting to flag.
The Windows equivalent is catalogued by the LOLBAS project, and the cross-platform discipline is covered in the Living off the Land Guide. The Linux case differs in one important way: escalation usually needs a misconfiguration made by the defender (a sudoers rule, a SUID bit, a capability), so the fix sits largely in configuration management rather than in the detection stack.
- Escalation: a user allowed to run a program as root through sudo, or a SUID-root program that does not drop privileges, can be steered into running a shell or writing a protected file. ATT&CK tracks this as T1548 Abuse Elevation Control Mechanism, with sub-techniques T1548.001 Setuid and Setgid and T1548.003 Sudo and Sudo Caching.
- Restricted shell escape: users confined to a limited shell or a single application break out through an allowed program's own command feature.
- Collection and transfer: programs that read arbitrary files or make outbound connections move data or tools without new software being installed (T1005 Data from Local System, T1105 Ingress Tool Transfer, T1041 Exfiltration Over C2 Channel).
The GTFOBins project
GTFOBins describes itself as a curated list of Unix-like executables that can be used to bypass local security restrictions in misconfigured systems. It is maintained as an open source repository on GitHub under the GPL-3.0 licence, and as of November 2026 the repository holds over 470 executable entries. Each entry lists one or more functions, and each function example is tagged with the contexts in which it works.
That two-axis model is what makes the catalogue useful to defenders. Functions say what a binary can do; contexts say under which grant it does it with someone else's privileges. The project also maps each function to an ATT&CK technique in its data files, which is a convenient starting point for detection coverage.
| Context (GTFOBins) | What it means | Defender question |
|---|---|---|
| Unprivileged | Any user can perform the function | Do we need this binary on this host at all, and is its network or file access monitored? |
| Sudo | Run by the privileged user through sudo because privileges are not dropped | Does any sudoers rule grant this binary, directly or through ALL or a wildcard? |
| SUID | Run with the file owner's effective privileges because the SUID bit is set and privileges are not dropped | Is the SUID bit set on this binary in any image or running host? |
| Capabilities | Bypasses kernel permission checks because the file has capabilities set | Does this binary carry a file capability such as cap_setuid or cap_dac_read_search? |
Use the catalogue as data, not as instructions. The repository's YAML files can be parsed into a list of binary names per context and joined with your own inventory to produce a risk report.
Abuse categories (shell, sudo, SUID, file read)
GTFOBins groups behaviours into functions. The table below maps each function to the ATT&CK technique the project itself assigns, and to the defensive control that removes or exposes it.
| Function | What the binary can do | ATT&CK (per project data) | Primary defensive control |
|---|---|---|---|
| Shell | Spawn an interactive system shell | T1059 Command and Scripting Interpreter | Never grant through sudo or SUID; alert on shells whose parent is not a terminal or login process when euid is 0 |
| Command | Run non-interactive system commands | T1059 | sudo NOEXEC or intercept for granted programs; process lineage rules in EDR |
| Reverse shell and bind shell | Connect a shell to a remote listener, or listen locally | T1059, T1071 Application Layer Protocol | Egress filtering on servers; alert on outbound connections from editors, pagers and archive tools |
| File read | Read local files | T1005 Data from Local System | Remove cap_dac_read_search and SUID; watch reads of /etc/shadow and private keys |
| File write | Write local files | T1565 Data Manipulation | Watch writes to /etc/sudoers, /etc/sudoers.d, /etc/passwd, authorized_keys and systemd units |
| Upload and download | Send local data out, or fetch remote data | T1041, T1105 | Egress proxy with allowlist; network telemetry per process |
| Library load | Load shared libraries into the same execution context | T1574 Hijack Execution Flow | Keep env_reset in sudo; never add LD_* variables to env_keep; mount writable paths noexec |
| Privilege escalation | Indirectly grant privilege, for example by setting the SUID bit or changing ownership of another file | T1548 | Alert on chmod or chown that sets SUID or changes owner to root outside change windows |
Three practical groupings cover most real findings:
- Shell escapes: editors, pagers, mail clients, debuggers and interpreters almost all have a feature that runs a subprocess. Granting any of them as root is equivalent to granting a root shell.
- Sudo grants: the sudoers manual itself warns that wildcards match any character including white space and that using ! against ALL to allow "all but a few" commands rarely works as intended. A rule that permits a package manager, a service manager with a pager, or a script in a user-writable directory is an escalation path.
- SUID binaries: distributions ship a short list of SUID programs that are designed to drop or manage privilege (passwd, su, sudo, mount). Anything else carrying SUID root, especially a copy of a general-purpose tool, is a finding.
Hardening sudo and SUID
The full sudoers configuration is covered in the sudo and sudoers Security Guide. The steps below are the GTFOBins-specific review.
Sudoers review
- Export every effective rule. Collect /etc/sudoers and every file read through @includedir (the manual notes it reads files in sorted lexical order and skips names ending in ~ or containing a dot, so stray files may be silently ignored or unexpectedly included). Include rules delivered by LDAP or SSSD where used.
- Join against the catalogue. Flag every command whose basename appears under the GTFOBins Sudo context, every ALL grant, every wildcard in a path or argument, and every command path that a non-root user can write.
- Replace program grants with task grants. Instead of granting an editor, grant sudoedit for the specific file; instead of a service manager, grant the exact start, stop or restart command with fixed arguments; instead of an interpreter, grant a root-owned wrapper script.
- Apply execution controls. The NOEXEC tag (or the noexec default) stops a dynamically linked program from running further commands where supported. From sudo 1.9.8 the intercept option and INTERCEPT tag control child processes, and log_subcmds records them. Test each, because some legitimate programs need to spawn children.
- Keep environment controls at their defaults. env_reset is on by default; keep it, set secure_path, and do not add loader or interpreter variables to env_keep.
- Turn on session logging for privileged rules. log_input and log_output are off by default; enable them (or the LOG_INPUT and LOG_OUTPUT tags) on rules that grant anything broader than a single fixed command.
- Pin binaries where paths can change. sudoers supports sha224 to sha512 command digests; the manual warns of a race if the user can write to the command, so digests complement correct ownership, they do not replace it.
SUID, SGID and capability inventory
- Baseline per image: record every file with the SUID or SGID bit and every file with a security.capability extended attribute in each golden image. Store the list in version control next to the image definition.
- Remove what the role does not need: strip SUID from binaries unused on servers and uninstall packages that exist only to provide them. Removal is the most durable control.
- Treat capabilities as SUID: the capabilities manual describes CAP_SETUID as allowing arbitrary changes of user ID, CAP_DAC_OVERRIDE and CAP_DAC_READ_SEARCH as bypassing file permission checks, and CAP_SYS_ADMIN as overloaded. Any of these on a general-purpose binary is equivalent to root.
- Use mount options: the nosuid option makes the kernel ignore set-user-ID and set-group-ID bits and file capabilities on that filesystem; noexec stops direct execution. Apply both to /tmp, /var/tmp, /dev/shm, /home and removable media where workloads allow.
- Constrain with MAC: SELinux or AppArmor profiles for granted programs limit what a shell escape can reach. See the SELinux Guide and the AppArmor Guide.
Choosing between controls
| Situation | Preferred control | Trade-off |
|---|---|---|
| Admins need to edit one config file as root | sudoedit for that path | Edits run as the user, then are copied back; some editors need configuration |
| Service account restarts one service | Fixed-argument command rule, NOPASSWD only for that command | Each new task needs a rule change, which is the point |
| Legacy tool requires SUID root | Isolate the host, add MAC profile, alert on execution | Residual risk remains; record an exception with an expiry date |
| Small estate, few admins | Manual quarterly review against the catalogue | Drift between reviews; pair with file integrity monitoring |
| Large estate, many images | Automated baseline in CI for images, and continuous comparison on hosts | Upfront engineering; pays back in audit evidence |
Detection with auditd and EDR
Because the abusable list is long and changes, detections should key on behaviour that every abuse shares: a privilege boundary crossed by a process that is not normally a shell. The Linux Logging and auditd for Defenders Guide covers collection and forwarding; this section covers the rule approach.
auditd rules approach
- Record privileged execution with the login identity: audit execve on both architectures (the audit.rules manual advises separate -F arch=b32 and -F arch=b64 rules on bi-arch systems) where euid is 0 and auid is a real user (auid>=1000 and auid!=unset, matching UID_MIN in /etc/login.defs). The auid field keeps the original login identity through sudo and su, which is what links the root process back to a person or service account.
- Watch the files escalation targets: write and attribute changes on /etc/sudoers, /etc/sudoers.d, /etc/passwd, /etc/shadow, /etc/group, root's authorized_keys and systemd unit directories, each with a distinct key.
- Catch new SUID and capability grants: audit chmod, fchmod, fchmodat and setxattr calls, then filter in the SIEM for mode changes that add the SUID bit or writes to security.capability.
- Lock the rules: auditctl -e 2 makes the configuration immutable until reboot and audits any attempt to change it; put it last in the rules file on production hosts.
An illustrative watch rule in the form the audit.rules manual documents: -a always,exit -F arch=b64 -F path=/etc/sudoers -F perm=wa -F key=sudoers_change. Test every rule for volume in a pilot ring before estate-wide rollout.
EDR and SIEM analytics
| Analytic | Signal | Typical false positives |
|---|---|---|
| Shell from unusual parent under root | Process image is a shell, euid 0, parent is an editor, pager, interpreter, archive tool or package manager | Package post-install scripts; admin workflows that shell out from vim |
| Network from non-network tool | Outbound connection from a binary that is not a client or daemon on that host | Interpreters used by configuration management |
| SUID added | Mode change sets 04000 outside package manager activity | Package installs and upgrades |
| Sensitive file read by odd process | /etc/shadow or SSH private keys opened by a process other than the expected auth stack | Backup agents |
| sudo of catalogued binary | sudo log entry where the command basename is in the GTFOBins Sudo list | Legitimate grants still pending review (each is a finding in itself) |
Build these as sequence rules where your platform supports it, and tune with an allowlist of known parents per host role. See the How to Hunt for Living-off-the-Land Binary Abuse for hunt structure and the Linux Detection and Response Guide for sensor choices, including eBPF-based telemetry.
Metrics
- Catalogued sudo grants: number of sudoers rules granting a binary in the GTFOBins Sudo context, trending to zero or to documented exceptions.
- SUID and capability drift: files with SUID, SGID or file capabilities not in the image baseline, per host.
- Broad grants: count of ALL and wildcard sudo rules, split by human and service accounts.
- Telemetry coverage: percentage of Linux hosts sending execve audit events with auid, and with the rules locked.
- Time to remove: median days from a new SUID or sudo finding to its removal or approved exception.
Where identity fits
Sudo rules are access grants, and most of the dangerous ones belong to non-human identities: CI runners, deployment users, backup agents and monitoring accounts given NOPASSWD rights to a tool because it was quicker than writing a narrow rule. Those accounts often have SSH keys spread across many hosts and no owner who reviews them. Review sudoers as part of access certification, give each service account an owner, and scope its rules to the exact commands its job needs. See the Unix and Linux Privileged Access Guide and the Service Account Security Guide.
Common failure patterns
- Granting an editor or pager "just to read logs": the shell escape makes it a full root grant. Use read-only group membership or a fixed command instead.
- Trusting ! exclusions: rules such as ALL except a shell are bypassed by any other program that can start a shell, which the sudoers manual itself warns rarely works as intended.
- Baselining once: SUID and capability lists are captured at build and never compared again, so a bit set during an incident or by a hand-installed package goes unnoticed.
- Auditing without auid: rules that log uid only show root, losing the link to the account that ran sudo.
- Containers treated as safe: images built from full distributions carry the same SUID binaries and sudo packages; strip them in the build and run as non-root.
- Catalogue as an alert list only: alerting on every execution of a listed binary floods the SOC; use the list to drive configuration findings and keep alerts behavioural.
Framework mapping
| Framework | Reference | How this guide applies |
|---|---|---|
| MITRE ATT&CK v20 | T1548.001 Setuid and Setgid; T1548.003 Sudo and Sudo Caching | Core escalation techniques removed by the sudoers and SUID review |
| MITRE ATT&CK v20 | T1059.004 Unix Shell; T1574.006 Dynamic Linker Hijacking | Shell and library-load functions; detected by lineage rules and env_reset |
| MITRE ATT&CK v20 | T1222.002 Linux and Mac Permissions | Detection of SUID and ownership changes |
| NIST SP 800-53 Rev. 5 | AC-6 Least Privilege; CM-7 Least Functionality | Narrow sudo grants; remove unneeded SUID binaries and packages |
| NIST SP 800-53 Rev. 5 | CM-6 Configuration Settings; AU-12 Audit Record Generation; SI-4 System Monitoring | Baselines in configuration management; auditd and EDR analytics |
Practitioner checklist
- Export every effective sudoers rule, including @includedir files and directory-service rules.
- Join rules against the GTFOBins Sudo context and remove or replace every match with sudoedit, fixed-argument commands or wrapper scripts.
- Remove ALL and wildcard grants from service accounts and assign each account an owner.
- Baseline SUID, SGID and file capabilities per image in version control and alert on drift.
- Mount /tmp, /var/tmp, /dev/shm and /home with nosuid and noexec where workloads allow.
- Enable NOEXEC or intercept, and log_input and log_output, on rules that remain broad.
- Deploy auditd execve rules with auid filtering, sensitive-file watches and SUID change rules, then lock with -e 2.
- Build EDR lineage rules for root shells and network activity from non-network binaries, tuned per host role.
- Report the five metrics above monthly and review exceptions at expiry.
Standards and references
- GTFOBins: Curated list of Unix binaries that can bypass local security restrictions
- GTFOBins: Project repository and data files
- MITRE ATT&CK: T1548 Abuse Elevation Control Mechanism
- Sudo Project: sudoers manual
- Linux man-pages: audit.rules(7)
- Linux man-pages: auditctl(8)
- Linux man-pages: capabilities(7)
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
Related NHI Mgmt Group resources: Living off the Land Guide · Linux Privilege Escalation Techniques Guide · File Integrity Monitoring Guide · Privileged Access Management Guide