Exploit database

GH-7b5f07d84a7eaff26b3cb7289fb549ec

xingchenrs/cybermeowfians

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

166 sources

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

Repository files7

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

tools/kernel-analysis-kit/scripts/backend/cve_2026_43499_audit.py

Python · 7,484 bytes
#!/usr/bin/env python3
"""Audit an ARM64 kernel Image for the CVE-2026-43499 remove_waiter pattern."""

from __future__ import annotations

import argparse
import json
import re
import sys
from pathlib import Path
from typing import Any

from capstone import CS_ARCH_ARM64, CS_MODE_ARM, Cs

import epoll_chain_pipeline as kernel_audit


def access_from_register(lines: list[str], register: str, offset: int) -> bool:
    pattern = re.compile(
        rf"\b(?:add|ldr|str)\b.*(?:\[{register},\s*#0x{offset:x}\]|"
        rf"\b{register},\s*#0x{offset:x}\b)"
    )
    return any(pattern.search(line) for line in lines)


def current_registers(lines: list[str]) -> list[str]:
    registers: list[str] = []
    pattern = re.compile(r"\bmrs\s+(x\d+),\s*sp_el0\b")
    for line in lines:
        match = pattern.search(line)
        if match and match.group(1) not in registers:
            registers.append(match.group(1))
    return registers


def passed_as_sixth_argument(
    lines: list[str], register: str, call_offset: int
) -> bool:
    call_token = f"bl #0x{call_offset:x}"
    for index, line in enumerate(lines):
        if call_token not in line:
            continue
        window = lines[max(0, index - 12):index]
        if any(re.search(rf"\bmov\s+x5,\s*{register}\b", item) for item in window):
            return True
    return False


def render_markdown(report: dict[str, Any]) -> str:
    e = report["evidence"]
    g = report["geometry"]
    lines = [
        "# CVE-2026-43499 static audit",
        "",
        f"- Input: `{report['input']['path']}`",
        f"- Release: `{report['identity']['release']}`",
        f"- Kernel SHA-256: `{report['input']['kernel_sha256']}`",
        f"- Verdict: **{report['verdict']}**",
        "",
        "## Root-condition evidence",
        "",
        "| Check | Result |",
        "| --- | --- |",
        f"| futex PI call path present | {e['futex_pi_call_path_present']} |",
        f"| `remove_waiter` uses `sp_el0` current task | {e['uses_current_task']} |",
        f"| current-task `pi_lock` access | {e['current_pi_lock_access']} |",
        f"| current-task `pi_blocked_on` access | {e['current_pi_blocked_on_access']} |",
        f"| current passed to `rt_mutex_adjust_prio_chain` | {e['current_passed_to_adjust_chain']} |",
        "",
        "## BTF geometry",
        "",
        f"- `rt_mutex_waiter.size = 0x{g['rt_mutex_waiter_size']:x}`",
        f"- `rt_mutex_waiter.task = +0x{g['waiter_task']:x}`",
        f"- `task_struct.pi_lock = +0x{g['task_pi_lock']:x}`",
        f"- `task_struct.pi_blocked_on = +0x{g['task_pi_blocked_on']:x}`",
        "",
        "## Boundary",
        "",
        "This verdict establishes the vulnerable kernel control-flow pattern. It does not "
        "by itself validate the public exploit's stack-reclaim timing, KASLR leak, fake "
        "waiter/task geometry, direct-map profile, pipe physical-R/W stage, or Android "
        "credential/SELinux payload.",
        "",
    ]
    return "\n".join(lines)


