GHSA-wgmf-q9vr-vww6
PhpSpreadsheet HTML writer is vulnerable to Cross-Site Scripting via style information
Quick fix
GHSA-wgmf-q9vr-vww6 — phpoffice/phpspreadsheet: upgrade to the fixed version with the command below.
composer require phpoffice/phpspreadsheet:^2.1.0Details
### 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.
Are you affected?
Enter the version of the package you're using.
Affected packages
2.0.0Fixed in: 2.1.0composer require phpoffice/phpspreadsheet:^2.1.00Fixed in: 1.29.1composer require phpoffice/phpspreadsheet:^1.29.10No fixed version published yet for phpoffice/phpexcel (composer). Pin to a known-safe version or switch to an alternative.
References
- https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-wgmf-q9vr-vww6[WEB]
- https://nvd.nist.gov/vuln/detail/CVE-2024-45046[ADVISORY]
- https://github.com/PHPOffice/PhpSpreadsheet/pull/3957[WEB]
- https://github.com/PHPOffice/PhpSpreadsheet/commit/f7cf378faed2e11cf4825bf8bafea4922ae44667[WEB]
- https://github.com/PHPOffice/PhpSpreadsheet[PACKAGE]