{"id":"CVE-2024-45060","aliases":["CVE-2024-45060","GHSA-v66g-p9x6-v98p"],"related":[],"kind":"vulnerability","state":"published","title":"Unauthenticated Cross-Site-Scripting (XSS) in sample file in PHPSpreadsheet","summary":"PHPSpreadsheet is a pure PHP library for reading and writing spreadsheet files. One of the sample scripts in PhpSpreadsheet is susceptible to a cross-site scripting (XSS) vulnerability due to improper handling of input where a number is expected leading to formula injection. The code in in `45_Quadratic_equation_solver.php` concatenates the user supplied parameters directly into spreadsheet formulas. This allows an attacker to take control over the formula and output unsanitized data into the page, resulting in JavaScript execution. This issue has been addressed in release versions 1.29.2, 2.1.1, and 2.3.0. All users are advised to upgrade. There are no known workarounds for this vulnerability.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"PHPSpreadsheet is a pure PHP library for reading and writing spreadsheet files. One of the sample scripts in PhpSpreadsheet is susceptible to a cross-site scripting (XSS) vulnerability due to improper handling of input where a number is expected leading to formula injection. The code in in `45_Quadratic_equation_solver.php` concatenates the user supplied parameters directly into spreadsheet formulas. This allows an attacker to take control over the formula and output unsanitized data into the page, resulting in JavaScript execution. This issue has been addressed in release versions 1.29.2, 2.1.1, and 2.3.0. All users are advised to upgrade. There are no known workarounds for this vulnerability.","source":"cvelist"},{"lang":"en","text":"### Summary\nOne of the sample scripts in PhpSpreadsheet is susceptible to a cross-site scripting (XSS) vulnerability due to improper handling of input where a number is expected leading to formula injection.\n\n### Details\n\nThe following [code](https://github.com/PHPOffice/PhpSpreadsheet/blob/d50b8b5de7e30439fb57eae7df9ea90e79fa0f2d/samples/Basic/45_Quadratic_equation_solver.php#L56) in `45_Quadratic_equation_solver.php` concatenates the user supplied parameters directly into spreadsheet formulas. This allows an attacker to take control over the formula and output unsanitized data into the page, resulting in JavaScript execution.\n```\n$discriminantFormula = '=POWER(' . $_POST['B'] . ',2) - (4 * ' . $_POST['A'] . ' * ' . $_POST['C'] . ')';\n$discriminant = Calculation::getInstance()->calculateFormula($discriminantFormula);\n\n$r1Formula = '=IMDIV(IMSUM(-' . $_POST['B'] . ',IMSQRT(' . $discriminant . ')),2 * ' . $_POST['A'] . ')';\n$r2Formula = '=IF(' . $discriminant . '=0,\"Only one root\",IMDIV(IMSUB(-' . $_POST['B'] . ',IMSQRT(' . $discriminant . ')),2 * ' . $_POST['A'] . '))';\n```\n\n\n### PoC\n1. Access `45_Quadratic_equation_solver.php` in a browser\n2. Enter any valid values for for `b` and `c`, and enter the following for `a`\n\n```\n1) & (\"1)),1)&char(60)&char(105)&char(109)&char(103)&char(32)&char(115)&char(114)&char(99)&char(61)&char(120)&char(32)&char(111)&char(110)&char(101)&char(114)&char(114)&char(111)&char(114)&char(61)&char(97)&char(108)&char(101)&char(114)&char(116)&char(40)&char(41)&char(62)&POWER(((1\") &n(\"1\")&(1\n```\n\n3. Press submit and observe that JavaScript is executed.\n\n![exploit-phpspreadsheet](https://user-images.githubusercontent.com/1211162/297062610-0cdb26d1-2b47-46e2-bd31-189b0694186d.png)\n\n### Impact\n\nThe impact of this vulnerability on the project is expected to be relatively low since these are sample files that should not be included when the library is used properly (e.g., through composer). However, at least two instances of popular WordPress plugins have unintentionally exposed this file by including the entire git repository. Since these files also serve as reference points for developers using the library, addressing this issue can enhance security for users.\n\nA solution to fix the vulnerability is proposed below, and a request for a CVE assignment has been made to facilitate responsible disclosure of the security issue to the affected WordPress plugins.\n\n### Remediation\n\nA quick and easy solution to prevent this attack is to force the parameters to be numerical values:\n\n```php\nif (isset($_POST['submit'])) {\n    $_POST['A'] = floatval($_POST['A']);\n    $_POST['B'] = floatval($_POST['B']);\n    $_POST['C'] = floatval($_POST['C']);\n    if ($_POST['A'] == 0) {\n```\n\nThank you for your time!","format":"markdown","source":"ghsa"},{"lang":"es","text":"PHPSpreadsheet es una librería PHP pura para leer y escribir archivos de hojas de cálculo. Uno de los scripts de muestra de PhpSpreadsheet es susceptible a una vulnerabilidad de cross-site scripting (XSS) debido a un manejo inadecuado de la entrada donde se espera un número, lo que lleva a la inyección de fórmulas. El código en `45_Quadratic_equation_solver.php` concatena los parámetros suministrados por el usuario directamente en fórmulas de hojas de cálculo. Esto permite que un atacante tome el control de la fórmula y muestre datos no saneados en la página, lo que resulta en la ejecución de JavaScript. Este problema se ha solucionado en las versiones de lanzamiento 1.29.2, 2.1.1 y 2.3.0. Se recomienda a todos los usuarios que actualicen. No existen workarounds conocidas para esta vulnerabilidad.","source":"nvd"}],"published":"2024-10-07T14:43:30.000Z","modified":"2026-06-17T07:53:30.787Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:H/A:N","score":7.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:H/A:N","score":7.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 1.29.2","status":"affected"},{"version":">= 2.0.0, < 2.1.1","status":"affected"},{"version":">= 2.2.0, < 2.3.0","status":"affected"}],"vendor":"PHPOffice","product":"PhpSpreadsheet","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","fixed":"1.29.2","status":"affected"},{"type":"custom","introduced":"2.0.0","fixed":"2.1.1","status":"affected"},{"type":"custom","introduced":"2.2.0","fixed":"2.3.0","status":"affected"}],"vendor":"phpoffice","product":"phpspreadsheet","cpe":"cpe:2.3:a:phpoffice:phpspreadsheet:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"2.2.0","status":"affected","fixed":"2.3.0"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.29.2"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.0.0","status":"affected","fixed":"2.1.1"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"1.8.2"}],"ecosystem":"Packagist","package":"phpoffice/phpexcel","purl":"pkg:composer/phpoffice/phpexcel","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.29.2"},{"status":"affected","introduced":"2.0.0","fixed":"2.1.1"},{"status":"affected","introduced":"2.2.0","fixed":"2.3.0"}],"vendor":"phpoffice","product":"phpspreadsheet","cpe":"cpe:2.3:a:phpoffice:phpspreadsheet:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-v66g-p9x6-v98p","tags":["exploit","mitigation","third-party-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/blob/d50b8b5de7e30439fb57eae7df9ea90e79fa0f2d/samples/Basic/45_Quadratic_equation_solver.php#L56","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-45060","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/commit/3990173db1207767139e63d33783beafada57007","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/commit/bc74f3aa1d76f191c6c7c3631e286abb25c38759","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/commit/fb42a103f14cfce258c836b31f4a71f1fb1a9747","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2024-10-08T18:27:07.349Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-45060","url":"https://www.cve.org/CVERecord?id=CVE-2024-45060","licence":"CVE Terms of Use","modified":"2024-10-08T18:28:48.263Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-v66g-p9x6-v98p","url":"https://github.com/advisories/GHSA-v66g-p9x6-v98p","licence":"CC-BY-4.0","modified":"2025-03-06T18:37:14.920Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-45060","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-45060","licence":"Public domain","modified":"2026-06-17T07:53:30.787Z"}],"updatedAt":"2026-11-25T22:58:46.145Z","epss":{"score":0.00507,"percentile":0.4486,"date":"2026-12-01T12:00:22.000Z"}}