CVE-2025-68616: WeasyPrint SSRF Protection Bypass via HTTP Redirect
Summary
CVE-2025-68616: WeasyPrint has a Server-Side Request Forgery (SSRF) Protection Bypass via HTTP Redirect. Affects weasyprint versions < 68.0. Fixed in 68.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
WeasyPrint is a popular open-source library used for generating PDF documents from HTML and CSS. It is widely utilized in web applications to create printable documents. The library allows developers to define custom URL fetching mechanisms to enhance security by validating or sanitizing URLs before fetching them. However, a critical vulnerability exists that undermines these security measures.
Vulnerability Detail
The vulnerability in WeasyPrint arises from its default URL fetching mechanism, which is susceptible to a Server-Side Request Forgery (SSRF) Protection Bypass. This occurs because the underlying urllib library automatically follows HTTP redirects without re-evaluating the new destination against the developer's security policies. An attacker can exploit this by providing a URL that initially passes validation but redirects to a blocked internal resource, leading to unauthorized access to sensitive internal services or cloud metadata endpoints.
How To Fix
Minimum fixed version
68.0
This is the first release that contains the fix.
pip install --upgrade "weasyprint==68.0"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, developers can implement additional checks in their custom url_fetcher function to validate the final destination after a redirect. Here is an example of how to enhance the secure_fetcher function:
from weasyprint import default_url_fetcher
# Enhanced Security Filter
def secure_fetcher(url):
# Check for both 'localhost' and any internal IP ranges
if "localhost" in url or url.startswith("http://127."):
raise PermissionError(f"Security Block: Access to {url} denied.")
print(f"[ALLOWED] Initial URL check passed for: {url}")
return default_url_fetcher(url)
Conclusion
The SSRF Protection Bypass vulnerability in WeasyPrint (CVE-2025-68616) poses significant risks to applications that rely on this library for PDF generation. It is crucial for developers to update to the patched version and consider implementing additional security measures to protect against potential exploits.
See every vulnerability recorded for weasyprint →
FAQ
CVE-2025-68616 is a vulnerability in WeasyPrint that allows attackers to bypass SSRF protections through HTTP redirects.
This vulnerability can lead to unauthorized access to internal services or sensitive data, potentially allowing attackers to exploit internal network resources.
Implement additional checks in your custom url_fetcher to validate the final destination after redirects as a temporary workaround.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
The CVSS score of this vulnerability is 7.5, indicating a high severity level.
References
Related vulnerabilities
Recent vulnerabilities recorded for weasyprint.