[php-src] PR #21963: ext/soap: Fix SOAP array index integer overflow
| From: | LamentXU123 | Date: | Wed, 06 May 2026 14:54:23 +0000 |
| Subject: | [php-src] PR #21963: ext/soap: Fix SOAP array index integer overflow | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36038@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21963
Author: LamentXU123
SOAP encoded array metadata such as arrayType, offset, and position is parsed into int indexes
before being used for array placement. That is, this code:
```php
<?php
class C extends SoapClient {
function __doRequest($r, $l, $a, $v, $o = false, ?string $u = null): string {
return <<<'XML'
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<x:testResponse xmlns:x="x">
<return SOAP-ENC:arrayType="xsd:string[1]" SOAP-ENC:offset="[2147483648]"
xsi:type="SOAP-ENC:Array">
<item xsi:type="xsd:string">x</item>
</return>
</x:testResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML;
}
}
$c = new C(null, ['location' => 'x', 'uri' => 'x']);
var_dump($c->test());
```
Will resulted in:
```php
array(1) {
[-2147483648]=>
string(1) "x"
}
```
Because the index overflows.
There is a TODO message to fix this. So I think people are aware of this bug before
I therefore wrote this to add checked decimal accumulation for SOAP array indexes and reject values
that exceed int range. I Also reject auto-increment past INT_MAX before updating the next array
position :)