{"id":"CVE-2024-45293","aliases":["CVE-2024-45293","GHSA-6hwr-6v2f-3m88"],"related":[],"kind":"vulnerability","state":"published","title":"XML External Entity Reference (XXE) in PHPSpreadsheet's XLSX reader","summary":"PHPSpreadsheet is a pure PHP library for reading and writing spreadsheet files. The security scanner responsible for preventing XXE attacks in the XLSX reader can be bypassed by slightly modifying the XML structure, utilizing white-spaces. On servers that allow users to upload their own Excel (XLSX) sheets, Server files and sensitive information can be disclosed by providing a crafted sheet. The security scan function in src/PhpSpreadsheet/Reader/Security/XmlScanner.php contains a flawed XML encoding check to retrieve the input file's XML encoding in the toUtf8 function. The function searches for the XML encoding through a defined regex which looks for `encoding=\"*\"` and/or `encoding='*'`, if not found, it defaults to the UTF-8 encoding which bypasses the conversion logic. This logic can be used to pass a UTF-7 encoded XXE payload, by utilizing a whitespace before or after the = in the attribute definition. Sensitive information disclosure through the XXE on sites that allow users to upload their own excel spreadsheets, and parse them using PHPSpreadsheet's Excel parser. This issue has been addressed in release versions 1.29.1, 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. The security scanner responsible for preventing XXE attacks in the XLSX reader can be bypassed by slightly modifying the XML structure, utilizing white-spaces. On servers that allow users to upload their own Excel (XLSX) sheets, Server files and sensitive information can be disclosed by providing a crafted sheet. The security scan function in src/PhpSpreadsheet/Reader/Security/XmlScanner.php contains a flawed XML encoding check to retrieve the input file's XML encoding in the toUtf8 function. The function searches for the XML encoding through a defined regex which looks for `encoding=\"*\"` and/or `encoding='*'`, if not found, it defaults to the UTF-8 encoding which bypasses the conversion logic. This logic can be used to pass a UTF-7 encoded XXE payload, by utilizing a whitespace before or after the = in the attribute definition. Sensitive information disclosure through the XXE on sites that allow users to upload their own excel spreadsheets, and parse them using PHPSpreadsheet's Excel parser. This issue has been addressed in release versions 1.29.1, 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\nThe security scanner responsible for preventing XXE attacks in the XLSX reader can be bypassed by slightly modifying the XML structure, utilizing white-spaces. On servers that allow users to upload their own Excel (XLSX) sheets, Server files and sensitive information can be disclosed by providing a crafted sheet. \n\n### Details\nThe security scan function in `src/PhpSpreadsheet/Reader/Security/XmlScanner.php` contains a flawed XML encoding check to retrieve the input file's XML encoding in the `toUtf8` function. \n\nThe function searches for the XML encoding through a defined regex which looks for `encoding=\"*\"` and/or `encoding='*'`, if not found, it defaults to the UTF-8 encoding which bypasses the conversion logic. \n\n ```\n$patterns = [\n            '/encoding=\"([^\"]*]?)\"/',\n            \"/encoding='([^']*?)'/\",\n];\n```\n\nThis logic can be used to pass a UTF-7 encoded XXE payload, by utilizing a whitespace before or after the `=` in the attribute definition. \n\n### PoC\n\nNeeded:\n- An Excel sheet (XLSX) with at least one cell containing a value.\n\nUnzip the excel sheet, and modify the `xl/SharedStrings.xml` file with the following value (note the space after `encoding=`):\n\n```\n<?xml version=\"1.0\" encoding= 'UTF-7' standalone=\"yes\"?>\n+ADw-!DOCTYPE abc [ ... ]>\n```\n\n#### Step-by-step\n\n1. First off, the following string is encoded in base64:\n\n```\n<!ENTITY internal 'abc'  >\" \n```\n\nResulting in:\n\n```\nPCFFTlRJVFkgaW50ZXJuYWwgJ2FiYycgID4K\n```\n\n2. The string is used with a parameter entity and the PHP filter wrapper to ultimately define custom entities and call them within the XML.\n\n```\n<?xml version=\"1.0\" encoding= 'UTF-7' standalone=\"yes\"?>\n+ADw-!DOCTYPE foo [ <!ENTITY % xxe SYSTEM \"php://filter//resource=data://text/plain;base64,PCFFTlRJVFkgaW50ZXJuYWwgJ2FiYycgID4K\" > %xxe;]>\n<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"1\" uniqueCount=\"1\"><si><t>&internal;</t></si></sst>\n```\n\nWhen this file is parsed by the library, the value `abc` should be in the original filled cell.\n\nWith the help of the PHP filter wrapper, this can be escalated to information disclosure/file read. \n\n### Impact\nSensitive information disclosure through the XXE on sites that allow users to upload their own excel spreadsheets, and parse them using PHPSpreadsheet's Excel parser.","format":"markdown","source":"ghsa"},{"lang":"es","text":"PHPSpreadsheet es una librería PHP pura para leer y escribir archivos de hojas de cálculo. El escáner de seguridad responsable de prevenir ataques XXE en el lector XLSX se puede eludir modificando ligeramente la estructura XML, utilizando espacios en blanco. En servidores que permiten a los usuarios cargar sus propias hojas de Excel (XLSX), los archivos del servidor y la información confidencial se pueden divulgar proporcionando una hoja manipulada. La función de escaneo de seguridad en src/PhpSpreadsheet/Reader/Security/XmlScanner.php contiene una comprobación de codificación XML defectuosa para recuperar la codificación XML del archivo de entrada en la función toUtf8. La función busca la codificación XML a través de una expresión regular definida que busca `encoding=\"*\"` y/o `encoding='*'`, si no se encuentra, se utiliza de forma predeterminada la codificación UTF-8 que elude la lógica de conversión. Esta lógica se puede utilizar para pasar un payload XXE codificada en UTF-7, utilizando un espacio en blanco antes o después del = en la definición del atributo. Divulgación de información confidencial a través de XXE en sitios que permiten a los usuarios cargar sus propias hojas de cálculo de Excel y analizarlas mediante el analizador de Excel de PHPSpreadsheet. Este problema se ha solucionado en las versiones de lanzamiento 1.29.1, 2.1.1 y 2.3.0. Se recomienda a todos los usuarios que actualicen la versión. No se conocen workarounds para esta vulnerabilidad.","source":"nvd"}],"published":"2024-10-07T15:58:52.000Z","modified":"2026-06-17T07:53:58.013Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":7.5,"rating":"HIGH"}],"cwes":["CWE-611"],"affected":[{"ranges":[{"version":">= 2.2.0, < 2.3.0","status":"affected"},{"version":"< 1.29.1","status":"affected"},{"version":">= 2.0.0, < 2.1.1","status":"affected"}],"vendor":"PHPOffice","product":"PhpSpreadsheet","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"2.2.0","fixed":"2.3.0","status":"affected"},{"type":"custom","introduced":"0","fixed":"1.29.1","status":"affected"},{"type":"custom","introduced":"2.0.0","fixed":"2.1.1","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.1"}],"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.1"},{"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-6hwr-6v2f-3m88","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-45293","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/commit/3bcd51826b7f089d1641e756c83030c30c3bdb0c","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/commit/7d6cb09f6e8204f65e6dd5a0490f7f45f44bb331","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/commit/949ff63e1f6413e6485f73af012d506aa81384bf","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":"yes","technicalImpact":"partial","date":"2024-10-07T20:23:44.790Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-45293","url":"https://www.cve.org/CVERecord?id=CVE-2024-45293","licence":"CVE Terms of Use","modified":"2024-10-07T20:25:10.635Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6hwr-6v2f-3m88","url":"https://github.com/advisories/GHSA-6hwr-6v2f-3m88","licence":"CC-BY-4.0","modified":"2025-03-06T18:36:55.798Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-45293","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-45293","licence":"Public domain","modified":"2026-06-17T07:53:58.013Z"}],"updatedAt":"2026-11-25T22:58:46.140Z","epss":{"score":0.02776,"percentile":0.86747,"date":"2026-12-01T12:00:22.000Z"}}