Commit 13a0f8c8c16 for php
commit 13a0f8c8c1634d80de1a42016390b1bc3bd6e470
Author: Jakub Zelenka <bukka@php.net>
Date: Sun Nov 1 15:18:09 2026 +0100
Fix GHSA-4646-p932-gw34: keep SOAP DTD alive during cleanup
diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c
index 340dbd8ea4a..a692ba8dcdc 100644
--- a/ext/soap/php_xml.c
+++ b/ext/soap/php_xml.c
@@ -50,6 +50,9 @@ static void cleanup_xml_node(xmlNodePtr node)
xmlUnlinkNode(trav);
xmlFreeNode(trav);
}
+ } else if (trav->type == XML_DTD_NODE) {
+ /* Attribute-value entity references can share content with the DTD.
+ * Keep it alive until the document itself is freed. */
} else if ((trav->type != XML_ELEMENT_NODE) &&
(trav->type != XML_CDATA_SECTION_NODE)) {
xmlUnlinkNode(trav);
diff --git a/ext/soap/tests/GHSA-4646-p932-gw34.phpt b/ext/soap/tests/GHSA-4646-p932-gw34.phpt
new file mode 100644
index 00000000000..8e3567d9660
--- /dev/null
+++ b/ext/soap/tests/GHSA-4646-p932-gw34.phpt
@@ -0,0 +1,35 @@
+--TEST--
+GHSA-4646-p932-gw34: DTD entity references must not outlive their declarations
+--POST--
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE Envelope [<!ENTITY e "boom">]>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns1="urn:t">
+ <SOAP-ENV:Header>
+ <h SOAP-ENV:actor="&e;" SOAP-ENV:mustUnderstand="1"/>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body>
+ <ns1:echo_><param0 xsi:type="xsd:string">x</param0></ns1:echo_>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+--EXTENSIONS--
+soap
+--FILE--
+<?php
+function echo_($x) {
+ return $x;
+}
+
+$server = new SoapServer(null, [
+ 'uri' => 'urn:t',
+ 'style' => SOAP_RPC,
+ 'use' => SOAP_ENCODED,
+]);
+$server->addFunction('echo_');
+$server->handle();
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>DTD are not supported by SOAP</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>