CVE-2026-129501: PHP DOM serializer frees a generated namespace prefix twice

ByLinuxtastic

December 1, 2026 #CVE, #PHP

PHP 8.4 introduced the new DOM API, Dom\XMLDocument and Dom\HTMLDocument, with its own XML serializer. When that serializer has to invent a namespace prefix for an element, it records it in a per-element prefix map, and a descendant’s map could end up sharing ownership of the same generated prefix. On saveXml() the prefix is used after one map has freed it and then freed a second time. The document does not need to be malformed: ordinary namespaced XML or HTML can produce the pattern. The PHP Group says an application that parses attacker-controlled content with these classes and serialises it “can be crashed, and repeated requests can cause denial of service”, and that code execution has not been demonstrated. Update to PHP 8.4.28 or 8.5.13 and restart PHP-FPM; until then, do not call saveXml() on documents built from untrusted input, and use saveHtml() where XML output is not needed.

CVE-2026-129501 at a glance.

ComponentPHP, the DOM extension’s new API (ext/dom): the XML serializer used by Dom\XMLDocument::saveXml() and Dom\HTMLDocument::saveXml(), specifically the copy-on-write namespace-prefix maps. The legacy DOMDocument class is not named in the advisory
Affected versionsPHP 8.4.0 through 8.4.27 and 8.5.0 through 8.5.12, per the PHP Group record; the advisory lists ext-dom from 8.4.0 and 8.5.0 and has no 8.2 or 8.3 entry, since the new DOM classes arrived in 8.4
Fixed inPHP 8.4.28 and 8.5.13, released 19 November 2026 as part of the four-branch security set. Debian: 8.4.28-1~deb13u1 (DSA-6641-1); Ubuntu: USN-9185-1 for php8.5 on 26.04 and 26.10; Red Hat: RHSA-2026:100821 (RHEL 10.3 php8.4), 101251 and 102255 (RHEL 9 php:8.4); SUSE Tumbleweed 8.5.13-1.1
SeverityPHP Group (CNA) CVSS 4.0 6.3 Medium (AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L), CWE-415 (double free) and CWE-416 (use after free). Red Hat rates it Moderate, CVSS 3.1 5.3, with CWE-1341 (multiple releases of the same resource); SUSE moderate at 5.3; Ubuntu Medium; NVD Awaiting Analysis with the CNA score only
Exploited in the wildNot on CISA’s Known Exploited Vulnerabilities list as of 1 December 2026 (catalogue 2026.11.30). EPSS 0.00650 (45.9th percentile) on 30 November 2026
Who is exposedPHP 8.4 and 8.5 applications that parse XML or HTML from the request, a feed, an upload or a third-party API with the new Dom\ classes and then serialise it with saveXml(): sanitisers, feed processors, XML-to-XML transformers, anything that round-trips a document. The described outcome is a crash of the worker, repeatable on demand; a double free is the kind of bug that sometimes grows into more, which the advisory marks as not demonstrated. Code still on the legacy DOMDocument API, and code that only reads the parsed tree, is outside the description
PublishedPHP advisory GHSA-x8r7-mg3g-74hg and CVE record 19 November 2026; this page built 1 December 2026, last updated 1 December 2026

What it is

Serialising namespaced XML means deciding, for each element, which prefix to write for each namespace in scope. The new DOM serializer keeps a map of prefixes per element and, to avoid copying it for every child, shares it copy-on-write: a child starts with a reference to the parent’s map and gets its own copy only when it changes something. When the serializer has to generate a prefix, because the document uses a namespace with no declared prefix, it allocates a string and puts it in the map with a flag saying the map owns it. The copy-on-write step copied that owned flag along with the pointer, so after a child’s map diverged, both maps believed they owned the one generated string. The first to be torn down freed it; the second used it, and then freed it again.

That is CWE-416 followed by CWE-415 in a single saveXml() call, and Red Hat files it under CWE-1341, releasing a resource more than once. The input that triggers it is valid XML with an undeclared or default namespace deep enough that a generated prefix crosses a map boundary; the PHP Group’s phrase is that “the document does not need to be malformed”. The practical effect is that a worker handling a crafted document dies, and a client that can submit documents can keep killing workers, which is the VA:L in the vector. Whether a freed-then-reused string can be steered into anything worse is the part the advisory leaves open.

