How a Simple PDF Generator Led Me to a Bug in Government Systems
A PDF generator endpoint accepted raw HTML and rendered it, allowing an attacker to embed an SVG object that caused the server to make requests to an external collaborator. The attacker then used this SSRF to reach the DigitalOcean metadata endpoint and retrieve internal instance information.
medium.com
Published on medium.com
When some people see the title of this article, red flags might go off. So, let me begin by explaining why I was poking at government systems in the first place.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the PDF renderer fetched external resources referenced in user-supplied HTML without restricting access to internal or metadata endpoints.
Impact
The SSRF could expose sensitive cloud metadata such as instance IDs, hostnames, user-data, and public keys, which could lead to credential theft or lateral movement, though the program did not consider it severe enough.
What the attacker needed
Access to the PDF generator endpoint; ability to submit HTML content
How it was found
- Find an API endpoint that generates PDFs from page content.
- Submit HTML containing an iframe pointing to an external server to test for outbound requests.
- When basic iframes did not work, try an SVG object with an external data source.
- Confirm the server made a request to the collaborator's server.
- Resolve the target subdomain to an IP address and identify the cloud provider.
- Render the cloud metadata endpoint through the PDF generator to retrieve internal metadata.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A PDF generator takes HTML and turns it into a PDF. If it fetches images or other resources from the HTML, an attacker can make it fetch internal addresses that are normally only reachable from inside the server's network. This is called server-side request forgery (SSRF).
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.