[php-src] Issue #25303: UBSan: member access within NULL encode in to_xml_list (SOAP union type error path)
| From: | YuanchengJiang | Date: | Sun, 08 Nov 2026 13:56:58 +0000 |
| Subject: | [php-src] Issue #25303: UBSan: member access within NULL encode in to_xml_list (SOAP union type error path) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-254071@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/25303
Author: YuanchengJiang
### Description
The following code:
```php
<?php
$wsdl = <<<XML
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:t" targetNamespace="urn:t">
<types>
<xsd:schema targetNamespace="urn:t">
<xsd:simpleType name="U"><xsd:union
memberTypes="xsd:int"/></xsd:simpleType>
</xsd:schema>
</types>
<message name="m"><part name="p"
type="tns:U"/></message>
<portType name="pt"><operation name="test"><input
message="tns:m"/></operation></portType>
<binding name="b" type="tns:pt">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="test"><soap:operation soapAction="#test"/>
<input><soap:body use="encoded" namespace="urn:t"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
</operation>
</binding>
<service name="s"><port name="p"
binding="tns:b"><soap:address
location="test://"/></port></service>
</definitions>
XML;
$c = new SoapClient("data://text/plain;base64," . base64_encode($wsdl),
["cache_wsdl" => WSDL_CACHE_NONE]);
$c->test([[1]]);
```
Resulted in this output:
```
ext/soap/php_encoding.c:3114:5: runtime error: member access within null pointer of type
'struct _encode'
#0 0x3e95282 in to_xml_list ext/soap/php_encoding.c:3114:5
#1 0x3e96a1a in to_xml_union ext/soap/php_encoding.c:3195:9
#2 0x3e931b4 in sdl_guess_convert_xml ext/soap/php_encoding.c:3379:10
#3 0x3e8c60d in master_to_xml_int ext/soap/php_encoding.c:484:11
#4 0x3e86380 in master_to_xml ext/soap/php_encoding.c:495:9
#5 0x40914a8 in serialize_zval ext/soap/soap.c:4413:13
#6 0x408f510 in serialize_parameter ext/soap/soap.c:4384:13
#7 0x4087361 in serialize_function_call ext/soap/soap.c:4245:12
#8 0x407ede7 in do_soap_call ext/soap/soap.c:2580:16
#9 0x405b1fb in soap_client_call_common ext/soap/soap.c:2775:2
#10 0x4059c7d in zim_SoapClient___call ext/soap/soap.c:2795:2
#11 0x64637dc in ZEND_CALL_TRAMPOLINE_SPEC_HANDLER Zend/zend_vm_execute.h:3683:4
#12 0x5fabacc in execute_ex Zend/zend_vm_execute.h:110621:12
#13 0x5fad941 in zend_execute Zend/zend_vm_execute.h:116059:2
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ext/soap/php_encoding.c:3114:5 in
```
To reproduce:
./sapi/cli/php test.php
Commit:
```
33a61f765a94e018a8d55d962a73e8c8331ee256
```
Configurations:
```
CC="clang-12" CXX="clang++-12" CFLAGS="-DZEND_VERIFY_TYPE_INFERENCE"
CXXFLAGS="-DZEND_VERIFY_TYPE_INFERENCE" ./configure --enable-debug
--enable-address-sanitizer --enable-undefined-sanitizer --enable-re2c-cgoto --enable-zts
--enable-bcmath --enable-calendar --enable-dba --enable-dl-test --enable-exif --enable-ftp
--enable-gd --enable-gd-jis-conv --enable-mbstring --enable-pcntl --enable-shmop --enable-soap
--enable-sockets --enable-sysvmsg --enable-zend-test --with-zlib --with-bz2 --with-curl
--with-enchant --with-gettext --with-gmp --with-mhash --with-ldap --with-libedit --with-readline
--with-snmp --with-sodium --with-xsl --with-zip --with-mysqli --with-pdo-mysql --with-pdo-pgsql
--with-pgsql --with-sqlite3 --with-pdo-sqlite --with-webp --with-jpeg --with-freetype
--enable-sigchild --with-pcre-jit --with-iconv
```
Operating System:
```
Ubuntu 20.04 Host, Docker 0599jiangyc/flowfusion:latest
```
*This report is automatically generated by [FlowFusion](https://github.com/php/flowfusion)*
### PHP Version
```plain
nightly
```
### Operating System
_No response_