SUID abuse, sudo misconfigurations, kernel exploits β identifying and mitigating local privilege escalation vectors
Critical
Pending
βΎ
Scenario: You are a junior security analyst at MidWest Financial. A contractor account with limited access is found to be running commands as root. Investigate how privilege escalation occurred.
CVE Reference
CVE-2021-4034 (PwnKit)
CVSS Score
7.8 HIGH
Attack Vector
Local β Root
Affected Systems
Linux (pkexec)
How It Works
Privilege escalation allows an attacker with low-level access to gain administrative (root/SYSTEM) privileges. Common vectors include:
SUID/GUID Bit Abuse: Executables with the SUID bit run as the file owner. If root owns a SUID binary and it is exploitable, attackers gain root.
Misconfigured sudo: Overly permissive sudoers entries allow users to run privileged commands.
Writable PATH Entries: If a privileged script calls binaries without absolute paths, attackers inject malicious binaries.
# Find SUID binaries β attacker reconnaissancefind / -perm-4000-type f 2>/dev/null
# Dangerous result β /usr/bin/find has SUID set-rwsr-xr-x 1 root root 220416 /usr/bin/find# Exploit via GTFOBins technique/usr/bin/find . -exec /bin/sh -p \; -quit# Attacker now has root shell β # prompt
β οΈ
Educational Simulation OnlyThis simulation models privilege escalation behavior in a controlled environment. No real commands are executed.
Interactive Privilege Escalation Simulator
Running Processes (pre-attack)
PID
User
Command
1
root
/sbin/init
452
root
sshd
891
user
bash
892
www-data
apache2
β
SET-UID
/usr/bin/find β οΈ
VulnLab Privilege Escalation Simulator β readySelect an attack vector and click Simulate Attack βΆ
Identify Misconfigurations
Review the sudoers file excerpt below. Check all entries that represent a security risk:
CONFIG/etc/sudoers
# Line 1
root ALL=(ALL:ALL) ALL
# Line 2contractor ALL=(ALL) NOPASSWD: /bin/bash# Line 3
deploy ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart apache2
# Line 4%webteam ALL=(ALL) NOPASSWD: ALL# Line 5
backup ALL=(ALL) NOPASSWD: /usr/bin/rsync
β Line 2: contractor has NOPASSWD access to /bin/bash (gives full shell)
β Line 3: deploy can restart apache2 (service management, acceptable)
β Line 4: %webteam has unrestricted NOPASSWD sudo (ALL commands)
β Line 5: backup uses rsync for file sync (scoped, lower risk)
π‘
Correct! Lines 2 and 4 are high-risk. /bin/bash grants a full root shell; NOPASSWD ALL for a group is equivalent to giving all group members root with no accountability.
Knowledge Check β 3 Questions (2 pts each)
02
Race Conditions & TOCTOU
Time-of-Check to Time-of-Use flaws, symlink attacks, and filesystem race condition exploits
High
Pending
βΎ
Scenario: An ATM application checks an account balance (Time of Check), then processes a withdrawal (Time of Use). An attacker triggers simultaneous withdrawals to double-spend.
TOCTOU Explained
A TOCTOU vulnerability exists when a program checks a resource's state and then uses that resource, but an attacker can change the resource between those two operations.
CVulnerable Code
inttransfer_funds(int amount) {
// TIME OF CHECK β reads balanceint balance = get_balance(account_id);
// β WINDOW: attacker triggers another thread here!// TIME OF USE β uses the stale balance valueif (balance >= amount) {
deduct(account_id, amount); // runs with old balancereturn SUCCESS;
}
}
π
The Race WindowThe gap between check and use is the attack surface. Even microseconds create exploitable windows in concurrent systems.
π
Symlink Attack VariantA process checks if /tmp/file is safe, then opens it. Attacker replaces it with a symlink to /etc/passwd before the open() call.
TOCTOU Timing Visualizer
Simulate the timing relationship between legitimate and attacker threads. Adjust the window size to see when the race condition becomes exploitable.
Thread Timeline
Legit Thread
Attacker Thread
TOCTOU Simulator β adjust window size, then Run Race
Defense: Atomic Operations
CFixed β Atomic Compare-and-Swap
// Use database transactions β atomic check + useBEGIN TRANSACTION;
SELECT balance FOR UPDATE; // locks rowUPDATE accounts SET balance = balance - :amountWHERE balance >= :amount AND id = :account_id;COMMIT; // atomic β no window exists
Knowledge Check β 3 Questions (2 pts each)
03
Buffer Overflows
Stack/heap overflows, return address corruption, NOP sleds, and memory-safe countermeasures
Critical
Pending
βΎ
Scenario: A legacy VPN appliance uses strcpy() to handle user authentication tokens. Security researchers discover that sending a 512-byte token crashes the device and achieves remote code execution.
Safe Alternative: Use strncpy(buf, token, sizeof(buf)-1) or, better, snprintf(). In modern C++, use std::string. Enable ASLR, Stack Canaries, and NX/DEP at compile time.
Stack Buffer Overflow Visualizer
Input β Stack State
Stack Memory (Buffer: 8 cells, EBP: 2, EIP: 2)
Buffer (safe) Overflow EIP Corrupted
Move slider right to fill buffer β watch for overflow...
Well done! ASLR, Stack Canaries, NX/DEP, and safe string functions together form a defense-in-depth strategy against buffer overflows.
Knowledge Check β 3 Questions (2 pts each)
04
Side-Channel Attacks
Timing attacks, cache analysis, power analysis β extracting secrets from observable system behavior
High
Pending
βΎ
Scenario: Spectre (CVE-2017-5753) allowed attackers to read kernel memory from user-space by exploiting CPU speculative execution β a hardware-level side channel invisible to the OS.
Attack Types
Timing, Cache, Power, EM
Famous Examples
Spectre, Meltdown, FLUSH+RELOAD
Target
Crypto keys, Passwords, Data
Observable Signal
Time, Power, Cache state, EM
Timing Attack on Password Comparison
PYTHONVulnerable β Early Exit
defcheck_password(stored, attempt):
for i in range(len(stored)):
if stored[i] != attempt[i]: # exits early!returnFalse# leaks how many chars matchedreturnTrue# Fix β constant-time comparisonimport hmac
defsafe_check(stored, attempt):return hmac.compare_digest(stored, attempt)
Timing Oracle Simulator
Exercise: A login API returns slightly different response times based on how many characters of the password matched. Use the timing oracle to discover the 4-character PIN.
Timing Attack Interface
Enter a 4-character guess. The server response time reveals information about correct characters. Analyze patterns to deduce the PIN.
Timing Oracle ready β try guessing the 4-char PINHint: characters are digits 1β4 only
π―
PIN Cracked via Timing Attack! This demonstrates how response time leaks can reconstruct secrets character by character β classic side-channel oracle.
Countermeasures
β±οΈ
Constant-Time AlgorithmsUse hmac.compare_digest() (Python), crypto/subtle.timingSafeEqual (Node.js). Never short-circuit secret comparisons.
π
Add JitterIntroduce random delays to mask timing signals. Ensure minimum response time is always met regardless of outcome.
Knowledge Check β 3 Questions (2 pts each)
05
Unpatched Services & EOL Systems
End-of-life OS/software risks, patch management failures, and legacy system isolation strategies
High
Pending
βΎ
Scenario: A hospital network scan reveals Windows 7 workstations processing patient data. No security patches have been issued since January 2020. The system is fully connected to the internet and running outdated SMB services.
EOL Software Status Dashboard
System / SoftwareEOL DateStatusAction Required
Windows 7 SP1Jan 14, 2020β EOLMigrate or air-gap
Windows Server 2008 R2Jan 14, 2020β EOLMigrate immediately
Windows 10 22H2Oct 14, 2025β οΈ ExpiringUpgrade to Win 11
Windows 11 23H2Nov 11, 2025β οΈ ExpiringUpdate to 24H2
EternalBlue (MS17-010) exploits SMBv1 on unpatched Windows. WannaCry ransomware (2017) infected 200,000+ systems in 150 countries. EOL systems never received the MS17-010 patch.
Patch Gap Risk Calculator
Asset Risk Assessment
Configure asset properties and click Calculate Risk
Mitigation Strategy Matrix
β Segment EOL systems into isolated VLANs with strict firewall rules
β Implement application whitelisting on EOL systems to restrict execution
β Enable auto-updates on EOL software (updates no longer available β ineffective)
β Deploy compensating controls: IDS/IPS monitoring for known EOL exploits
β Create migration plan with target architecture and timeline for EOL replacement
β
Correct! Auto-updates are ineffective for EOL systems β no patches are issued. Segmentation, whitelisting, IDS monitoring, and a migration plan are the right compensating controls.
Knowledge Check β 3 Questions (2 pts each)
06
Insecure Data Storage
Cleartext credentials, weak encryption, unprotected databases, and mobile storage misconfigurations
Medium
Pending
βΎ
Scenario: A mobile banking app stores authentication tokens in SharedPreferences (Android) without encryption. A physical device compromise or backup extraction exposes all customer tokens.
Storage Vulnerability Map
Mobile (Android)
β SharedPreferences (plaintext)β SQLite without encryptionβ Android Keystore APIβ EncryptedSharedPreferences
Web / Cloud
β Passwords in localStorageβ S3 bucket β public accessβ Secrets Manager (AWS/Azure)β AES-256 at rest + TLS in transit