Exploit database

GH-4d52aa97536c6d29734073c020ee88f0

horkimhab/cve-2026-73570

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-73570

5 sources

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

Repository files6
horkimhab/cve-2026-73570Revision 36d3d97f193a

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

zimbraKing-jishino567/zimbra_cve_checker.py

Python · 19,424 bytes
#!/usr/bin/env python3
"""
Zimbra CVE checker helper (multi-line: 8.8.15 and 10.x).

Workflow:
  1. Extract ZmSettings.js from a zimbra-mbox-webclient-war .deb.
  2. Inside it is a build string like  8.8.15_GA_4581  or  10.1.1_GA_4660.
  3. This tool resolves that to a release and lists the CVEs that still
     affect it (CVEs whose fix shipped in a LATER release).

Two release "schemes", picked automatically from the version:
  * 8.8.15  -> BUILD scheme: every patch shares the version 8.8.15 and differs
               only by build number, so a build->patch map is required, then
               CVEs are matched by patch level.
  * 10.x    -> VERSION scheme: the dotted version (10.1.1) IS the release.
               CVEs are matched by comparing dotted versions per minor series
               (a 10.1.x host is compared against each CVE's '10.1' fix).

Examples:
    python zimbra_cve_checker.py 8.8.15_GA_4581
    python zimbra_cve_checker.py 10.1.1_GA_4660
    python zimbra_cve_checker.py 4581                 # bare build (assumes 8.8.15)
    python zimbra_cve_checker.py path/to/ZmSettings.js
    python zimbra_cve_checker.py 10.1.1_GA_4660 --json
    python zimbra_cve_checker.py --update-map         # refresh 8.8.15 build->patch map

Stdlib only. No third-party dependencies.
"""

import argparse
import json
import os
import re
import sys
import urllib.request

HERE = os.path.dirname(os.path.abspath(__file__))
DATA = os.path.join(HERE, "data")

VERSION_RE = re.compile(r"(\d+\.\d+\.\d+)_GA_(\d+)")
# Broader: <version>_<channel>_<build>, where channel is GA / ZEXTRAS / NETWORK /
# FOSS / etc. For GA the trailing token is a numeric build number; for other
# channels (e.g. Zextras/Carbonio) it is a build *date*, not a GA build number.
CLIENT_VERSION_RE = re.compile(r"(\d+\.\d+\.\d+)_([A-Za-z0-9]+)_([A-Za-z0-9]+)")
# Pull the value straight out of the ZmSettings.js "CLIENT_VERSION" registration.
CLIENT_VERSION_SETTING_RE = re.compile(r'CLIENT_VERSION"[^}]*?defaultValue:\s*"([^"]+)"')
SEVERITY_ORDER = {"critical": 0, "high": 1, "medium": 2, "low": 3, "unknown": 4}


def find_client_version_string(text):
    """Return the verbatim '<version>_<channel>_<build>' string from JS/text
    (preferring the explicit CLIENT_VERSION setting), or None."""
    setting = CLIENT_VERSION_SETTING_RE.search(text)
    if setting:
        inner = CLIENT_VERSION_RE.search(setting.group(1))
        if inner:
            return inner.group(0)
    match = CLIENT_VERSION_RE.search(text)
    return match.group(0) if match else None


def _parse_client_version(text):
    """(version, build_or_None, channel) for the CLIENT_VERSION string in `text`,
    or None. Only GA channels yield a numeric build; non-GA suffixes are dates."""
    cv = find_client_version_string(text)
    if cv is None:
        return None
    m = CLIENT_VERSION_RE.match(cv)
    version, channel, stamp = m.group(1), m.group(2).upper(), m.group(3)
    build = int(stamp) if (channel == "GA" and stamp.isdigit()) else None
    return version, build, channel

