Exploit database

GH-ee13c92a8082cc1f7ec7f7f240773733

vulpecuna/cve-2026-87902

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-87902

16 sources

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

Repository files17
vulpecuna/cve-2026-87902Revision d59503455cd9

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

lab/themes.py

Python · 3,697 bytes
#!/usr/bin/env python3
"""wp-themes - rebuilds themes.json, the per-theme facts poc.py reads.

Usage:
    python3 lab/themes.py [--survey lab/survey.json] [--cache lab/.cache]
                          [--out themes.json]

Reads the archives already in the cache and records, per theme, the one thing
that decides whether CVE-2026-87902 is reachable on it:

  page_dirs    a top-level page-* directory. The template name is built as
               "page-{pagename}.php", so the first path segment has to be a
               directory the theme really ships, or the include resolves to
               nothing. A theme that ships one is affected; a theme that does
               not cannot be driven through this sink at all.

  front_page   whether the theme ships front-page.php. Not a criterion: it
               only means the front page id is the wrong one to hang the
               request on, because the loader answers is_front_page first.

Downloads nothing: a theme with no archive in the cache is written with
"front_page": null, meaning unmeasured.

Exit codes: 0 written, 2 no survey or no cache, 3 usage.
"""
import argparse
import json
import os
import sys
import zipfile

HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(HERE)


def archives(cache: str) -> dict:
    """slug -> newest archive on disk, from <slug>.<version>.zip."""
    found = {}
    for name in sorted(os.listdir(cache)):
        if not name.endswith(".zip"):
            continue
        slug = name[:-4].split(".")[0]
        found.setdefault(slug, name)
    return found


def ships(path: str, slug: str, name: str) -> bool:
    with zipfile.ZipFile(path) as bundle:
        return f"{slug}/{name}" in bundle.namelist()


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
    parser.add_argument("--survey", default=os.path.join(HERE, "survey.json"))
    parser.add_argument("--cache", default=os.path.join(HERE, ".cache"))
    parser.add_argument("--out", default=os.path.join(ROOT, "themes.json"))
    try:
        arguments = parser.parse_args()
    except SystemExit as usage:
        raise SystemExit(3 if usage.code else 0) from None

    try:
        with open(arguments.survey, encoding="utf-8") as handle:
            survey = json.load(handle)
        held = archives(arguments.cache)
    except (OSError, ValueError) as absent:
        print(absent, file=sys.stderr)
        return 2

    themes, measured = [], 0
    for entry in survey["themes"]:
        row = {"slug": entry["slug"], "version": entry["version"],
               "installs": entry["installs"], "page_dirs": entry["page_dirs"],
               "front_page": None}
        archive = held.get(entry["slug"])
        if archive:
            row["front_page"] = ships(os.path.join(arguments.cache, archive),
                                      entry["slug"], "front-page.php")
            measured += 1
        themes.append(row)

    themes.sort(key=lambda row: (not row["page_dirs"], -row["installs"]))
    with open(arguments.out, "w", encoding="utf-8") as sink:
        json.dump({"cve": "CVE-2026-87902", "ghsa": "GHSA-7hp8-65ch-5whp",
                   "source": os.path.relpath(arguments.survey, ROOT).replace(os.sep, "/"),
                   "themes": themes}, sink, indent=1)

    carry = [row for row in themes if row["page_dirs"]]
    print(f"{len(themes)} themes, {len(carry)} ship a page-* directory and are "
          f"affected: " + ", ".join(row["slug"] for row in carry))
    print(f"{measured} measured from the cache, "
          f"{len(themes) - measured} left unmeasured")
    return 0


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