PhpSpreadsheetでXXEによる情報漏えいやサービス妨害のおそれ
Summary
PhpSpreadsheetのSpreadsheetML読み込み処理では、二重エンコードされた入力によりXMLの検査を回避され、外部実体参照(XXE)による任意ファイルの読み取りやSSRF、エンティティ展開によるサービス拒否を引き起こされるおそれがあります。影響を受けるのは3.3.0から3.10.8未満と5.10.0未満の版で、修正版は3.10.8と5.10.0です。修正版へ更新してください。
AI summary
Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.
PhpSpreadsheetのSpreadsheetML読み込み処理では、二重エンコードされた入力によりXMLの検査を回避され、外部実体参照(XXE)による任意ファイルの読み取りやSSRF、エンティティ展開によるサービス拒否を引き起こされるおそれがあります。影響を受けるのは3.3.0から3.10.8未満と5.10.0未満の版で、修正版は3.10.8と5.10.0です。修正版へ更新してください。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| PHPOfficePhpSpreadsheet | — | Not listed |
| composerphpoffice/phpspreadsheet |
< 3.10.8→ 3.10.8 |
3.10.8 |
| Packagistphpoffice/phpspreadsheet |
≥ 3.3.0, < 3.10.8→ 3.10.8 |
3.10.8 |
Original description The description as published by the source.
Summary
The SpreadsheetML XML reader (Reader\Xml) scans file content twice through XmlScanner::scan(), and each scan runs an unentity() callback that calls html_entity_decode() after the pattern check. By double-encoding the < character as &#60;, the first scan decodes & to & (forming <), and the second scan decodes < to < (forming <!DOCTYPE). Neither scan's pattern check detects the <!DOCTYPE string because the callback runs after each check. This enables Denial of Service via entity expansion on all PHP versions, and XXE/SSRF on PHP < 8.0 or when LIBXML_NOENT is used.
Details
The vulnerability involves an interaction between three code locations:
1. XmlScanner::scan() (XmlScanner.php, lines 87–108) — checks the pattern before the callback:
public function scan($xml): string
{
$pattern = '/\0*<\0*!\0*D\0*O\0*...\0*/';
if (preg_match($pattern, $xml)) { // CHECK 1 (raw)
throw new Exception('Detected use of ENTITY...');
}
$xml = $this->toUtf8($xml);
if (preg_match($pattern, $xml)) { // CHECK 2 (UTF-8)
throw new Exception('Detected use of ENTITY...');
}
if ($this->callback !== null) {
$xml = call_user_func($this->callback, $xml); // DECODE (after checks!)
}
return $xml; // <!DOCTYPE now present, never checked
}
2. Xml::canRead() (Xml.php, lines 79–117) — scans and stores the result:
$data = file_get_conten…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- advisory nvd.nist.gov
- package github.com
- web github.com
- web github.com
- web github.com
- web github.com
- web github.com
- web github.com