# Release-line registry. Detection is by version prefix (longest match wins).
LINES = {
    "8.8.15": {
        "label": "8.8.15",
        "scheme": "build",
        "builds": os.path.join(DATA, "8.8.15", "builds.json"),
        "cves": os.path.join(DATA, "8.8.15", "cves.json"),
    },
    "9.0.0": {
        "label": "9.0.0",
        "scheme": "build",
        "builds": os.path.join(DATA, "9.0.0", "builds.json"),
        "cves": os.path.join(DATA, "9.0.0", "cves.json"),
    },
    "10.": {
        "label": "10.x",
        "scheme": "version",
        "cves": os.path.join(DATA, "10.x", "cves.json"),
    },
}
DEFAULT_LINE = "8.8.15"  # used when only a bare build number is given


def covered_labels():
    return ", ".join(sorted(cfg["label"] for cfg in LINES.values()))


# --------------------------------------------------------------------------- #
# helpers
# --------------------------------------------------------------------------- #
def load_json(path):
    with open(path, "r", encoding="utf-8") as fh:
        return json.load(fh)


def vtuple(v):
    """'10.1.1' -> (10, 1, 1); tolerant of extra/fewer parts."""
    parts = re.findall(r"\d+", v)
    return tuple(int(p) for p in parts) if parts else (0,)


def minor_key(v):
    parts = v.split(".")
    return ".".join(parts[:2])


def detect_line(version):
    """Return the LINES key whose prefix matches the version, longest first."""
    if version is None:
        return DEFAULT_LINE
    for key in sorted(LINES, key=len, reverse=True):
        if version.startswith(key):
            return key
    return None


# --------------------------------------------------------------------------- #
# parsing the input
# --------------------------------------------------------------------------- #
def extract_build(token):
    """
    Accepts a full build string ('8.8.15_GA_4581', '10.1.1_GA_4660',
    '9.0.0_ZEXTRAS_20220713'), a bare build number, or a path to a file
    (ZmSettings.js) containing a CLIENT_VERSION string.
    Returns (version_str_or_None, build_int_or_None, channel_or_None).

    `build` is set only for GA builds (the suffix is a real build number); for
    non-GA channels (ZEXTRAS, NETWORK, ...) the suffix is a build date, so it is
    None and the patch level can't be resolved from it.
    """
    if os.path.isfile(token):
        with open(token, "r", encoding="utf-8", errors="ignore") as fh:
            text = fh.read()
        parsed = _parse_client_version(text)
        if parsed is None:
            raise ValueError(
                f"No CLIENT_VERSION '<version>_<channel>_<build>' string found inside {token!r}."
            )
        return parsed

    parsed = _parse_client_version(token)
    if parsed is not None:
        return parsed

    if token.isdigit():
        return None, int(token), "GA"

    raise ValueError(
        f"Could not parse {token!r}. Expected '8.8.15_GA_4581', '10.1.1_GA_4660', "
        "'9.0.0_ZEXTRAS_20220713', a bare build number, or a path to ZmSettings.js."
    )


# --------------------------------------------------------------------------- #
# BUILD scheme (8.8.15 / 9.0.0-style)
# --------------------------------------------------------------------------- #
def resolve_patch(build, build_map):
    """Returns (patch_or_None, exact_bool, note)."""
    if build in build_map:
        return build_map[build], True, "exact match"

    known = sorted(build_map)
    lower = [b for b in known if b < build]
    higher = [b for b in known if b > build]
    if lower and higher:
        lo, hi = lower[-1], higher[0]
        return (None, False,
                f"unknown build; lies between P{build_map[lo]} (build {lo}) and "
                f"P{build_map[hi]} (build {hi}). Run --update-map for an exact answer.")
    if lower:
        lo = lower[-1]
        return (None, False,
                f"unknown build; newer than highest known build {lo} (P{build_map[lo]}). "
                "Run --update-map.")
    if higher:
        hi = higher[0]
        return (None, False,
                f"unknown build; older than lowest known build {hi} (P{build_map[hi]}). "
                "Run --update-map.")
    return None, False, "build map is empty; run --update-map."


