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-45060 Overview
CVE-2024-45060 is a cross-site scripting (XSS) vulnerability in PhpSpreadsheet, a pure PHP library for reading and writing spreadsheet files. The flaw exists in the 45_Quadratic_equation_solver.php sample script, which concatenates user-supplied parameters directly into spreadsheet formulas. An attacker can manipulate the formula to output unsanitized data into the rendered page, resulting in JavaScript execution in a victim's browser. The issue is categorized under [CWE-79] and requires user interaction to trigger. Maintainers addressed the vulnerability in releases 1.29.2, 2.1.1, and 2.3.0.
Critical Impact
Successful exploitation enables arbitrary JavaScript execution in the context of the vulnerable application, allowing session theft, phishing, and client-side account takeover.
Affected Products
- PHPOffice PhpSpreadsheet versions prior to 1.29.2
- PHPOffice PhpSpreadsheet 2.x versions prior to 2.1.1
- PHPOffice PhpSpreadsheet 2.2.x versions prior to 2.3.0
Discovery Timeline
- 2024-10-07 - CVE-2024-45060 published to NVD
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-45060
Vulnerability Analysis
The vulnerability resides in the sample script samples/Basic/45_Quadratic_equation_solver.php shipped with PhpSpreadsheet. The script accepts user-supplied GET parameters that are expected to be numeric coefficients for a quadratic equation. Instead of validating or casting these inputs, the code concatenates them directly into spreadsheet formulas that are later evaluated and rendered to the response page.
Because the inputs reach formula construction without sanitization, an attacker can inject spreadsheet formula syntax that produces attacker-controlled strings. Those strings are written back to the HTML response without encoding, enabling cross-site scripting. The sample is often deployed in demo environments or copied into production code, which expands the real-world attack surface. See the PhpSpreadsheet security advisory GHSA-v66g-p9x6-v98p for maintainer details.
Root Cause
The root cause is improper input validation combined with missing output encoding. The script assumes numeric input where it is not enforced, and the resulting formula output is embedded in HTML without context-aware escaping. This dual failure maps cleanly to [CWE-79], Improper Neutralization of Input During Web Page Generation.
Attack Vector
An attacker crafts a URL to the vulnerable sample script with malicious payloads in the query parameters normally used for equation coefficients. The attacker delivers the link to a victim through phishing, forums, or an embedded link. When the victim loads the URL, the server renders the formula output into the page and the browser executes the injected JavaScript under the application's origin.
The vulnerability does not provide server-side code execution but can be chained with session riding, credential capture, or application-specific logic to compromise user accounts. See the vulnerable code reference for the exact concatenation pattern.
Detection Methods for CVE-2024-45060
Indicators of Compromise
- HTTP requests to 45_Quadratic_equation_solver.php or other PhpSpreadsheet sample scripts in production web logs.
- Query strings containing HTML tag characters such as <script>, onerror=, javascript:, or formula syntax like =HYPERLINK injected into numeric parameters.
- Unexpected outbound requests from browsers after visiting pages that embed PhpSpreadsheet sample output.
Detection Strategies
- Inventory PHP dependencies with composer show phpoffice/phpspreadsheet to identify installations below 1.29.2, 2.1.1, or 2.3.0.
- Scan web roots for the presence of the PhpSpreadsheet samples/ directory, which should not be deployed to production.
- Deploy web application firewall rules that flag XSS-style payloads targeting PhpSpreadsheet sample endpoints.
Monitoring Recommendations
- Enable and review Content Security Policy (CSP) violation reports to catch injected inline script execution.
- Monitor web server access logs for sustained requests to /samples/Basic/ paths from external sources.
- Alert on anomalous referer chains that correlate with query parameters containing HTML or script tokens.
How to Mitigate CVE-2024-45060
Immediate Actions Required
- Upgrade PhpSpreadsheet to version 1.29.2, 2.1.1, or 2.3.0 depending on the deployed branch.
- Remove the samples/ directory from any production deployment, since it is intended only for demonstration.
- Audit custom code that was copied or adapted from PhpSpreadsheet samples for the same unsafe concatenation pattern.
Patch Information
The PhpSpreadsheet maintainers released fixes in versions 1.29.2, 2.1.1, and 2.3.0. All users are advised to upgrade to the appropriate branch. Full details are available in the GitHub Security Advisory GHSA-v66g-p9x6-v98p.
Workarounds
- No official workarounds exist according to the maintainer advisory; upgrading is the required remediation.
- As a defense-in-depth measure, block public access to any samples/ path at the web server or reverse proxy layer.
- Enforce strict input validation that casts expected numeric parameters to numeric types before use in any formula or template.
# Upgrade PhpSpreadsheet using Composer to a patched release
composer require phpoffice/phpspreadsheet:^2.3.0
# Remove bundled sample scripts from production web root
rm -rf /var/www/html/vendor/phpoffice/phpspreadsheet/samples
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

