Leveraging XSS to Read Internal Files
A PDF generator in an Android healthcare app rendered user-supplied HTML without sanitisation, allowing script execution. The attacker used an iframe pointing to a local file to read internal files, bypassing the locked-down launcher.
Published on blog.dixitaditya.com
Everybody is familiar with what an XSS is so fast-forwarding it a bit, this is a write-up on how I managed to get an XSS in a PDF generator on an Android application that allowed me to read local files on the system.
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 component rendered unsanitised HTML input, allowing script and iframe tags to execute in a local context.
Impact
An attacker could read local files on the Android device, bypassing the custom launcher that restricted access to the filesystem.
What the attacker needed
Access to the app's record editing feature; ability to generate a PDF printout
How it was found
- Edit a patient record and request a PDF printout.
- Enter a simple HTML tag to check if it is rendered in the PDF.
- Try a script-based request to a local file, which fails.
- Try an image error handler with an iframe, which crashes the app.
- Use a simple script that writes an iframe pointing to a local file.
- Observe the file contents in the generated 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 an app turns your input into a PDF, it may treat your text as web page code. If it does not clean that code, you can make the PDF include a hidden frame that loads a file from the device itself. This let the tester read a system file that the app's locked screen was meant to hide.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.