Skip to content
XSS Write-up Intermediate

From HTML Injection to Server File Reading via PDF Export

An uploaded filename was inserted unsanitised into an HTML template that the backend rendered into a PDF, so HTML and JavaScript in the filename executed inside the PDF renderer. The author used this to read local files such as the system password file from the server.

medium.com

Published on medium.com

.بِسْ� اللَّه الرَّحْ� ن الرَّحِي� . . اللَّه� َّ صَلِّ وَسلَّ� وبارك على نَبِينَا � ُح� َّد. I ask Allah to grant victory and relief to our brothers and sisters in Palestine and Sudan.

Mohand, 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 uploaded filename was concatenated into an HTML template without sanitisation, and the PDF renderer executed scripts and allowed local file access.

Impact

An attacker who can upload a file could run script inside the PDF renderer and read files the renderer process can access; attempts to reach cloud metadata failed, possibly due to network restrictions or the host not being on that cloud.

What the attacker needed

Ability to upload a file; ability to trigger PDF export

The fix

The filename should be HTML-escaped before it is placed in the PDF template, and the renderer should be configured to block script execution and local file access.

How it was found

  1. Upload a file whose name contains HTML tags.
  2. Generate a PDF export that includes the uploaded filename.
  3. Open the PDF and observe that the HTML tags were rendered.
  4. Put JavaScript in the filename that requests a local file and writes the response, then generate the PDF again.
  5. Observe the local file contents rendered inside the PDF.

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 you upload a file, the site stores its name. This site later put that name into a web page that it turned into a PDF document. Because the name was not cleaned, code hidden in the name ran on the server and could open files stored on that machine.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.