Skip to content
SSRF Write-up Intermediate

Exploiting SSRF in PDF HTML Injection: Basic and Blind

An endpoint that generated PDFs from user-supplied HTML allowed an attacker to inject an iframe, causing the server to make requests to internal resources. In blind scenarios, the PDF framework executed JavaScript that could read a local file and exfiltrate its contents to an attacker-controlled server.

jbince Follow

Published on medium.com

On a recent application assessment, I encountered an endpoint that would take HTML from user input and generate a PDF from it. I knew that it was possible to perform SSRF by inserting an iframe, but I wanted to know how this would be abused in more complex scenarios.

Joward, on medium.com

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 generation library renders user-supplied HTML and fetches remote resources, including executing JavaScript, without restricting which URLs can be accessed.

Impact

An attacker could read internal resources and, if the PDF framework executes JavaScript and the target has a relaxed CORS policy, exfiltrate data without seeing the PDF.

What the attacker needed

Endpoint accepts HTML for PDF; PDF framework fetches remote resources; for blind: framework executes JavaScript; for blind: target has relaxed CORS

How it was found

  1. Identify an endpoint that accepts HTML and returns a PDF.
  2. Inject an iframe whose source points to the desired internal resource.
  3. For blind SSRF, host an HTML page with JavaScript that reads the internal resource and sends it to an attacker server.
  4. Inject an iframe pointing to the attacker-hosted page.
  5. Receive the exfiltrated data on the attacker server.

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.

When a website turns your HTML into a PDF, it may fetch images or pages you include. If you can add an iframe pointing to an internal address, the server fetches it for you. That is server-side request forgery (SSRF): tricking a server into making requests on your behalf.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.