From b7efdc3b0a0a12133a8f49193090b8fddd3f82d6 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Sun, 22 Nov 2026 21:50:01 +0100 Subject: [PATCH 1/2] ext/soap: Fix NULL dereference on empty Body with matching SOAPAction Since 63e0b9ccbfe the function can be resolved from the SOAPAction header when the Body has no function element, leaving func NULL. --- NEWS | 2 + ext/soap/soap.c | 13 +++--- .../tests/soapaction_empty_body_document.phpt | 24 ++++++++++ .../tests/soapaction_empty_body_header.phpt | 35 +++++++++++++++ .../tests/soapaction_empty_body_header.wsdl | 44 +++++++++++++++++++ ext/soap/tests/soapaction_empty_body_rpc.phpt | 24 ++++++++++ .../soapaction_empty_body_rpc_params.phpt | 24 ++++++++++ .../soapaction_empty_body_rpc_soap12.phpt | 24 ++++++++++ 8 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 ext/soap/tests/soapaction_empty_body_document.phpt create mode 100644 ext/soap/tests/soapaction_empty_body_header.phpt create mode 100644 ext/soap/tests/soapaction_empty_body_header.wsdl create mode 100644 ext/soap/tests/soapaction_empty_body_rpc.phpt create mode 100644 ext/soap/tests/soapaction_empty_body_rpc_params.phpt create mode 100644 ext/soap/tests/soapaction_empty_body_rpc_soap12.phpt diff --git a/NEWS b/NEWS index c02edbf7d6c7..5e26189d88ff 100644 --- a/NEWS +++ b/NEWS @@ -161,6 +161,8 @@ PHP NEWS - SOAP: . Fixed bug GH-25267 (NULL dereference in to_xml_any() with integer key). (lazerg) + . Fixed NULL dereference in SoapServer::handle() with an empty Body and a + SOAPAction matching an RPC operation. (Jorg Sowa) - Sockets: . Fixed bug GH-25530 (socket_last_error() without a socket returns an error diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 7070a7205184..d934fda73989 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -3488,13 +3488,16 @@ static sdlFunctionPtr deserialize_function_call(sdlPtr sdl, xmlDocPtr request, c } } - if (function && function->binding && function->binding->bindingType == BINDING_SOAP) { - sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes; - if (fnb->style == SOAP_RPC) { + /* func is NULL when the function was resolved via SOAPAction and the Body is empty */ + if (func) { + if (function && function->binding && function->binding->bindingType == BINDING_SOAP) { + sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes; + if (fnb->style == SOAP_RPC) { + func = func->children; + } + } else { func = func->children; } - } else { - func = func->children; } deserialize_parameters(func, function, num_params, parameters); diff --git a/ext/soap/tests/soapaction_empty_body_document.phpt b/ext/soap/tests/soapaction_empty_body_document.phpt new file mode 100644 index 000000000000..a9914afa52f3 --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_document.phpt @@ -0,0 +1,24 @@ +--TEST-- +SoapServer::handle() with empty Body and SOAPAction matching a document-style operation with parameters +--EXTENSIONS-- +soap +--INI-- +soap.wsdl_cache_enabled=0 +--POST-- + + + +--FILE-- +addFunction("test"); +$_SERVER["HTTP_SOAPACTION"] = "#test"; +$server->handle(); +?> +--EXPECT-- + +SOAP-ENV:ClientMissing parameter diff --git a/ext/soap/tests/soapaction_empty_body_header.phpt b/ext/soap/tests/soapaction_empty_body_header.phpt new file mode 100644 index 000000000000..8b2aad16d3cd --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_header.phpt @@ -0,0 +1,35 @@ +--TEST-- +SoapServer::handle() with Header, empty Body and SOAPAction matching an RPC operation +--EXTENSIONS-- +soap +--INI-- +soap.wsdl_cache_enabled=0 +--POST-- + + + secret + + + +--FILE-- +auth = $value; + } + + public function test() { + return "auth: " . $this->auth; + } +} + +$server = new SoapServer(__DIR__.'/soapaction_empty_body_header.wsdl'); +$server->setObject(new Service()); +$_SERVER["HTTP_SOAPACTION"] = "Test"; +$server->handle(); +?> +--EXPECT-- + +auth: secret diff --git a/ext/soap/tests/soapaction_empty_body_header.wsdl b/ext/soap/tests/soapaction_empty_body_header.wsdl new file mode 100644 index 000000000000..1e62ef6ea847 --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_header.wsdl @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ext/soap/tests/soapaction_empty_body_rpc.phpt b/ext/soap/tests/soapaction_empty_body_rpc.phpt new file mode 100644 index 000000000000..a43611b26551 --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_rpc.phpt @@ -0,0 +1,24 @@ +--TEST-- +SoapServer::handle() with empty Body and SOAPAction matching an RPC operation +--EXTENSIONS-- +soap +--INI-- +soap.wsdl_cache_enabled=0 +--POST-- + + + +--FILE-- +addFunction("getItems"); +$_SERVER["HTTP_SOAPACTION"] = "http://testuri.orgTestServiceAction"; +$server->handle(); +?> +--EXPECT-- + + diff --git a/ext/soap/tests/soapaction_empty_body_rpc_params.phpt b/ext/soap/tests/soapaction_empty_body_rpc_params.phpt new file mode 100644 index 000000000000..738e8f86e76d --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_rpc_params.phpt @@ -0,0 +1,24 @@ +--TEST-- +SoapServer::handle() with empty Body and SOAPAction matching an RPC operation with parameters +--EXTENSIONS-- +soap +--INI-- +soap.wsdl_cache_enabled=0 +--POST-- + + + +--FILE-- +addFunction("Add"); +$_SERVER["HTTP_SOAPACTION"] = "Add"; +$server->handle(); +?> +--EXPECT-- + +SOAP-ENV:ClientMissing parameter diff --git a/ext/soap/tests/soapaction_empty_body_rpc_soap12.phpt b/ext/soap/tests/soapaction_empty_body_rpc_soap12.phpt new file mode 100644 index 000000000000..7b2364fedee1 --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_rpc_soap12.phpt @@ -0,0 +1,24 @@ +--TEST-- +SoapServer::handle() with empty SOAP 1.2 Body and SOAPAction matching an RPC operation with parameters +--EXTENSIONS-- +soap +--INI-- +soap.wsdl_cache_enabled=0 +--POST-- + + + +--FILE-- + SOAP_1_2]); +$server->addFunction("Add"); +$_SERVER["HTTP_SOAPACTION"] = "Add"; +$server->handle(); +?> +--EXPECT-- + +env:SenderMissing parameter From c41a12ec17fe2212eb11075cae107026e9abbbca Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Mon, 23 Nov 2026 14:12:06 +0100 Subject: [PATCH 2/2] ext/soap: Drop redundant document-style empty Body test --- .../tests/soapaction_empty_body_document.phpt | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 ext/soap/tests/soapaction_empty_body_document.phpt diff --git a/ext/soap/tests/soapaction_empty_body_document.phpt b/ext/soap/tests/soapaction_empty_body_document.phpt deleted file mode 100644 index a9914afa52f3..000000000000 --- a/ext/soap/tests/soapaction_empty_body_document.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -SoapServer::handle() with empty Body and SOAPAction matching a document-style operation with parameters ---EXTENSIONS-- -soap ---INI-- -soap.wsdl_cache_enabled=0 ---POST-- - - - ---FILE-- -addFunction("test"); -$_SERVER["HTTP_SOAPACTION"] = "#test"; -$server->handle(); -?> ---EXPECT-- - -SOAP-ENV:ClientMissing parameter