Linux Privilege Escalation for CompTIA PenTest+ (PT0-003): SUID, Sudo Misconfigurations, and Kernel Exploits

Why Linux Privilege Escalation Earns Its Own PT0-003 Objective

Getting a shell on a Linux target is rarely the end of an engagement — it's usually the beginning. Initial access through a web application vulnerability, a weak SSH credential, or a misconfigured service almost always lands a tester in a low-privilege context: a web server account like www-data, a service account, or an unprivileged user. CompTIA PenTest+ (PT0-003) Domain 3.0, Attacks and Exploits, carries the heaviest weight on the exam, and privilege escalation sits right in the middle of it alongside its Windows counterpart. Where Windows privilege escalation leans on token abuse, service misconfigurations, and DLL hijacking, Linux escalation is a different muscle: file permissions, the sudoers file, scheduled jobs, and the kernel itself. CompTIA expects candidates to recognize both toolsets and the logic behind them, not just memorize command syntax.

Enumeration First: Mapping the Attack Surface Before You Escalate

Every reliable privilege escalation path starts with enumeration. Before attempting any exploit, a tester systematically maps what the current user can see, run, and write to. Manual enumeration means checking id and sudo -l for group memberships and sudo rights, searching for SUID/SGID binaries with find / -perm -4000 -type f 2>/dev/null, listing cron jobs in /etc/crontab and /etc/cron.d/, and reviewing kernel and distribution version with uname -a and /etc/os-release.

In practice, most engagements lean on automated enumeration scripts to speed this up: LinPEAS and LinEnum are the two PT0-003 candidates should recognize by name. Both scripts walk the filesystem and system configuration looking for the same categories of weaknesses a human would check manually, then color-code the output by how likely each finding is to lead to root. The exam doesn't expect memorized LinPEAS output, but it does expect you to know what category of misconfiguration each tool is hunting for and why enumeration always comes before exploitation.

SUID and SGID Binary Abuse

