/

CVE-2025-68616

Severity:

HIGH RISK

(7.5)

SSRF in WeasyPrint default_url_fetcher

CVE-2025-68616

Modified

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-601, CWE-918

Impact:

Unauthorized access to internal network resources via SSRF

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

WeasyPrint's default URL fetching logic can be abused to bypass server-side request forgery (SSRF) protections by following HTTP redirects without reapplying custom security checks.

When an application relies on a custom url_fetcher to block access to internal resources, attackers can still reach those resources if an initially allowed URL redirects to a forbidden target that is not revalidated against the developer's policy.

Affected context

This vulnerability appears in applications that:

  • Use WeasyPrint to generate PDFs or other documents from web content
  • Rely on default_url_fetcher directly, or wrap/extend it within a custom url_fetcher
  • Intend to block internal or sensitive endpoints (e.g., localhost, 169.254.169.254, in-cluster services, internal admin panels)
  • Process attacker-controlled or partially untrusted URLs inside WeasyPrint

The issue surfaces specifically when an initially permitted URL returns an HTTP redirect (3xx) to a second URL that would normally be blocked by the application's SSRF policy.

Exploit preconditions

  • Attack surface: WeasyPrint's URL fetching mechanism, typically invoked when converting HTML/CSS that references external URLs (images, stylesheets, fonts, etc.).
  • Required access: Ability to influence or supply URLs that WeasyPrint will fetch, such as via user-submitted HTML, templates with user-controlled attributes, or input parameters feeding into PDF generation.
  • Trigger point: A crafted URL that:
  1. Points to an attacker-controlled endpoint or otherwise allowed host, and
  2. Responds with an HTTP redirect to a disallowed internal resource (e.g., http://127.0.0.1:..., cloud metadata URLs, or private services).
  • Why exploitation is possible: The underlying urllib client automatically follows redirects and fetches the new location without re-validating the final destination against the application's custom url_fetcher security policy, effectively bypassing SSRF filtering logic.

Why this happens

The core issue stems from trusting automatic redirect handling in a lower-level HTTP library without enforcing security checks on the final redirect target.

In WeasyPrint's default_url_fetcher, the initial URL may be screened or constrained by a custom url_fetcher implementation, but once the request is handed off to urllib, subsequent redirects are followed implicitly. Because the redirected URL is not re-run through the developer's SSRF policy, an attacker can chain an allowed external host with a redirect to an internal or otherwise restricted host.

This behavior aligns with:

  • CWE-918 (Server-Side Request Forgery): The server-side component (WeasyPrint) is induced to make network requests to attacker-chosen internal resources.
  • CWE-601 (URL Redirection to Untrusted Site): Redirects are followed in a way that changes the ultimate target to one outside the intended trust boundary, without revalidation.

Conceptually, the bug is an insufficient validation of the redirected destination, allowing internal network access through automatic redirect following.

Potential impact

  • Unauthorized access to internal HTTP services (e.g., localhost-bound admin APIs, debug interfaces).
  • Exposure of cloud or container metadata services (e.g., 169.254.169.254), which can lead to credential leakage.
  • Interaction with internal microservices that were assumed to be unreachable from the outside, potentially influencing their state.
  • Use of internal services as an oracle for network scanning or service discovery (e.g., timing differences, error responses).
  • Potential pivot point for more complex attacks if internal endpoints expose sensitive operations or misconfigured admin panels.

General mitigation guidance

Effective mitigation focuses on constraining outbound requests, controlling redirect behavior, and centralizing URL validation:

  • Enforce policy on the final URL after redirects:
  • Treat the "effective URL" (post-redirect) as the one that must pass SSRF checks.
  • Apply host, scheme, and IP-based allowlists/denylists to the resolved destination.
  • Restrict or disable automatic redirect following for untrusted input:
  • Use HTTP clients that expose hooks or callbacks on redirect events so the application can re-validate targets.
  • Consider failing closed on unexpected or multi-hop redirects when processing user-influenced URLs.
  • Normalize and resolve URLs before validation:
  • Resolve hostnames to IP addresses and check against reserved ranges (localhost, RFC1918, link-local, metadata IPs).
  • Canonicalize URLs before applying policy, so different representations of the same internal address can't bypass filters.
  • Apply defense-in-depth at the network layer:
  • Use network-level egress controls (e.g., firewall rules, security groups) to prevent application containers from reaching sensitive metadata endpoints and internal admin services.
  • Segregate WeasyPrint-running workloads into network segments with limited outbound access.
  • Design custom url_fetcher implementations to be secure by default:
  • Default to blocking all non-essential outbound requests and selectively allow specific domains and schemes.
  • Log and monitor blocked attempts for anomaly detection and policy tuning.

How teams detect issues like this

Detection typically combines code-level review, configuration analysis, and behavioral monitoring:

  • Static analysis and code review:
  • Look for uses of WeasyPrint's default_url_fetcher or wrappers that delegate to underlying HTTP libraries with automatic redirects enabled.
  • Flag any custom url_fetcher that validates only the initial URL but does not account for redirect targets.
  • Check for absence of explicit redirect policies (e.g., no maximum redirect hops, no validation of Location headers).
  • Policy and configuration audits:
  • Review SSRF defense policies to ensure they operate on the final resolved URL (including redirects and DNS resolution).
  • Inspect network egress rules for applications using WeasyPrint to confirm that sensitive local ranges are blocked.
  • Runtime and log-based monitoring:
  • Instrument logging for all URLs fetched by WeasyPrint, including both initial and redirected URLs.
  • Alert on requests targeting localhost, reserved IP ranges, or metadata services from application workloads.
  • Use HTTP access logs or proxy logs to identify suspicious redirect chains originating from PDF generation workflows.
  • Security testing and CI integration:
  • Incorporate SSRF-focused tests in QA, using controlled redirect endpoints to verify that internal URLs cannot be reached through multi-step redirects.
  • Leverage automated SAST/DAST tools that include SSRF and open-redirect patterns in their rule sets, while validating SSRF policies in CI pipelines.

Sources

SourceLink
github.comgithub.com/Kozea/WeasyPrint/commit/b6a14f0f3f4ce9c0c75c1a2d73cb1c5d43f0e565
github.comgithub.com/Kozea/WeasyPrint/security/advisories/GHSA-983w-rhvv-gwmv
access.redhat.comaccess.redhat.com/security/cve/CVE-2025-68616
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2430858
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-68616.json

Frequently asked

questions

Yes, if an attacker can cause WeasyPrint to fetch URLs based on externally supplied input (for example, through user-supplied HTML or parameters passed into the PDF generation process). In that scenario, the attacker can set up redirect chains that reach internal resources.

The attacker typically needs only the ability to influence or specify URLs that WeasyPrint will fetch, not shell or filesystem access. They do not need direct network access to the internal services; instead, they abuse the server's network position via SSRF.

The safest pattern is to enforce SSRF validation on the final, post-redirect URL and to tightly restrict where WeasyPrint is allowed to connect. This often means disabling implicit redirects for untrusted URLs or intercepting every redirect step to reapply strict allowlist/denylist checks on the effective destination.

Future designs should treat every network request made on behalf of user-controllable input as potentially hostile. This includes:

  • Validating fully resolved URLs (after redirects and DNS resolution) against strict allowlists.
  • Minimizing or disabling automatic redirect following where not strictly necessary.
  • Combining application-layer controls with network egress restrictions.
  • Making SSRF-safe URL fetching utilities a shared, well-reviewed component rather than re-implementing ad hoc logic in each feature.
Find out what's already
exploitable in your codebase.