Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-56365 Overview
CVE-2024-56365 is a reflected cross-site scripting (XSS) vulnerability in PhpSpreadsheet, a widely deployed PHP library for reading and writing spreadsheet files. The flaw resides in the constructor of the Downloader class, which is reachable through the /vendor/phpoffice/phpspreadsheet/samples/download.php sample script. Unsanitized user input flows into reflected HTML output, allowing an attacker to execute arbitrary JavaScript in a victim's browser session. The issue is tracked under [CWE-79] and affects any application that exposes the shipped sample scripts to untrusted clients.
Critical Impact
An attacker can craft a malicious URL that, when visited by an authenticated user, executes attacker-controlled JavaScript in the context of the hosting application, enabling session theft, credential capture, or targeted phishing.
Affected Products
- PhpSpreadsheet versions prior to 3.7.0
- PhpSpreadsheet versions prior to 2.3.5 and 2.1.6
- PhpSpreadsheet versions prior to 1.29.7
Discovery Timeline
- 2025-01-03 - CVE-2024-56365 published to NVD
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-56365
Vulnerability Analysis
The vulnerability is a reflected XSS flaw in the Downloader sample class shipped with PhpSpreadsheet. The constructor accepts request parameters and renders them back into the HTTP response without proper output encoding or input validation. Because the vulnerable code lives under vendor/phpoffice/phpspreadsheet/samples/, deployments that leave the samples directory web-accessible after composer install are exposed. Reflected XSS requires user interaction, typically a crafted link delivered through phishing or an attacker-controlled page.
Root Cause
The root cause is missing output sanitization on request-controlled data inside the Downloader constructor logic in samples/download.php. The sample scripts were designed as demonstration code and echoed $_POST and $_GET values directly into the response. The patch in commit 700a8034 refactors the vulnerable sample code paths to use a $helper->log() abstraction rather than direct echo statements, and adds input type validation such as is_numeric() checks before rendering values.
Attack Vector
Exploitation requires an attacker to deliver a crafted URL to a victim with access to a PhpSpreadsheet installation that exposes samples/download.php. When the victim visits the link, injected JavaScript executes in the origin of the hosting application. The attack vector is network-based and requires user interaction, but no privileges or prior authentication on the target application.
// Patch excerpt: samples/Engineering/Convert-Online.php
$quantity = $_POST['quantity'];
$fromUnit = $_POST['fromUnit'];
$toUnit = $_POST['toUnit'];
- if (isset($units[$_POST['category']][$fromUnit], $units[$_POST['category']][$toUnit])) {
+ if (!is_numeric($quantity)) {
+ $helper->log('Quantity is not numeric');
+ } elseif (isset($units[$_POST['category']][$fromUnit], $units[$_POST['category']][$toUnit])) {
/** @var float|string */
$result = ConvertUOM::CONVERT($quantity, $fromUnit, $toUnit);
- echo "{$quantity} {$units[$_POST['category']][$fromUnit]} is {$result} {$units[$_POST['category']][$toUnit]}", PHP_EOL;
+ $helper->log("{$quantity} {$units[$_POST['category']][$fromUnit]} is {$result} {$units[$_POST['category']][$toUnit]}");
} else {
- echo 'Please enter quantity and select From Unit and To Unit', PHP_EOL;
+ $helper->log('Please enter quantity and select From Unit and To Unit');
}
} else {
- echo 'Please enter quantity and select From Unit and To Unit', PHP_EOL;
+ $helper->log('Please enter quantity and select From Unit and To Unit');
}
Source: PHPOffice/PhpSpreadsheet patch commit 700a8034
Detection Methods for CVE-2024-56365
Indicators of Compromise
- HTTP requests targeting /vendor/phpoffice/phpspreadsheet/samples/download.php or other paths under samples/ on production hosts.
- Query string or POST body parameters containing <script>, javascript:, onerror=, or URL-encoded equivalents in requests to the vulnerable endpoints.
- Referer headers pointing to attacker-controlled domains preceding requests to the sample scripts.
Detection Strategies
- Scan web roots for exposed vendor/phpoffice/phpspreadsheet/samples/ directories and flag deployments shipping sample code to production.
- Review web application firewall (WAF) logs for reflected XSS payload patterns against any path containing phpspreadsheet/samples.
- Audit application composer dependencies to identify installations running PhpSpreadsheet versions below 3.7.0, 2.3.5, 2.1.6, or 1.29.7.
Monitoring Recommendations
- Enable WAF rules for OWASP Core Rule Set XSS signatures and alert on hits against PHP vendor directories.
- Forward web server access logs to a centralized logging platform and build detections for suspicious parameter content on sample scripts.
- Monitor browser-side Content Security Policy (CSP) violation reports for inline script execution on application origins.
How to Mitigate CVE-2024-56365
Immediate Actions Required
- Upgrade PhpSpreadsheet to 3.7.0, 2.3.5, 2.1.6, or 1.29.7 depending on your supported release line.
- Remove or restrict access to the vendor/phpoffice/phpspreadsheet/samples/ directory on all internet-facing hosts.
- Audit application dependencies with composer show phpoffice/phpspreadsheet to confirm the installed version is patched.
Patch Information
The maintainers released fixes in versions 3.7.0, 2.3.5, 2.1.6, and 1.29.7. Technical details of the fix are documented in the GitHub Security Advisory GHSA-jmpx-686v-c3wx and the upstream patch commit 700a8034.
Workarounds
- Block HTTP access to any URL path containing /vendor/ at the web server or reverse proxy layer.
- Deploy a WAF rule that rejects script-like payloads in requests to samples/download.php until patching completes.
- Enforce a strict Content Security Policy that disallows inline script execution to reduce the impact of reflected XSS.
# Nginx: deny public access to the vendor directory
location ~ ^/vendor/ {
deny all;
return 404;
}
# Verify installed PhpSpreadsheet version
composer show phpoffice/phpspreadsheet | grep versions
# Upgrade to a patched release
composer require phpoffice/phpspreadsheet:^3.7.0
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