A SUID (Set User ID) binary runs with the permissions of its file owner rather than the user who launched it. When root owns a SUID binary that can read files, spawn a shell, or write to arbitrary paths, a low-privilege user can leverage it to execute code as root. Classic examples include a SUID copy of cp, vim, find, or python left behind by a careless administrator, or a legitimately SUID system binary with an undocumented shell-escape feature. GTFOBins.github.io is the reference testers use on real engagements to look up which binaries support privilege escalation and the exact one-liner to abuse them — PT0-003 expects you to understand the underlying concept (a privileged binary doing something its author didn't intend) rather than the website itself.

SGID binaries work the same way but inherit group ownership instead, which is slightly less dangerous but still useful for lateral movement into a privileged group such as docker or adm.

Sudo Misconfigurations

The sudoers file controls which commands a user can run as another user, typically root, often without re-entering a password. A line like jsmith ALL=(ALL) NOPASSWD: /usr/bin/vim looks harmless to an administrator trying to let a junior sysadmin edit configuration files, but it's a direct path to root: many common utilities, including text editors, package managers, and even some backup tools, include a shell-escape sequence that a tester can trigger from inside the "restricted" program. Wildcard entries are just as dangerous — granting NOPASSWD access to a script with a wildcard argument, such as /opt/backup/*.sh, often lets an attacker supply their own script path. Running sudo -l as the compromised user is almost always the first command a tester runs, because it immediately reveals what's been explicitly permitted.

Cron Jobs and Scheduled Task Hijacking

Scheduled tasks are a favorite escalation path because they frequently run as root on a timer, outside of any interactive session. A tester looks for two conditions: a cron job that calls a script the current user can write to, or a cron job that calls a binary by name without a full path while a directory earlier in root's PATH is writable. In the first case, replacing the script's contents with a reverse shell payload and waiting for the next scheduled run yields a root shell. In the second, dropping a malicious binary with the same name into a writable, earlier-priority directory achieves the same result without ever touching the real script. World-writable cron scripts are a surprisingly common finding in real environments, especially ones built from copy-pasted DevOps automation.

Writable Files, PATH Hijacking, and Weak Permissions

Beyond cron, testers check for a handful of other permission weaknesses CompTIA groups under the same objective: a writable /etc/passwd or /etc/shadow (which lets an attacker add a new root-equivalent user outright), writable systemd service unit files that run as root, and capabilities assigned via setcap — a more granular alternative to SUID that can grant a binary a specific privileged capability like cap_setuid without making the whole program run as root. A misassigned capability is functionally equivalent to a SUID misconfiguration and shows up in the same enumeration sweep.

Kernel Exploits and Outdated Software

When file and configuration-based escalation paths come up empty, a tester falls back to kernel exploits: unpatched vulnerabilities in the Linux kernel itself, or in setuid-root system daemons, that allow arbitrary code execution at the highest privilege level. Because a kernel exploit can crash or destabilize the target system, PT0-003 treats it as a higher-risk, higher-impact technique that should be used only within the scope and rules of engagement agreed to during pre-engagement planning, and documented carefully for the client in the final report. Identifying the running kernel version and cross-referencing it against known CVEs is a standard enumeration step precisely because many environments go months or years between patch cycles.

Credential Harvesting on a Compromised Host

Privilege escalation and credential access go hand in hand on Linux the same way they do on Windows. Bash history files, SSH private keys left in home directories, hardcoded database credentials in configuration files, and cached credentials in environment variables are all fair game once a shell is established. A reverse shell that lands as an unprivileged user is often just a stepping stone: harvested credentials from that foothold frequently grant access to a second host or service where the same user has higher privileges, extending the attack path without a single additional exploit.

Containers Change the Calculus

Modern Linux environments complicate the picture further, because "root on the container" and "root on the host" are not the same thing. A misconfigured container — one running privileged, mounting the host filesystem, or exposing the Docker socket — can let a tester escape the container boundary entirely, a technique covered in more depth in our guide to cloud-based attacks and container escapes. PT0-003 candidates should recognize that privilege escalation inside a container is often just the first step toward a much more damaging host-level compromise.

From Exploit to Report

Every privilege escalation finding needs to be reproducible and clearly explained, because the client's remediation team has to fix the actual misconfiguration, not just patch the one exploit you demonstrated. A SUID binary finding should name the specific binary and command used; a sudo misconfiguration finding should quote the exact sudoers line. This level of detail is exactly what separates a usable penetration test report from a vague "privilege escalation was possible" bullet point, and it's also tested directly under PT0-003's reporting domain.

Exam Tips for PT0-003

CompTIA tends to test this material with scenario-based questions: you're given a sudo -l output, a cron entry, or a find result, and asked to identify the escalation path or the best next command. Memorizing tool names won't get you there — focus on understanding why each misconfiguration grants elevated access. Also expect the exam to pair Linux and Windows privilege escalation in the same question set, so be ready to distinguish a SUID binary from a vulnerable Windows service, and a cron job hijack from a scheduled task hijack. Buffer overflows and memory-corruption exploits, covered separately in our buffer overflow guide, are a related but distinct escalation category you should be able to tell apart from configuration-based privilege escalation.

Key Takeaways

  • Linux privilege escalation almost always starts with thorough enumeration — manually or via LinPEAS/LinEnum — before any exploitation is attempted.
  • SUID/SGID binaries and sudo misconfigurations are the two most commonly tested and most commonly found real-world escalation paths.
  • Cron jobs and PATH hijacking exploit root-owned scheduled tasks that run with weak file or directory permissions.
  • Kernel exploits are a higher-risk fallback technique that must stay within the engagement's agreed rules of engagement.
  • Container misconfigurations can turn a contained foothold into full host compromise, linking privilege escalation to cloud and container attack paths.
  • Clear, reproducible documentation of each escalation path is what makes a finding actionable in the final post-exploitation and reporting phase of the engagement.

Comments