Course contentsShow
← Security
Lesson 973 of 3,05220. Web Security - File Upload and ProcessingFree lesson

XXE in Document Processing

Understand XML External Entity attacks when processing office documents, SVGs, and XML-based formats.

XXE in Document Processing

What you'll learn: How attackers exploit XML-based file formats to execute External Entity (XXE) attacks during document processing.


Understanding XXE in Document Processing

Many common file formats—Microsoft Office documents (.docx, .xlsx, .pptx), SVG images, and configuration files—are actually XML under the hood. When your application parses these uploaded files, it's processing XML. If the XML parser is configured insecurely, attackers can inject malicious XML External Entity declarations that make the server read local files, perform SSRF attacks, or cause denial of service.

Think of it like this: Imagine a document is like a recipe that can reference ingredients from your pantry. XXE is when an attacker sneaks in a recipe that says "include the contents of /etc/passwd from the kitchen safe" instead of normal ingredients—and your parser obediently fetches it.

Common Attack Vectors

When processing uploaded documents:

  • .docx/.xlsx files are ZIP archives containing XML files
  • SVG images are pure XML that browsers and image libraries parse
  • PDF, RSS feeds, and configuration imports may contain XML

An attacker embeds malicious entity declarations like:

<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>

When your document processor parses this, it may read and expose sensitive files or make network requests to internal systems.

Why This Matters

Unlike simple file upload attacks targeting web shells, XXE exploits the legitimate parsing process. Your application thinks it's safely processing a harmless spreadsheet, but the XML parser is silently executing file reads or SSRF attacks in the background.

Key Takeaway: XXE attacks exploit insecure XML parsers when processing seemingly innocent document formats. Always disable external entity processing and use secure parser configurations when handling XML-based files like Office documents and SVGs.