Vulnerabilities in pkg:pypi/unstructured

PACKAGE
Advisory Identifier: GHSA-v5mq-3xhg-98m9
Advisory Summary

CVE-2026-104250 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting unstructured libraries in the PyPI ecosystem. The issue involves stored xss via unescaped html generation. Remediation is available by upgrading affected packages to version 0.24.1.

4 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/unstructured

4 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/unstructured. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-v5mq-3xhg-98m9 CVE-2026-104250 MODERATE unstructured: Stored XSS via unescaped HTML generation
GHSA-4mvj-m6j5-pmf7 CVE-2026-71428 CRITICAL unstructured: Server-Side Request Forgery in the URL-based partitioning
GHSA-gm8q-m8mv-jj5m CVE-2025-64712 CRITICAL Unstructured has Path Traversal via Malicious MSG Attachment that Allows Arbitrary File Write
GHSA-32r8-54hf-c9p3 CVE-2024-46455 MODERATE unstructured XML External Entity (XXE)

CVE-2026-104250 at a Glance

CVE Identifier CVE-2026-104250
GHSA Identifier GHSA-v5mq-3xhg-98m9
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product unstructured
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-104250

To remediate this vulnerability, upgrade all affected unstructured dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

unstructured fixed: 0.24.1
pip install unstructured>=0.24.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show unstructured

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-104250, inspect your installed packages using pip:

pip show unstructured

Analyze the terminal output to locate any version of unstructured in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.24.1), your application is affected.

Note: The pip show unstructured command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In unstructured, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary When `unstructured` parses an untrusted document and outputs the result as HTML, malicious markup contained in the document (e.g. `<img src=x onerror=...>`) is left in the output HTML without escaping. When that output is displayed in a browser, the script embedded in the document executes in the viewer's browser. ### Details `partition_html(html_parser_version="v2")` (and the VLM partitioner) preserve the input document's element tags, attributes, and text into `metadata.text_as_html`, and `elements_to_html()` outputs that as an HTML document. The function that builds HTML on this path, `to_html()` in `unstructured/documents/ontology.py`, performs no escaping at all. As a result, event handlers such as `onerror` / `onmouseover` / `onload` originating from the input document are left in the output HTML as-is (literal `<script>` tags are stripped by the parser, but attribute-based vectors and `javascript:` URLs are not). In addition, link URLs are not scheme-filtered, so `<a href="javascript:...">` is also emitted. Relevant source: `documents/ontology.py` (`to_html`, `_construct_attribute_string`, `_generate_final_html`); `partition/html/transformations.py` (`text_as_html = ontology_element.to_html()`); `partition/html/convert.py` (`elements_to_html`). ### PoC Environment: `downloads.unstructured.io/unstructured-io/unstructured:latest`, `unstructured` 0.23.3. ```python from unstructured.partition.html import partition_html from unstructured.partition.html.convert import elements_to_html malicious = ('<body class="Document">' '<p class="Paragraph" onmouseover="alert(1)">hello' '<img src=x onerror="alert(document.domain)"></p>' '<a class="Hyperlink" href="javascript:alert(document.cookie)">click me</a>' '</body>') els = partition_html(text=malicious, html_parser_version="v2") open("xss_output.html", "w").write(elements_to_html(list(els), no_group_by_page=True)) ``` `elements_to_html()` output body — the unescaped vectors survive: ```html <p class="NarrativeText" id="..." onmouseover="alert(1)"> <p class="Paragraph">hello</p> <img class="Image" onerror="alert(document.domain)" src="x"/> </p> <a class="UncategorizedText" href="javascript:alert(document.cookie)" id="...">click me</a> ``` Opening `xss_output.html` in a browser fires `alert` automatically (via `<img onerror>`), with no interaction. Per-vector confirmation (each payload labelled, each verified in a browser): | Vector | Trigger | Cause | |---|---|---| | `<img onerror>` | open file (auto) | element `text` not escaped | | `<svg onload>` (via `title='"><svg ...>'`) | open file (auto) | attribute value not escaped (`"` breakout) | | `<a href=javascript:>` | click | link URL scheme not filtered | | `onmouseover` | hover | source attribute preserved as-is | ### Impact Stored XSS caused by improper output encoding. Anyone who renders the HTML or `text_as_html` generated from an untrusted document is affected. In an ingestion pipeline where uploaded documents are parsed and a staff member reviews their contents in a web UI, a low-privileged or external submitter can inject malicious HTML; when a privileged reviewer later opens the parsed result, `<img onerror>` fires in their session with no interaction, leading to cross-record information disclosure and privileged actions.

CVE-2026-104250 Affected unstructured Versions

1 component(s)
Fixed Versions:
0.24.1
Product / Package Ecosystem Affected Versions Fixed Version
unstructured
PyPI
< 0.24.1
0.24.1

References

Frequently Asked Questions

