Summary
A Server-Side Request Forgery (SSRF) flaw in ERPNext and the underlying Frappe Framework allows attacker-controlled HTML in print formats to embed external resources that are fetched by the server-side PDF renderer.
By injecting elements such as iframes that point to internal or cloud-only endpoints, an attacker can coerce the server to send arbitrary HTTP requests and potentially disclose sensitive information from internal services or metadata APIs.
Affected context
The issue appears in ERPNext v16.0.1 and Frappe Framework v16.1.1 when generating PDFs from user-controlled HTML in Print Formats.
It manifests in environments where:
- Users can influence or supply HTML used for PDF generation, and
- The PDF rendering engine automatically loads external resources referenced in that HTML (e.g., via iframes, images, or other embedded content).
In such setups, the application effectively acts as an HTTP client on behalf of the user, including toward internal-only and cloud metadata endpoints, without explicit network-level restrictions.
Exploit preconditions
- Attack surface: HTTP(S) endpoints that trigger PDF generation from Print Formats in ERPNext/Frappe.
- Required access: Ability to create, edit, or otherwise control HTML content used by the Print Format engine (this may be authenticated or derived from workflow permissions, depending on configuration).
- Trigger point: Requesting a PDF generation operation where the underlying HTML includes elements that reference attacker-specified URLs (e.g., iframe, img, link).
- Why exploitation is possible: The server-side PDF renderer resolves and fetches external resources embedded in HTML without adequately sanitizing or constraining the target URLs, allowing attacker-controlled destinations, including internal addresses and metadata services.
Why this happens
This vulnerability stems from treating user-controlled HTML as trusted input in a server-side rendering pipeline that makes outbound HTTP requests.
The HTML-to-PDF engine resolves embedded resources (such as iframes or images) by issuing HTTP requests from the server environment. Because URLs within this HTML are not sufficiently sanitized or restricted, attackers can direct the renderer to reach arbitrary endpoints.
This behavior corresponds to CWE-918: Server-Side Request Forgery (SSRF), where an application acting as an HTTP client is influenced by untrusted input to interact with internal or otherwise protected network resources.
Potential impact
- Retrieval of cloud instance metadata (e.g., temporary credentials, keys, configuration) from metadata service endpoints.
- Access to internal HTTP services not directly exposed to the internet (e.g., admin panels, internal APIs, database consoles).
- Discovery and probing of internal network structure and hosts through timing and response-based side channels.
- Potential pivoting into further attacks if internal services respond with sensitive data or expose management interfaces.
- Exposure of environment-specific secrets or configuration details that can aid follow-on compromise.
General mitigation guidance
Effective mitigation focuses on limiting how user input influences server-side HTTP requests and constraining where the server can connect:
- Treat Print Format HTML as untrusted input and apply strict sanitization that removes or neutralizes elements capable of initiating external requests (e.g., iframe, script, remote img/src, link/href).
- Configure the HTML-to-PDF engine in a "no network" or network-restricted mode where possible, preventing automatic outbound fetches during rendering.
- Enforce URL allowlists for any server-side fetches originating from templated or user-supplied content, restricting outbound connections to explicitly approved domains.
- Apply network-layer egress controls (firewall rules, proxy policies) to block direct access from application hosts to internal segments and cloud metadata endpoints.
- Partition privileges so that PDF generation components operate with minimal network access required for business functionality.
How teams detect issues like this
Detection commonly centers on identifying risky patterns in both code and runtime behavior:
- Static analysis rules or secure code review checklists that flag use of user-controlled HTML in conjunction with server-side rendering engines capable of loading remote resources.
- Inspection for HTML sanitization routines around Print Format handling, ensuring that potentially networked elements (iframe, remote images, stylesheets) are either stripped or tightly controlled.
- Logging and monitoring of outbound HTTP requests from application servers, with alerts on requests to internal IP ranges, link-local addresses, and known metadata endpoints.
- Use of web application firewalls or egress proxies with policies to detect and block suspicious SSRF-like patterns, such as non-user-facing servers making calls to private address spaces.

