Skip to content
Back to Blog
·9 min read·technology

Linux Privilege Escalation: A Pentester Enumeration Guide

A practical Linux privilege escalation guide covering sudo, SUID/SGID, cron jobs, capabilities, and kernel enumeration for authorised Indian pentesters.

BR

Bachao.AI Research Team

Cybersecurity Research

Scan Your Stack for This

Security exposure this creates

Unpatched vulnerabilities in your tech stack are the #1 entry point for breaches targeting Indian businesses. Here's what to watch.

Linux privilege escalation is the process of moving from a low-privilege shell to root by systematically enumerating misconfigurations — weak sudo rules, SUID binaries, writable cron jobs, dangerous capabilities, and unpatched kernels — then exploiting the first viable vector. For authorised pentesters and Indian sysadmins hardening their own systems, the discipline is the same: enumerate exhaustively before touching a single exploit, because most Linux boxes are compromised not through zero-days but through configuration debt nobody audited. This guide walks the standard enumeration checklist, the common escalation vectors it surfaces, and the defensive controls that close each one.

Why Enumeration Comes Before Exploitation

Every experienced pentester repeats the same rule: enumeration is 90% of privilege escalation. A fresh low-privilege shell tells you almost nothing about what's exploitable until you've methodically checked sudo permissions, file ownership, running processes, scheduled tasks, and kernel version. Skipping this step and jumping straight to a kernel exploit is how testers crash production systems and miss the quiet, reliable misconfiguration sitting one command away.

🛡️
SECURITY
Everything in this guide assumes a signed authorisation letter or statement of work covering the specific host and time window. Attempting privilege escalation on systems you don't own or have not been contracted to test is a criminal offence under Sections 43 and 66 of India's IT Act, 2000.

Step One: sudo -l and Sudoers Misconfigurations

The first command on any authorised Linux engagement is sudo -l, which lists what the current user can run as another user (usually root) without a password, or with their own password.

sudo -l

Common findings include binaries listed with NOPASSWD, or entries pointing at interpreters and editors (vim, less, find, python3, awk) that were never meant to be run with elevated privileges. Any of these can typically be abused to spawn a root shell through the binary's built-in shell-out functionality — a pattern documented extensively on GTFOBins, the community-maintained reference for Unix binaries that can bypass local security restrictions when misused via sudo, SUID, or capabilities.

⚠️
WARNING
A sudoers entry that looks harmless — like NOPASSWD: /usr/bin/find — is frequently a full root compromise in one line, because find supports an -exec flag that spawns an arbitrary shell as the target user.

Step Two: SUID and SGID Binaries

SUID (Set User ID) and SGID (Set Group ID) bits let a binary execute with the permissions of its owner rather than the user running it. A SUID binary owned by root effectively runs as root regardless of who invokes it — which is exactly why unnecessary SUID bits are one of the most reliable escalation paths on a poorly hardened box.

find / -perm -4000 -type f 2>/dev/null
find / -perm -2000 -type f 2>/dev/null

The first command finds SUID binaries, the second SGID. Cross-reference every non-standard result against GTFOBins — custom or third-party SUID binaries that shell out, read arbitrary files, or write to arbitrary paths are the highest-value findings in this phase.

Know your vulnerabilities before attackers do

Run a free VAPT scan — takes 5 minutes, no signup required.

Book Your Free Scan

Step Three: Cron Jobs and Scheduled Tasks

Cron jobs running as root that reference a script writable by a lower-privilege user are a classic escalation path: edit the script, wait for the schedule to fire, and it executes as root.

cat /etc/crontab
ls -la /etc/cron.d/ /etc/cron.daily/ /etc/cron.hourly/
crontab -l -u root 2>/dev/null

Also check the permissions on any script a root cron job calls, not just the crontab entry itself:

find / -writable -not -path "/proc/*" -type f 2>/dev/null
💡
TIP
Pay particular attention to cron jobs referencing scripts in world-writable directories like /tmp or /var/tmp, and to jobs using relative paths without an absolute path or a locked-down PATH variable — both are frequently exploitable through path hijacking.

Step Four: Linux Capabilities

Capabilities split root's traditional all-or-nothing power into discrete, assignable privileges (CAP_SETUID, CAP_NET_RAW, CAP_SYS_ADMIN, and dozens more). A binary granted CAP_SETUID without being SUID root can still be abused to escalate, and capabilities are frequently overlooked because testers default to only checking SUID bits.

getcap -r / 2>/dev/null

Any binary returning cap_setuid+ep or similar is worth checking against GTFOBins' capabilities section — the abuse pattern is analogous to SUID exploitation but through a different kernel mechanism, and it's routinely missed in enumeration that stops at find -perm -4000.