def audit(path: Path) -> dict[str, Any]:
    target = kernel_audit.read_input(path)
    data = target["kernel"]
    _, config, _ = kernel_audit.gt.extract_ikconfig(data)
    kallsyms = kernel_audit.gt.recover_kallsyms(
        data, target["kernel_size"], target["image_size"]
    )
    btf = kernel_audit.gt.locate_btf(data, kallsyms)
    release, uname_version = kernel_audit.release_and_uname_version(
        target["kernel_version"]
    )
    md = Cs(CS_ARCH_ARM64, CS_MODE_ARM)
    names = (
        "remove_waiter",
        "rt_mutex_start_proxy_lock",
        "rt_mutex_adjust_prio_chain",
        "futex_requeue",
    )
    functions = {
        name: kernel_audit.maybe_function_info(data, kallsyms, name, md)
        for name in names
    }
    remove = functions["remove_waiter"]
    if remove["missing"]:
        raise kernel_audit.AuditError("remove_waiter is absent from recovered kallsyms")

    geometry = {
        "rt_mutex_waiter_size": btf.size("rt_mutex_waiter"),
        "waiter_task": btf.field("rt_mutex_waiter", "task"),
        "task_pi_lock": btf.field("task_struct", "pi_lock"),
        "task_pi_blocked_on": btf.field("task_struct", "pi_blocked_on"),
    }
    lines = remove["disassembly"]
    registers = current_registers(lines)
    adjust_offset = functions["rt_mutex_adjust_prio_chain"]["start"]
    uses_current = bool(registers)
    pi_lock_access = any(
        access_from_register(lines, register, geometry["task_pi_lock"])
        for register in registers
    )
    pi_blocked_access = any(
        access_from_register(lines, register, geometry["task_pi_blocked_on"])
        for register in registers
    )
    current_to_adjust = bool(adjust_offset is not None) and any(
        passed_as_sixth_argument(lines, register, adjust_offset)
        for register in registers
    )
    call_path = all(not functions[name]["missing"] for name in names)
    vulnerable = all(
        (call_path, uses_current, pi_lock_access, pi_blocked_access, current_to_adjust)
    )
    verdict = (
        "VULNERABLE_PATTERN_PRESENT"
        if vulnerable
        else "FIXED_OR_DIVERGENT_PATTERN_MANUAL_REVIEW"
    )

    return {
        "schema": 1,
        "verdict": verdict,
        "input": {key: value for key, value in target.items() if key != "kernel"},
        "identity": {"release": release, "uname_version": uname_version},
        "config": {
            "CONFIG_FUTEX": config.get("CONFIG_FUTEX"),
            "CONFIG_FUTEX_PI": config.get("CONFIG_FUTEX_PI"),
            "CONFIG_RT_MUTEXES": config.get("CONFIG_RT_MUTEXES"),
            "CONFIG_SMP": config.get("CONFIG_SMP"),
            "CONFIG_PREEMPT": config.get("CONFIG_PREEMPT"),
        },
        "geometry": geometry,
        "evidence": {
            "futex_pi_call_path_present": call_path,
            "uses_current_task": uses_current,
            "current_registers": registers,
            "current_pi_lock_access": pi_lock_access,
            "current_pi_blocked_on_access": pi_blocked_access,
            "current_passed_to_adjust_chain": current_to_adjust,
        },
        "functions": {
            name: {
                "start": info["start"],
                "size": info["size"],
                "calls": info["calls"],
                "disassembly": info["disassembly"] if name == "remove_waiter" else [],
            }
            for name, info in functions.items()
        },
    }


def main(argv: list[str] | None = None) -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--input", type=Path, required=True, help="complete ARM64 Image")
    parser.add_argument("--out-dir", type=Path, required=True)
    args = parser.parse_args(argv)
    try:
        report = audit(args.input)
        out_dir = args.out_dir.resolve()
        out_dir.mkdir(parents=True, exist_ok=True)
        (out_dir / "audit.json").write_text(
            json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8"
        )
        (out_dir / "AUDIT.md").write_text(render_markdown(report), encoding="utf-8")
        print(f"verdict: {report['verdict']}")
        print(f"kernel sha256: {report['input']['kernel_sha256']}")
        print(f"output: {out_dir}")
        return 0
    except (kernel_audit.AuditError, kernel_audit.gt.GenerationError, OSError, ValueError) as exc:
        print(f"audit failed: {exc}", file=sys.stderr)
        return 2


if __name__ == "__main__":
    raise SystemExit(main())