File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1438,12 +1438,20 @@ PHP_METHOD(SoapServer, handle)
14381438 instanceof_function (Z_OBJCE (h -> retval ), soap_fault_class_entry )) {
14391439 php_output_discard ();
14401440 soap_server_fault_ex (function , & h -> retval , h );
1441- if (service -> type == SOAP_CLASS && soap_obj ) {zval_ptr_dtor (soap_obj );}
1441+ if (service -> type == SOAP_CLASS && soap_obj ) {
1442+ if (service -> soap_class .persistence != SOAP_PERSISTENCE_SESSION ) {
1443+ zval_ptr_dtor (soap_obj );
1444+ }
1445+ }
14421446 goto fail ;
14431447 } else if (EG (exception )) {
14441448 php_output_discard ();
14451449 _soap_server_exception (service , function , ZEND_THIS );
1446- if (service -> type == SOAP_CLASS && soap_obj ) {zval_ptr_dtor (soap_obj );}
1450+ if (service -> type == SOAP_CLASS && soap_obj ) {
1451+ if (service -> soap_class .persistence != SOAP_PERSISTENCE_SESSION ) {
1452+ zval_ptr_dtor (soap_obj );
1453+ }
1454+ }
14471455 goto fail ;
14481456 }
14491457 } else if (h -> mustUnderstand ) {
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GHSA-m33r-qmcv-p97q: Use-after-free after header parsing failure with SOAP_PERSISTENCE_SESSION
3+ --CREDITS--
4+ Ilia Alshanetsky (iliaal)
5+ --EXTENSIONS--
6+ soap
7+ session
8+ --FILE--
9+ <?php
10+
11+ class Handler {
12+ public function return () {
13+ return new SoapFault ('Server ' , 'denied ' );
14+ }
15+ public function throw () {
16+ throw new SoapFault ('Server ' , 'denied ' );
17+ }
18+ public function hello () {
19+ return 'ok ' ;
20+ }
21+ }
22+
23+ session_start ();
24+
25+ $ srv = new SoapServer (null , ['uri ' => 'urn:a ' ]);
26+ $ srv ->setClass (Handler::class);
27+ $ srv ->setPersistence (SOAP_PERSISTENCE_SESSION );
28+
29+ $ srv ->handle (<<<XML
30+ <?xml version="1.0" encoding="UTF-8"?>
31+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="urn:a">
32+ <soap:Header>
33+ <a:return/>
34+ </soap:Header>
35+ <soap:Body>
36+ <a:hello/>
37+ </soap:Body>
38+ </soap:Envelope>
39+ XML );
40+
41+ $ srv ->handle (<<<XML
42+ <?xml version="1.0" encoding="UTF-8"?>
43+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="urn:a">
44+ <soap:Header>
45+ <a:throw/>
46+ </soap:Header>
47+ <soap:Body>
48+ <a:hello/>
49+ </soap:Body>
50+ </soap:Envelope>
51+ XML );
52+
53+ ?>
54+ --EXPECT--
55+ <? xml version="1.0 " encoding="UTF -8 "?>
56+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>denied</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
57+ <? xml version="1.0 " encoding="UTF -8 "?>
58+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>denied</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
You can’t perform that action at this time.
0 commit comments