Step Five: Kernel Version and Patch Level

Kernel exploits are a last resort in a careful engagement — they're higher-risk (crash potential) than a clean misconfiguration-based escalation — but an unpatched kernel is still worth identifying early, because it tells you how current the host's patch cadence actually is.

uname -a
cat /etc/os-release

Cross-reference the reported kernel version against known local privilege escalation CVEs for that release line before considering a kernel-level exploit, and prefer a userland misconfiguration path whenever one exists — it's more reliable and far less likely to destabilise the host.

Common Linux Privilege Escalation Vectors Summarised

VectorEnumeration commandWhy it worksTypical fix
Sudo misconfigurationsudo -lInterpreter/editor binaries allow shell-out as rootRestrict sudoers to specific arguments, remove NOPASSWD
SUID/SGID binariesfind / -perm -4000Binary runs with owner's privileges regardless of callerStrip SUID from non-essential binaries
Writable cron scriptsls -la /etc/cron.d/Root-scheduled script editable by lower-privilege userLock file ownership and permissions to root only
Dangerous capabilitiesgetcap -r /Fine-grained root-equivalent power granted to a binaryAudit and remove unnecessary capability grants
Kernel exploitsuname -aUnpatched local privilege escalation CVE in running kernelApply kernel patches on a fixed cadence
Weak file permissionsfind / -writableWorld-writable config or script referenced by a privileged processEnforce least-privilege ownership on system files

Automated Enumeration: Where linPEAS Fits

Manual enumeration teaches the underlying logic, but on a real engagement it's paired with automated enumeration scripts — linPEAS being the most widely used in the community — that run the same checks (sudo rules, SUID/SGID, capabilities, cron, writable paths, kernel version, and dozens more) in one pass and highlight likely-exploitable results by colour. These tools are a starting point for triage, not a replacement for manually verifying every finding before acting on it — automated scripts produce false positives, and blindly executing a suggested exploit against a live system without understanding what it does is how authorised engagements go wrong.

graph TD A[Enumerate System] -->|sudo SUID cron caps kernel| B[Find Misconfiguration] B -->|Confirm exploitability| C[Select Exploit Vector] C -->|Execute carefully| D[Gain Root] D -->|Document finding| E[Remediate and Verify] style A fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style B fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style C fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style D fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style E fill:#1e3d2f,stroke:#10B981,color:#e2e8f0
68%Breaches involving a non-malicious human element such as error or misuse (Verizon 2024 DBIR)
25,000+Vulnerabilities catalogued in NIST's National Vulnerability Database in a single recent year (NIST NVD)

The pattern these figures point to holds inside a single host just as much as across an organisation: most exploitable weaknesses trace back to configuration and permission decisions, not novel code-level flaws — which is exactly why enumeration discipline outperforms jumping straight to an exploit.

Distribution of Privilege Escalation Vectors

Based on common findings across authorised Linux pentest engagements, misconfiguration-driven vectors dominate over kernel-level exploits:

pie title Common Linux Privilege Escalation Vector Types "Sudo Misconfiguration" : 30 "SUID SGID Binaries" : 25 "Writable Cron Jobs" : 15 "Capabilities Abuse" : 12 "Weak File Permissions" : 10 "Kernel Exploits" : 8

Defence: Closing Each Vector Before It's Found

Enumeration findings map directly onto remediation actions, and most of them cost nothing but administrative time.

    1. Enforce least privilege in sudoers. Restrict entries to the exact binary and arguments required, remove blanket NOPASSWD grants, and never allow sudo access to interpreters, editors, or find/awk-style utilities that can shell out.
    2. Audit SUID/SGID bits regularly. Most systems ship with more SUID binaries than they actually need. Run find / -perm -4000 on a schedule and strip the bit from anything not in active, justified use.
    3. Lock down cron job ownership and paths. Scripts referenced by root-scheduled jobs should be owned by root, writable only by root, and referenced with absolute paths — never relative paths that depend on an unlocked PATH variable.
    4. Review capability grants like you review sudoers. getcap -r / should be part of the same audit cadence as SUID checks; capabilities are just as dangerous and far less visible.
    5. Patch on a fixed cadence, not reactively. Kernel and package patching should follow a defined schedule aligned to vendor advisories, not wait for an incident to trigger it.
    6. Monitor for enumeration behaviour itself. Bursts of find, getcap, or sudoers-file access from a single session, especially from a low-privilege account, are a detectable signature worth alerting on before escalation succeeds.