The fix stops the copy from inheriting ownership, so only one map ever frees a generated prefix. It shipped in 8.4.28 and 8.5.13 on 19 November 2026 with the rest of the set. The advisory credits EliseZeroTwo with the report, ndossche with the fix, devnexen with the review and bukka with the analysis, and names no commit.

Who is affected on Linux

Each row is what the distribution’s own security tracker said on 1 December 2026; the link in the row is the tracker page, which will be newer than this one. Distributions still on PHP 8.2 or 8.3 do not carry the new DOM API and are not affected.

DistributionStatusFixed package
AlpineNot consulted for this page; the Alpine tracker refused automated readers on earlier runs—
Debianphp8.2 not affected (the new DOM API is 8.4+); php8.4 trixie fixed via DSA-6641-1; forky and sid fixed at 8.4.28-3. No DLA8.4.28-1~deb13u1 (trixie)
UbuntuPriority Medium; php8.5 fixed on 26.04 and 26.10 by USN-9185-1 of 23 November 2026; php8.1 (22.04) and php8.3 (24.04) not affected8.5.4-0ubuntu1.6 (26.04), 8.5.9-0ubuntu2.2 (26.10)
RHEL, Rocky, Alma, CentOS StreamModerate, CVSS 3.1 5.3, CWE-1341; errata RHSA-2026:100821 (RHEL 10.3 php8.4 8.4.28), 101251 and 102255 (RHEL 9 php:8.4), 101658 (Hardened Images); the page’s package states read Not affected for the RHEL 8 and 9 default streams, which ship 8.2 or earlier; Bugzilla 2576599php8.4-8.4.28 (RHEL 10.3); the php:8.4 stream builds in the errata
openSUSE/SLERated moderate, CVSS 3.1 5.3; openSUSE Tumbleweed fixed php8 >= 8.5.13-1.1; openSUSE Leap 16.0 and 16.1 Affected; SLES 16.0 and 16.1 In progress; SLES 15 SP4–SP7 Not affectedphp8 8.5.13-1.1 (Tumbleweed)
php.net source builds, Docker php:* images, Remi and Ondřej Surý repositoriesThe upstream release applies; a container keeps the old PHP until the image is rebuiltPHP 8.4.28 and 8.5.13

How to check

Three questions: is this an 8.4 or 8.5 build below the fix; does the application use the new Dom\ classes rather than the legacy DOMDocument; and does it call saveXml() on a document it parsed from outside. Only the third combination is the described flaw.

# 1. which PHP builds are installed, and are they at or above 8.5.13 / 8.4.28 / 8.3.37 / 8.2.36?
php -v | head -1
for b in /usr/bin/php8.* /usr/sbin/php-fpm8.* /opt/remi/php*/root/usr/bin/php; do [ -x "$b" ] && echo "$b: $($b -v 2>/dev/null | head -1)"; done
dpkg -l 'php8.*' 2>/dev/null | awk '/^ii/ {print $2, $3}'      # Debian/Ubuntu
rpm -qa 'php*' 2>/dev/null | sort                                # RHEL family, Remi

# 2. the new DOM API in use? (Dom\XMLDocument / Dom\HTMLDocument are 8.4+; legacy DOMDocument is not named)
grep -rnE 'Dom\\(XMLDocument|HTMLDocument)|use Dom\\' --include='*.php' /var/www /srv 2>/dev/null | head

# 3. saveXml() on those documents, and where the input comes from
grep -rnE '->saveXml\(' --include='*.php' /var/www /srv 2>/dev/null | head
grep -rnE 'Dom\\(XMLDocument|HTMLDocument)::create(From(String|File))?\(' --include='*.php' /var/www /srv 2>/dev/null | head

