External XML Entity via File Upload (SVG)
An avatar upload accepted SVG files that were parsed as XML, so an external entity in the SVG's DOCTYPE was resolved and its value rendered into the stored avatar image. An attacker could read local files from the server by uploading a crafted SVG and then opening the resulting avatar path.
<?xml version="1.0" standalone="yes"?><!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]><svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"><text font-size="16" x="0" y="16">&xxe;</text></svg>
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 server parsed uploaded SVG files as XML with external entity resolution enabled, so a DOCTYPE entity referencing a local file was expanded and rendered.
Impact
An attacker could read local files on the server, such as the hostname file, through the stored avatar image.
What the attacker needed
An account able to upload an avatar; upload accepts SVG/XML; attacker can view the stored avatar
How it was found
- Enumerate the web app's features to find possible attack vectors.
- Probe the WAF to learn which characters and payloads it blocks.
- Find the avatar upload field that accepts PNG, XML and EPS formats.
- Upload an SVG containing an external entity declaration pointing at a local file.
- After the upload redirects, inspect the page's DOM to find the stored avatar path.
- Open the avatar image path directly to view the expanded file contents.
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.
SVG images are actually XML documents, and XML can define 'entities' that pull in content from elsewhere, including files on the server. If the server parses the uploaded SVG as XML without disabling that feature, the file's contents get placed into the image. The tester uploaded such an SVG as an avatar and then viewed the avatar to see the file contents.
What is XXE?
An XML parser resolves entities the attacker defines, reading local files or making the server send requests.