Skip to content
XXE Write-up Intermediate

The issue

Apache POI's XSSFExportToXml class did not enable secure XML processing when validating an XSD schema taken from an XLSX file, allowing an attacker to supply a malicious schema. This could cause the application to fetch attacker-chosen URLs, leading to SSRF and leakage of sensitive information from local or remote resources.

medium.com

Published on medium.com

Apache POI is a popular Java library for working with Microsoft documents. For example, it allows you reading and writing Microsoft Excel files using Java.

Artem Smotrakov, on medium.com

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

The SchemaFactory used to parse the attacker-controlled XSD schema was not configured with secure XML processing, so external entity and schema references were resolved.

Impact

An attacker could trigger SSRF and leak sensitive information from local and remote resources, though only when the application processes untrusted files with XML validation enabled.

What the attacker needed

Apache POI 4.1.0 or below; Untrusted data reaches XSSFExportToXml; XML validation enabled (third parameter true)

The fix

The issue was fixed in POI 4.1.1 by setting the FEATURE_SECURE_PROCESSING feature on SchemaFactory.

How it was found

  1. Create an XLSX file whose xl/xmlMaps.xml contains a schema with an external reference.
  2. Repackage the modified files back into an XLSX archive.
  3. Have the application process the file through XSSFExportToXml with validation enabled.
  4. Observe that SchemaFactory loads the external schema location.

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.

Apache POI is a Java library that reads and writes Microsoft Office files such as Excel spreadsheets. When it validates a spreadsheet's embedded schema, it did not switch on a safety setting, so a crafted spreadsheet could make the server fetch a URL chosen by the attacker. That is called server-side request forgery: the server is tricked into making requests on the attacker's behalf.

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.