Skip to content
XXE Write-up Intermediate

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.

Atul Follow

Published on web.archive.org

<?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>

Jane Doe, on web.archive.org

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

  1. Enumerate the web app's features to find possible attack vectors.
  2. Probe the WAF to learn which characters and payloads it blocks.
  3. Find the avatar upload field that accepts PNG, XML and EPS formats.
  4. Upload an SVG containing an external entity declaration pointing at a local file.
  5. After the upload redirects, inspect the page's DOM to find the stored avatar path.
  6. 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.

Similar reports

View all

Same bug class and techniques, clearest first.

XML external entities (XXE)

The lesson behind this report.

An XML parser resolves entities the attacker defines, reading local files or making the server send requests.