def report_build_scheme(report, line_cfg, build):
    build_map = {int(k): int(v) for k, v in load_json(line_cfg["builds"])["builds"].items()}
    cve_db = load_json(line_cfg["cves"])

    patch, exact, note = resolve_patch(build, build_map)
    label = line_cfg["label"]
    if patch is None:
        report["release"] = None
    elif patch == 0:
        report["release"] = f"{label} GA"
    else:
        report["release"] = f"{label} Patch {patch}"
    report["release_exact"] = exact
    report["resolution_note"] = note
    if patch is None:
        return report

    hits = []
    for c in cve_db["cves"]:
        if patch < c["fixed_in_patch"]:
            hits.append(_norm(c, f"P{c['fixed_in_patch']}"))
    report["affected_cves"] = _sort_hits(hits)
    report["summary"] = _summary(hits)
    return report


# --------------------------------------------------------------------------- #
# VERSION scheme (10.x-style)
# --------------------------------------------------------------------------- #
def report_version_scheme(report, line_cfg, version):
    cve_db = load_json(line_cfg["cves"])
    known_minors = set(cve_db["_meta"].get("known_minors", []))
    mk = minor_key(version)

    report["release"] = version
    report["release_exact"] = True
    if mk not in known_minors:
        report["resolution_note"] = (
            f"minor series {mk} is not covered by the dataset "
            f"(known: {sorted(known_minors)}); results may be incomplete.")
    else:
        report["resolution_note"] = f"matched minor series {mk}"

    cur = vtuple(version)
    hits = []
    for c in cve_db["cves"]:
        fixed = c["fixed_in"].get(mk)
        if fixed and cur < vtuple(fixed):
            hits.append(_norm(c, fixed))
    report["affected_cves"] = _sort_hits(hits)
    report["summary"] = _summary(hits)
    return report


# --------------------------------------------------------------------------- #
# normalisation / shared reporting
# --------------------------------------------------------------------------- #
def _norm(c, fixed_label):
    return {
        "cve": c["cve"],
        "severity": c.get("severity", "unknown"),
        "cvss": c.get("cvss", "?"),
        "exploited_in_wild": c.get("exploited_in_wild", False),
        "confidence": c.get("confidence", "medium"),
        "description": c.get("description", ""),
        "remediation_note": c.get("remediation_note"),
        "fixed_label": fixed_label,
    }


def _sort_hits(hits):
    hits.sort(key=lambda c: (SEVERITY_ORDER.get(c["severity"], 4), c["fixed_label"]))
    return hits


def _summary(hits):
    return {
        "total": len(hits),
        "critical": sum(1 for c in hits if c["severity"] == "critical"),
        "high": sum(1 for c in hits if c["severity"] == "high"),
        "exploited_in_wild": sum(1 for c in hits if c["exploited_in_wild"]),
        "needs_verification": sum(1 for c in hits if c["confidence"] == "verify"),
    }


def build_report(token):
    version, build, channel = extract_build(token)
    line = detect_line(version)

    report = {
        "input": token,
        "version": version,
        "build": build,
        "channel": channel,
        "line": line,
        "release": None,
        "release_exact": False,
        "resolution_note": "",
        "out_of_scope": False,
        "affected_cves": [],
        "summary": {},
    }

    if line is None:
        report["out_of_scope"] = True
        report["resolution_note"] = (
            f"version {version} is not in any known release line "
            f"(covered: {covered_labels()}).")
        return report

    cfg = LINES[line]
    if cfg["scheme"] == "build":
        if build is None:
            # Non-GA build (e.g. Zextras/Carbonio) or no numeric build: the
            # suffix is a date, so the patch level can't be resolved.
            report["resolution_note"] = _non_ga_note(version, channel, line)
            return report
        return report_build_scheme(report, cfg, build)

    report = report_version_scheme(report, cfg, version)
    if channel and channel != "GA":
        report["resolution_note"] += (
            f"  Note: '{channel}' build (likely Zextras/Carbonio) — the Zimbra GA "
            "advisory data may not map exactly to this product.")
    return report


