GHSA-wgmf-q9vr-vww6
PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via style information
Packages
| Ecosystem | Package | Affected | Fixed in |
|---|---|---|---|
| Packagist | phpoffice/phpspreadsheet | >= 2.0.0, < 2.1.0 | 2.1.0 |
| Packagist | phpoffice/phpspreadsheet | < 1.29.1 | 1.29.1 |
| Packagist | phpoffice/phpexcel | <= 1.8.2 | no fix listed |
Details
As written in the advisory (Markdown source, shown as plain text).
### Summary
`\PhpOffice\PhpSpreadsheet\Writer\Html` doesn't sanitize spreadsheet styling information such as font names, allowing an attacker to inject arbitrary JavaScript on the page.
### PoC
Example target script:
```
<?php
require 'vendor/autoload.php';
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
$spreadsheet = $reader->load(__DIR__ . '/book.xlsx');
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
print($writer->generateHTMLAll());
```
Save this file in the same directory:
[book.xlsx](https://github.com/PHPOffice/PhpSpreadsheet/files/15212797/book.xlsx)
Open index.php in a web browser. An alert should be displayed.
### Impact
Full takeover of the session of users viewing spreadsheet files as HTML.
References
External links from the advisory. They lead to third-party sites.
- https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-wgmf-q9vr-vww6
- https://nvd.nist.gov/vuln/detail/CVE-2024-45046
- https://github.com/PHPOffice/PhpSpreadsheet/pull/3957
- https://github.com/PHPOffice/PhpSpreadsheet/commit/f7cf378faed2e11cf4825bf8bafea4922ae44667
- https://github.com/PHPOffice/PhpSpreadsheet