ext/soap: Fix integer overflow when decoding SOAP array indexes#21963
ext/soap: Fix integer overflow when decoding SOAP array indexes#21963LamentXU123 wants to merge 1 commit intophp:PHP-8.4from
Conversation
|
Plus: Had to fix the bailout logic.... Now in the client side, if I raise a error when overflow is detected, the code will go to master_to_eval() and without xmlFreeDoc(response) and cause a memory leak. So in case of that I just had to add some logic to the bailout process to make sure xmldoc is free, although I hate it (;′⌒`) |
|
looks good, but I ll have another look more toward the end of this week (and likely merging it in the process). Thanks for working on it ! |
|
as mentioned, overall good just few minor nits to address ! |
Thanks for reviewing! The fix should be in place in a couple of minutes. Now I think this is rather a bug fix so it is more proper to rebase this on 8.4 I don't sure if this should be counted as a minor security fix(signed integer overflow) if than this should go to 8.2 |
|
I m not sure it would qualify as actual security fix for 8.2 but let me discuss it internally |
Take your time :) I am first going to rebase this on 8.4 |
|
Okay, now its on 8.4 and I squash every commit on this branch into one commit so it would be easier to merge. |
| efree(dims); | ||
| efree(pos); | ||
| zval_ptr_dtor(ret); | ||
| ZVAL_UNDEF(ret); |
There was a problem hiding this comment.
indeed ; soap_error0(E_ERROR, …) should always bail through the SOAP error handler in practice, but leaving ret pointing to freed array data on the off-chance the
bailout path ever changes is a footgun we don't need. The ZVAL_UNDEF keeps the returned zval safe regardless.
devnexen
left a comment
There was a problem hiding this comment.
technically correct, LGTM if CI green.
Feel free to merge after the targeted branch is decided :) |
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:
Will resulted in:
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 :)