def _non_ga_note(version, channel, line):
    label = LINES[line]["label"] if line in LINES else version
    if channel and channel != "GA":
        return (
            f"{version} '{channel}' build — the suffix is a build date, not a Zimbra GA build number, so the "
            f"{label} patch level can't be resolved. This looks like a Zextras/Carbonio build; the Zimbra GA "
            "build->patch map and CVE data may not apply. If you know the patch level, query it directly "
            "(--line/--patch, or the GUI's 'look up by patch')."
        )
    return f"no GA build number was found, so the {label} patch level can't be resolved."


# --------------------------------------------------------------------------- #
# --update-map scraper (8.8.15 build->patch)
# --------------------------------------------------------------------------- #
def update_map(max_patch=60, timeout=20):
    builds_path = LINES["8.8.15"]["builds"]
    base = "https://wiki.zimbra.com/index.php?title=Zimbra_Releases/8.8.15"
    pages = ["", *[f"/P{n}" for n in range(1, max_patch + 1)]]
    found = {}
    for suffix in pages:
        patch = 0 if suffix == "" else int(suffix.lstrip("/P"))
        url = f"{base}{suffix}&action=raw"
        try:
            req = urllib.request.Request(url, headers={"User-Agent": "zimbra-cve-checker/1.0"})
            with urllib.request.urlopen(req, timeout=timeout) as resp:
                text = resp.read().decode("utf-8", "ignore")
        except Exception as exc:  # noqa: BLE001
            print(f"  P{patch:<3} skip ({exc})", file=sys.stderr)
            continue
        m = VERSION_RE.search(text)
        if m:
            found[int(m.group(2))] = patch
            print(f"  P{patch:<3} -> build {m.group(2)}")
        else:
            print(f"  P{patch:<3} no build string on page", file=sys.stderr)

    if not found:
        print("No builds scraped (network/format issue). Map unchanged.", file=sys.stderr)
        return
    data = load_json(builds_path)
    merged = {int(k): int(v) for k, v in data["builds"].items()}
    merged.update(found)
    data["builds"] = {str(k): v for k, v in sorted(merged.items())}
    with open(builds_path, "w", encoding="utf-8") as fh:
        json.dump(data, fh, indent=2)
    print(f"\nUpdated {builds_path} with {len(found)} scraped builds ({len(merged)} total).")


# --------------------------------------------------------------------------- #
# printing
# --------------------------------------------------------------------------- #
def print_report(r):
    print("=" * 70)
    print("  Zimbra build fingerprint")
    print("=" * 70)
    print(f"  input          : {r['input']}")
    print(f"  version        : {r['version'] or '(bare build, assumed ' + DEFAULT_LINE + ')'}")
    print(f"  build number   : {r['build'] if r['build'] is not None else 'n/a'}")
    if r.get("channel"):
        print(f"  channel        : {r['channel']}")
    line_label = LINES[r["line"]]["label"] if r["line"] in LINES else "UNKNOWN"
    print(f"  release line   : {line_label}")

    if r["out_of_scope"]:
        print(f"  release        : OUT OF SCOPE")
        print(f"  note           : {r['resolution_note']}")
        print("-" * 70)
        print(f"  No dataset for this version. Covered lines: {covered_labels()}")
        return

    if r["release"] is not None:
        kind = "exact" if r["release_exact"] else "ESTIMATE"
        print(f"  release        : {r['release']}  ({kind})")
    else:
        print(f"  release        : UNRESOLVED")
    print(f"  note           : {r['resolution_note']}")
    print("-" * 70)

    if r["release"] is None:
        print("  Cannot list CVEs without a resolved release.")
        print("  Tip: run  python zimbra_cve_checker.py --update-map")
        return

    s = r["summary"]
    print(f"  CVEs affecting {r['release']}: {s['total']}  "
          f"(critical={s['critical']}, high={s['high']}, "
          f"exploited-in-wild={s['exploited_in_wild']})")
    print("-" * 70)
    if not r["affected_cves"]:
        print("  No known CVEs in the database affect this release.")
        print("  (DB is curated, not exhaustive -- absence is not proof of safety.)")
    for c in r["affected_cves"]:
        flags = []
        if c["exploited_in_wild"]:
            flags.append("EXPLOITED-IN-WILD")
        if c["confidence"] == "verify":
            flags.append("VERIFY-FIX")
        flag_str = ("  [" + ", ".join(flags) + "]") if flags else ""
        cvss = c["cvss"] if c["cvss"] is not None else "n/a"
        print(f"  {c['cve']:<18} {c['severity'].upper():<8} CVSS {str(cvss):<4} "
              f"fixed in {c['fixed_label']}{flag_str}")
        print(f"      {c['description']}")
        if c["remediation_note"]:
            print(f"      remediation: {c['remediation_note']}")
    print("-" * 70)
    if s["needs_verification"]:
        print(f"  NOTE: {s['needs_verification']} entr(y/ies) flagged VERIFY-FIX -- confirm "
              "the fixed version against:")
        print("        https://wiki.zimbra.com/wiki/Zimbra_Security_Advisories")
    print("  Build/version -> CVE data is best-effort triage, not authoritative")
    print("  compliance evidence.")