What is CVE-2026-104250?
CVE-2026-104250 is a security vulnerability in unstructured involving Stored XSS via unescaped HTML generation under CWE-116: Improper Encoding or Escaping of Output.
Which unstructured versions are affected?
Affected versions include releases prior to 0.24.1 across affected packages: unstructured.
What version fixes CVE-2026-104250?
Upgrading to 0.24.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is unstructured affected?
Yes, unstructured is affected in releases prior to 0.24.1. Upgrade your dependency to 0.24.1 or later.
What is the CVSS score of CVE-2026-104250?
CVE-2026-104250 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2026-104250?
CVE-2026-104250 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check PyPI dependencies for CVE-2026-104250?
Run the dependency tree command: 'pip show unstructured'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-v5mq-3xhg-98m9",
  "modified" : "2026-10-15T20:16:18Z",
  "published" : "2026-10-15T20:16:18Z",
  "aliases" : [ "CVE-2026-104250" ],
  "summary" : "unstructured: Stored XSS via unescaped HTML generation",
  "details" : "### Summary\n\nWhen `unstructured` parses an untrusted document and outputs the result as HTML, malicious markup contained in the document (e.g. `<img src=x onerror=...>`) is left in the output HTML without escaping. When that output is displayed in a browser, the script embedded in the document executes in the viewer's browser.\n\n### Details\n\n`partition_html(html_parser_version=\"v2\")` (and the VLM partitioner) preserve the input document's element tags, attributes, and text into `metadata.text_as_html`, and `elements_to_html()` outputs that as an HTML document.\n\nThe function that builds HTML on this path, `to_html()` in `unstructured/documents/ontology.py`, performs no escaping at all. As a result, event handlers such as `onerror` / `onmouseover` / `onload` originating from the input document are left in the output HTML as-is (literal `<script>` tags are stripped by the parser, but attribute-based vectors and `javascript:` URLs are not). In addition, link URLs are not scheme-filtered, so `<a href=\"javascript:...\">` is also emitted.\n\nRelevant source: `documents/ontology.py` (`to_html`, `_construct_attribute_string`, `_generate_final_html`); `partition/html/transformations.py` (`text_as_html = ontology_element.to_html()`); `partition/html/convert.py` (`elements_to_html`).\n\n### PoC\n\nEnvironment: `downloads.unstructured.io/unstructured-io/unstructured:latest`, `unstructured` 0.23.3.\n\n```python\nfrom unstructured.partition.html import partition_html\nfrom unstructured.partition.html.convert import elements_to_html\n\nmalicious = ('<body class=\"Document\">'\n             '<p class=\"Paragraph\" onmouseover=\"alert(1)\">hello'\n             '<img src=x onerror=\"alert(document.domain)\"></p>'\n             '<a class=\"Hyperlink\" href=\"javascript:alert(document.cookie)\">click me</a>'\n             '</body>')\nels = partition_html(text=malicious, html_parser_version=\"v2\")\nopen(\"xss_output.html\", \"w\").write(elements_to_html(list(els), no_group_by_page=True))\n```\n\n`elements_to_html()` output body — the unescaped vectors survive:\n\n```html\n<p class=\"NarrativeText\" id=\"...\" onmouseover=\"alert(1)\">\n  <p class=\"Paragraph\">hello</p>\n  <img class=\"Image\" onerror=\"alert(document.domain)\" src=\"x\"/>\n</p>\n<a class=\"UncategorizedText\" href=\"javascript:alert(document.cookie)\" id=\"...\">click me</a>\n```\n\nOpening `xss_output.html` in a browser fires `alert` automatically (via `<img onerror>`), with no interaction. Per-vector confirmation (each payload labelled, each verified in a browser):\n\n| Vector | Trigger | Cause |\n|---|---|---|\n| `<img onerror>` | open file (auto) | element `text` not escaped |\n| `<svg onload>` (via `title='\"><svg ...>'`) | open file (auto) | attribute value not escaped (`\"` breakout) |\n| `<a href=javascript:>` | click | link URL scheme not filtered |\n| `onmouseover` | hover | source attribute preserved as-is |\n\n### Impact\n\nStored XSS caused by improper output encoding. Anyone who renders the HTML or `text_as_html` generated from an untrusted document is affected. In an ingestion pipeline where uploaded documents are parsed and a staff member reviews their contents in a web UI, a low-privileged or external submitter can inject malicious HTML; when a privileged reviewer later opens the parsed result, `<img onerror>` fires in their session with no interaction, leading to cross-record information disclosure and privileged actions.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "unstructured"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.24.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.24.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Unstructured-IO/unstructured/security/advisories/GHSA-v5mq-3xhg-98m9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-104250"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Unstructured-IO/unstructured/pull/4394"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Unstructured-IO/unstructured/commit/cda16b3f2170019be9c6ea5635946fb3eaa2d66f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Unstructured-IO/unstructured"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Unstructured-IO/unstructured/releases/tag/0.24.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116", "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-15T20:16:18Z",
    "nvd_published_at" : "2026-10-13T17:17:15Z"
  }
}