Skip to content
File upload Write-up Intermediate

Local file reading using PDF generation via user cookie

A user-controlled cookie value was reflected unsanitised into a PDF generated from an invoice, allowing HTML injection. The attacker could then use an iframe with a file:// URL to read local files from the server's filesystem.

medium.com

Published on medium.com

Writing about a vulnerability which I got during testing a feature a web application. The feature which I am going to discuss here was about exporting the invoices created by the user a PDF.

Amyrahm, 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 service embedded user-controlled cookie data into HTML without sanitisation, and the headless browser allowed file:// URLs.

Impact

An attacker could read local files on the server running the PDF generation, limited to what the headless browser could access via file:// URLs.

What the attacker needed

Ability to set a cookie value; ability to export an invoice as PDF

How it was found

  1. Create an invoice and export it as PDF.
  2. Notice an unexpected field at the top of the PDF showing a username.
  3. Search Burp history and find the username reflected in a cookie named uname.
  4. Inject HTML into the cookie value and confirm it appears in the PDF.
  5. Use an iframe with a file:// URL to list the C: drive and read files.

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 data into a PDF, it often uses a browser behind the scenes. If that data is not cleaned, you can sneak in HTML that makes the browser load local files. Here, a cookie value was used in the PDF without cleaning, so the attacker could list and read files on the server.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.