def report_for_patch(line, patch):
    """Build a report directly from a patch number (no build needed), for the
    build-scheme lines (8.8.15, 9.0.0)."""
    if line not in LINES or LINES[line]["scheme"] != "build":
        raise ValueError(f"--patch needs a patch-based line: "
                         f"{[k for k, v in LINES.items() if v['scheme'] == 'build']}")
    cfg = LINES[line]
    label = cfg["label"]
    release = f"{label} GA" if patch == 0 else f"{label} Patch {patch}"
    report = {"input": release, "version": line, "build": None, "channel": "GA", "line": line,
              "release": release, "release_exact": True,
              "resolution_note": "patch specified directly", "out_of_scope": False,
              "affected_cves": [], "summary": {}}
    cve_db = load_json(cfg["cves"])
    hits = [_norm(c, f"P{c['fixed_in_patch']}") for c in cve_db["cves"]
            if patch < c["fixed_in_patch"]]
    report["affected_cves"] = _sort_hits(hits)
    report["summary"] = _summary(hits)
    return report


# --------------------------------------------------------------------------- #
def main(argv=None):
    ap = argparse.ArgumentParser(description="Map a Zimbra build to its release and known CVEs.")
    ap.add_argument("target", nargs="?",
                    help="Build string, bare build number, or path to ZmSettings.js")
    ap.add_argument("--line", help="release line for --patch (e.g. 8.8.15, 9.0.0)")
    ap.add_argument("--patch", type=int,
                    help="query by patch number directly, e.g. --line 9.0.0 --patch 38")
    ap.add_argument("--json", action="store_true", help="Emit machine-readable JSON")
    ap.add_argument("--update-map", action="store_true",
                    help="Scrape the Zimbra wiki to refresh the 8.8.15 build->patch map")
    ap.add_argument("--max-patch", type=int, default=60,
                    help="Highest patch number to probe when updating the map (default 60)")
    args = ap.parse_args(argv)

    if args.update_map:
        update_map(max_patch=args.max_patch)
        return 0

    try:
        if args.patch is not None:
            report = report_for_patch(args.line or DEFAULT_LINE, args.patch)
        elif args.target:
            report = build_report(args.target)
        else:
            ap.error("provide a build string / ZmSettings.js path, --line/--patch, or --update-map")
    except ValueError as exc:
        print(f"error: {exc}", file=sys.stderr)
        return 2

    if args.json:
        print(json.dumps(report, indent=2))
    else:
        print_report(report)
    return 0


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