Course contentsShow
← Security
Lesson 623 of 3,05213. Web Security - Injection AttacksFree lesson

XXE via File Upload and Content Types

Identify XXE in file uploads, SVG processing, DOCX files, and other formats that embed XML.

XXE via File Upload and Content Types

What you'll learn: How attackers exploit XXE vulnerabilities through file upload features and embedded XML in various document formats.

The Hidden XML Problem

Many file formats that don't look like XML actually contain XML under the hood. When applications accept file uploads and parse these formats, they may inadvertently expose XXE vulnerabilities — even when they never directly accept .xml files.

Think of it like a Trojan horse: you're not uploading a weapon directly, you're hiding it inside something that looks harmless.

Common Attack Vectors

SVG Files: Scalable Vector Graphics files are XML-based. An attacker can upload a malicious SVG containing:

  • External entity definitions to read local files
  • SSRF payloads to scan internal networks
  • Blind XXE payloads with out-of-band exfiltration

DOCX/XLSX/PPTX Files: Microsoft Office documents are actually ZIP archives containing XML files. An attacker can:

  • Unzip the document
  • Modify internal XML files (like document.xml or sharedStrings.xml)
  • Inject XXE payloads
  • Re-zip and upload

PDF Documents: Some PDF parsers support embedded XML (XFDF forms).

Configuration Files: Formats like RSS, SOAP messages, or API payloads sent with Content-Type: application/xml.

Content-Type Manipulation

Even when uploading legitimate files, attackers may manipulate the Content-Type header to force XML parsing. For example, submitting JSON data but setting Content-Type: application/xml to trick the server into parsing it as XML instead.

Why This Works

Developers often trust file upload features, assuming format validation is sufficient. But if the backend uses XML parsers on uploaded content without disabling external entities, the application becomes vulnerable — regardless of file extension filtering.

Key Takeaway: XXE vulnerabilities hide in many file formats beyond plain XML — always validate and secure-parse uploaded files that contain embedded XML structures like SVG, DOCX, and others.