GitHub Advisory Database
GHSA-wgmf-q9vr-vww6
PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via style information
Details
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
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.
Affected packages
| Ecosystem | Package | Affected versions |
|---|---|---|
| Packagist | phpoffice/phpspreadsheet | From 2.0.0 before 2.1.0 (fixed in 2.1.0) |
| Packagist | phpoffice/phpspreadsheet | All versions before 1.29.1 (fixed in 1.29.1) |
| Packagist | phpoffice/phpexcel | All versions up to and including 1.8.2 |
References
- 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