A build at 8.4.28 or 8.5.13, or any 8.2 or 8.3 build, is not affected. An older 8.4 or 8.5 build whose code never names Dom\XMLDocument or Dom\HTMLDocument is using the legacy API, which the advisory does not name. The exposed case is a hit in step 2 and a saveXml() in step 3 whose document came from createFromString() or createFromFile() on request data, an upload or a fetched feed.

How to fix it

Update and restart the pool. On Debian 13 and the RHEL 9 and 10 8.4 streams the fixed package is the same build that fixes the two SOAP siblings; on Ubuntu only the php8.5 packages change.

# Debian 12 / 13 (php8.2 8.2.36-1~deb12u1 via DLA-4916-1; php8.4 8.4.28-1~deb13u1 via DSA-6641-1)
sudo apt update && sudo apt install --only-upgrade 'php8.*'
# Ubuntu 22.04 / 24.04 / 26.04 / 26.10 (USN-9185-1, 23 November 2026)
sudo apt update && sudo apt install --only-upgrade 'php8.*'
# RHEL 8 / 9 / 10 and rebuilds (php:8.2 / php:8.4 module streams, php8.4 on RHEL 10)
sudo dnf update 'php*'
# then restart what runs PHP: FPM pools keep the old binary until they are restarted
sudo systemctl restart php8.4-fpm php8.3-fpm php8.2-fpm php-fpm 2>/dev/null; sudo systemctl reload apache2 httpd 2>/dev/null
# confirm the running version
php -v | head -1; curl -sI http://localhost/ | grep -i '^x-powered-by'

The advisory’s interim advice is to avoid saveXml() on attacker-controlled Dom\ documents and, for HTML where XML output is not required, to use saveHtml(), which takes a different serialisation path. Where the output must be XML, the document can be serialised through the legacy API after import, at the cost of the new API’s stricter semantics:

<?php
// HTML in, HTML out: the HTML serializer is not the one with the bug
$doc = Dom\HTMLDocument::createFromString($untrusted, LIBXML_NOERROR);
$out = $doc->saveHtml();

// XML output required: round-trip through the legacy DOMDocument until the update is in
$legacy = new DOMDocument();
$legacy->loadXML($untrusted, LIBXML_NONET | LIBXML_NOERROR);
$out = $legacy->saveXML();

Do not disable the DOM extension to “mitigate” this: half the PHP ecosystem (SimpleXML, SOAP, most templating) depends on it and the host will stop serving. And do not treat input validation as the fix, since the triggering document is well-formed and namespaced; a schema check will pass it. The update is a single package and the restart is the only disruption.

Sources

  • CVE-2026-129501 at CVE.org — the PHP Group CNA record (19 November 2026): the description, the affected ranges per branch, the CVSS 4.0 vector and the CWE
  • GHSA-x8r7-mg3g-74hg — the PHP project’s advisory: the mechanism (copy-on-write prefix maps inheriting ownership of a generated prefix), the ext-dom ranges for 8.4 and 8.5, the two patched versions, the saveHtml() advice and the credit to EliseZeroTwo, ndossche, devnexen and bukka; no fix commit is named
  • PHP 8 ChangeLog — the 19 November 2026 entries for 8.5.13 (and 8.6.0), which list this CVE among the eighteen fixed in the release set; the 8.4, 8.3 and 8.2 sections were beyond the readable part of the page on 1 December, so their build numbers are taken from the advisory
  • NVD entry — Awaiting Analysis; published 19 November; the CNA’s CVSS 4.0 6.3, CWE-415 and CWE-416; no NVD score and no cisaExploitAdd
  • Distribution trackers: Debian (php8.2 not affected; DSA-6641-1 for php8.4) · Ubuntu (Medium, USN-9185-1 for php8.5) · Red Hat (Moderate, 5.3, CWE-1341, four errata) · SUSE (moderate, 5.3; Tumbleweed fixed)
  • CISA KEV catalogue 2026.11.30, not listed · EPSS: 0.00650, 45.9th percentile, on 30 November 2026

Related reading

This advisory page was assembled from the primary sources listed above on 1 December 2026 and is updated when they change. The facts are theirs; the checks and the ordering are ours. If a row in the distribution table is out of date, the tracker link in that row is the current word.