Summary
Stirling-PDF's URL-to-PDF conversion endpoint does not apply the SSRF protections used by related conversion endpoints. An attacker-controlled public webpage may cause the server-side WeasyPrint process to request internal services or cloud metadata resources referenced by embedded HTML elements, potentially exposing their contents in the resulting PDF.
Affected context
The issue occurs in deployments where the URL conversion endpoint fetches remote HTML and passes it to WeasyPrint for PDF generation. Although the initially requested URL is checked for public reachability, embedded resources in the fetched document may be retrieved separately without equivalent SSRF filtering. Risk depends on the server's network access, cloud environment, and the privileges available to the conversion process.
Exploit preconditions
- Attack surface: The URL-to-PDF conversion API endpoint
- Required access: Ability to submit a URL for conversion, subject to the application's normal access controls
- Trigger point: Server-side retrieval of HTML followed by resource loading during PDF rendering
- Why exploitation is possible: Validation applies to the initial URL but not to every resource referenced by the returned HTML, allowing the rendering subprocess to access internal or otherwise restricted destinations
Why this happens
The vulnerability results from incomplete SSRF enforcement across a multi-stage fetch pipeline. The application validates the destination of the initial request but treats resource references in the retrieved HTML as trusted input. WeasyPrint then performs additional network requests without applying the same destination checks, which maps to CWE-918: Server-Side Request Forgery.
Potential impact
- Internal network services may be accessed from the server's network position
- Cloud instance metadata or temporary credentials could be exposed
- Sensitive internal responses may be embedded in generated PDF files
- Network topology and service information could be disclosed
- Compromised credentials may enable further unauthorized activity
General mitigation guidance
Mitigation generally focuses on enforcing SSRF protections at every outbound-request stage, including requests initiated by document renderers.
Common defensive patterns include:
- Applying centralized allowlisting and destination validation to the initial URL and all embedded resources
- Disabling or restricting external resource loading during PDF rendering by default
- Blocking loopback, link-local, private, reserved, and otherwise restricted address ranges after DNS resolution
- Revalidating destinations across redirects and preventing DNS rebinding
- Running rendering workers with isolated network access and least-privilege permissions
- Reducing the trust placed in remote HTML and using sanitized, constrained document inputs
- Preventing generated documents or error responses from exposing sensitive fetched content
How teams detect issues like this
Detection can combine application, network, and source-level controls:
- Use static analysis to identify URL fetches and renderer configurations that lack shared SSRF validation
- Review code paths where HTML, CSS, images, fonts, or other document resources trigger outbound requests
- Inspect logs for conversion requests followed by connections to private, loopback, link-local, or metadata address ranges
- Monitor rendering workers for unexpected internal DNS lookups and outbound traffic
- Enforce policies requiring centralized egress controls and destination validation for document-processing services
- Use automated security review tools to flag inconsistent protections between sibling endpoints