ℹ️
INFO
CERT-In regularly publishes advisories covering Linux privilege escalation vulnerabilities and misconfiguration patterns Indian organisations should track as part of routine patch management, separate from any specific engagement's findings.
🎯Key Takeaway
Linux privilege escalation almost never depends on a rare exploit — it depends on whether sudo rules, SUID bits, cron permissions, and capabilities were audited before an attacker got a foothold. The enumeration checklist is also the hardening checklist; the only difference is who runs it first.

Where an External VAPT Adds Structure

An internal sysadmin running this checklist occasionally is good practice, but a structured, independent VAPT engagement — combining this same enumeration methodology with manual verification and business-context risk prioritisation, delivered with a CERT-In empanelled partner where regulatory submission is required — catches drift between audits: the SUID bit added during a rushed deployment, the cron job scripted by a departed engineer, the sudoers line nobody remembers approving. Automated, continuous scanning closes the gap between point-in-time internal reviews and what an attacker actually finds on the day they try.

Platforms like Bachao.AI build this kind of host-level and application-level enumeration into an ongoing VAPT pipeline, so Indian SMB teams get privilege-escalation-grade visibility without needing a dedicated Linux security engineer running manual sudo and SUID audits every month. Dhisattva AI Pvt Ltd built the platform around the reality that most Indian SMBs run production Linux infrastructure without anyone formally responsible for auditing it.

Next Steps

Privilege escalation enumeration is a discipline, not a one-off checklist — misconfigurations reappear every time a new service is deployed, a script is edited, or a package is upgraded. Run this checklist on your own authorised infrastructure on a fixed schedule, and treat every SUID bit, sudoers line, and cron job as something that needs a documented reason to exist.

Want visibility into which Linux misconfigurations are actually exploitable in your environment? Get a free VAPT scan, or browse the Bachao.AI blog for more hands-on security methodology. If your infrastructure processes personal data under India's privacy law, also review our DPDP compliance guide.

Frequently Asked Questions

What is the first command a pentester runs for Linux privilege escalation?
sudo -l is typically the first check, since it immediately reveals what the current user can run as another user, often root, without needing further enumeration. Misconfigured sudoers entries are one of the fastest, most reliable escalation paths on real engagements.
What are SUID and SGID binaries, and why do they matter for privilege escalation?
SUID (Set User ID) and SGID (Set Group ID) are file permission bits that let a binary run with its owner's or group's privileges rather than the invoking user's. A SUID binary owned by root can be abused to gain root access if it shells out or reads/writes arbitrary files, which is why auditing them with find / -perm -4000 is a standard enumeration step.
What is linPEAS and is it safe to use?
linPEAS is a widely used community enumeration script that automates checks for sudo misconfigurations, SUID/SGID binaries, capabilities, cron jobs, and dozens of other privilege escalation indicators, highlighting likely-exploitable findings. It's a triage tool, not a replacement for manual verification, and like any enumeration script it should only be run on systems you're explicitly authorised to test.
How does Linux privilege escalation differ from a kernel exploit?
Privilege escalation broadly covers any technique that raises a low-privilege session to root, most commonly through misconfigurations like sudo rules, SUID binaries, or writable cron jobs. Kernel exploits are a narrower, higher-risk subset that target unpatched vulnerabilities in the kernel itself, and are generally a last resort because they carry a higher chance of crashing the system.
What are Linux capabilities and why are they often missed during enumeration?
Capabilities split root's traditional all-or-nothing privileges into discrete, individually assignable powers, such as CAP_SETUID or CAP_NET_RAW, that can be granted to a binary without making it fully SUID. They're frequently missed because many testers and sysadmins only check SUID bits with find -perm -4000 and never run getcap -r / to catch capability-based grants.
How can Indian sysadmins defend against Linux privilege escalation proactively?
Regularly audit sudoers entries for unnecessary NOPASSWD or interpreter access, strip unused SUID/SGID bits, lock cron scripts to root ownership with absolute paths, review capability grants on the same schedule as SUID audits, and patch the kernel on a fixed cadence rather than reactively. Monitoring for enumeration behaviour itself, such as bursts of find or getcap activity from a low-privilege session, adds an additional detection layer.
BR

Bachao.AI Research Team

Cybersecurity Research

AI-powered security research and threat intelligence from the Bachao.AI team. Covering the latest vulnerabilities, CVEs, and cybersecurity developments affecting Indian businesses.

Get cybersecurity insights for Indian SMBs

Weekly vulnerability alerts, DPDP compliance tips, and security guides. No spam — unsubscribe anytime.

We respect your privacy. Your email is never shared.

Check whether this class of vulnerability is exposed in your systems

Free automated scan — risk score in under 2 hours. No credit card required.

Scan Your Stack for This
Find your vulnerabilitiesStart free scan →