314 Commits
Author SHA1 Message Date
Ilia Alshanetsky 7b3369c0c2 Fix GH-24315: Harden SoapClient cross-origin redirect handling (#24329)
SoapClient followed any Location header, so a redirect to another host,
port, or scheme resent the HTTP authentication credentials, the stream
context headers, and the SOAP envelope to that origin. Such redirects now
fail with a SoapFault. A same-host upgrade from http to https on port 443
is still followed. The new follow_cross_origin_redirects option restores
the previous behavior. Cookies were already scoped by domain and
Proxy-Authorization only reaches the proxy, so neither changes.

Fixes GH-24315
2026-10-25 07:01:05 -04:00
Ilija Tovilo 9705fda1bb Merge branch 'PHP-8.6' into master
* PHP-8.6:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:34:56 +02:00
Ilija Tovilo d6373dfe15 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:33:23 +02:00
Ilija Tovilo c7273b9ba8 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:30:04 +02:00
Ilija Tovilo 8a94bb3822 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:27:03 +02:00
Ilija Tovilo c1a5f468d0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:12:35 +02:00
3584a98bda Avoid state corruption via bailout
- Replace bailout on OOM with UnwindExit
- Properly reset various globals that may be accessed during startup

Fix GHSA-w8hw-w9fx-j79w (CVE-2026-109618)
Fix GHSA-6wmf-4rv5-p3rp (CVE-2026-109619)

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Jakub Zelenka <bukka@php.net>
Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
2026-10-21 16:06:22 +02:00
Ilia Alshanetsky 38ec8eb284 ext/soap: Reject a response body shorter than Content-Length (#23935)
A short read of a Content-Length body returned the bytes received and left
the keep-alive socket cached. Return failure instead, which closes that
socket and raises the existing HTTP fault.
2026-09-27 12:16:21 -04:00
Jakub Zelenka 48e53b0921 Merge branch 'PHP-8.5'
* PHP-8.5:
  Skip bz2 GH-20807 test when less than 13 GiB of memory is available
  ext/soap: make GHSA-cj93-vc83-wgqv test lean and reliable
  Add NEWS entries
  ext/standard: Fix 1-char relative Location redirects after GH-23467
  [http] Fix out-of-bounds read on empty Location header
  Fix GHSA-ch8v-r6jh-4vvr: encode 0xFF in FILTER_SANITIZE_ENCODED
  Fix GHSA-9f67-6fw4-hpfp
  Fix GHSA-j3wh-g957-2m85: phar tar entry injection
  Fix GHSA-cj93-vc83-wgqv
  Fix GHSA-rgrp-mwpx-f6rm: unbounded recursion in ext/soap XML parsing and decoding
  Fix GHSA-fpwc-w8rq-cr92: strip credentials from user headers on cross-origin redirects
  Fix GHSA-r6x9-5r99-36j7: Various packet overreads in mysqlnd wireprotocol
  Fix GHSA-xr7j-rvgx-xq5p: OOB read in php_openssl_matches_wildcard_name()
  Fix GHSA-vvx9-73fr-5jjx: do not fall back to CN if the cert has a service ID
  Fix GHSA-62xp-839h-2637: FastCGI allowed_clients compared only 96 bits of IPv6 addresses
  Fix heap-buffer-overflow in convert stream filters with NUL in line-break-chars

# Conflicts:
#	NEWS
#	ext/openssl/xp_ssl.c
#	ext/phar/tar.c
#	ext/soap/php_http.c
#	ext/standard/http_fopen_wrapper.c
2026-09-22 11:15:26 +02:00
Jakub Zelenka 2ef7525be7 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Skip bz2 GH-20807 test when less than 13 GiB of memory is available
  ext/soap: make GHSA-cj93-vc83-wgqv test lean and reliable
  Add NEWS entries
  ext/standard: Fix 1-char relative Location redirects after GH-23467
  [http] Fix out-of-bounds read on empty Location header
  Fix GHSA-ch8v-r6jh-4vvr: encode 0xFF in FILTER_SANITIZE_ENCODED
  Fix GHSA-9f67-6fw4-hpfp
  Fix GHSA-j3wh-g957-2m85: phar tar entry injection
  Fix GHSA-cj93-vc83-wgqv
  Fix GHSA-rgrp-mwpx-f6rm: unbounded recursion in ext/soap XML parsing and decoding
  Fix GHSA-fpwc-w8rq-cr92: strip credentials from user headers on cross-origin redirects
  Fix GHSA-r6x9-5r99-36j7: Various packet overreads in mysqlnd wireprotocol
  Fix GHSA-xr7j-rvgx-xq5p: OOB read in php_openssl_matches_wildcard_name()
  Fix GHSA-vvx9-73fr-5jjx: do not fall back to CN if the cert has a service ID
  Fix GHSA-62xp-839h-2637: FastCGI allowed_clients compared only 96 bits of IPv6 addresses
  Fix heap-buffer-overflow in convert stream filters with NUL in line-break-chars

# Conflicts:
#	NEWS
#	ext/phar/tar.c
#	ext/soap/php_http.c
#	ext/soap/php_xml.c
#	ext/standard/http_fopen_wrapper.c
#	win32/ioutil.c
2026-09-22 11:14:09 +02:00
Jakub Zelenka 2cd16757b2 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/soap: make GHSA-cj93-vc83-wgqv test lean and reliable
  Add NEWS entries
  ext/standard: Fix 1-char relative Location redirects after GH-23467
  [http] Fix out-of-bounds read on empty Location header
  Fix GHSA-ch8v-r6jh-4vvr: encode 0xFF in FILTER_SANITIZE_ENCODED
  Fix GHSA-9f67-6fw4-hpfp
  Fix GHSA-j3wh-g957-2m85: phar tar entry injection
  Fix GHSA-cj93-vc83-wgqv
  Fix GHSA-rgrp-mwpx-f6rm: unbounded recursion in ext/soap XML parsing and decoding
  Fix GHSA-fpwc-w8rq-cr92: strip credentials from user headers on cross-origin redirects
  Fix GHSA-r6x9-5r99-36j7: Various packet overreads in mysqlnd wireprotocol
  Fix GHSA-xr7j-rvgx-xq5p: OOB read in php_openssl_matches_wildcard_name()
  Fix GHSA-vvx9-73fr-5jjx: do not fall back to CN if the cert has a service ID
  Fix GHSA-62xp-839h-2637: FastCGI allowed_clients compared only 96 bits of IPv6 addresses
  Fix heap-buffer-overflow in convert stream filters with NUL in line-break-chars

# Conflicts:
#	ext/openssl/xp_ssl.c
2026-09-22 11:03:08 +02:00
Jakub Zelenka f9e04180ae Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/soap: make GHSA-cj93-vc83-wgqv test lean and reliable
  Add NEWS entries
  ext/standard: Fix 1-char relative Location redirects after GH-23467
  [http] Fix out-of-bounds read on empty Location header
  Fix GHSA-ch8v-r6jh-4vvr: encode 0xFF in FILTER_SANITIZE_ENCODED
  Fix GHSA-9f67-6fw4-hpfp
  Fix GHSA-j3wh-g957-2m85: phar tar entry injection
  Fix GHSA-cj93-vc83-wgqv
  Fix GHSA-rgrp-mwpx-f6rm: unbounded recursion in ext/soap XML parsing and decoding
  Fix GHSA-fpwc-w8rq-cr92: strip credentials from user headers on cross-origin redirects
  Fix GHSA-r6x9-5r99-36j7: Various packet overreads in mysqlnd wireprotocol
  Fix GHSA-xr7j-rvgx-xq5p: OOB read in php_openssl_matches_wildcard_name()
  Fix GHSA-vvx9-73fr-5jjx: do not fall back to CN if the cert has a service ID
  Fix GHSA-62xp-839h-2637: FastCGI allowed_clients compared only 96 bits of IPv6 addresses
  Fix heap-buffer-overflow in convert stream filters with NUL in line-break-chars
2026-09-22 10:54:22 +02:00
Nora DosscheandJakub Zelenka b11bd1d939 Fix GHSA-cj93-vc83-wgqv
Co-authored-by: Jakub Zelenka <bukka@php.net>
2026-09-18 22:26:47 +02:00
Weilin Du 600e4a8445 tree-wide: Refactor with zend_string_ends_with* (#23216) 2026-08-14 17:01:16 +08:00
David Carlier f6fe838e36 ext/soap: truncate header values containing newline characters.
Commit 3dcdb9826b routed the user_agent option through a truncate-and-warn
check, but the Content-Type context option, the soapaction and the cookie
names and values reach the same request buffer unchecked, so a CR/LF in any
of them still injects arbitrary request headers.

Emit all of them through that same check. The helper now takes an explicit
length so the char* soapaction can share it.

Close GH-22781
2026-07-21 03:07:08 +01:00
Ilia Alshanetsky 3dcdb9826b ext/soap: truncate a user_agent containing newline characters (#22771)
GH-17976 sanitized user_agent where the HTTP wrapper emits headers and left
the SOAP client alone, so a value carrying CRLF still injects request headers
through all three of its sources: the SoapClient user_agent option, the
http.user_agent stream context option, and the ini setting. Resolve the three
to one zend_string and emit it through the same truncate-and-warn check the
HTTP wrapper applies.

Closes GH-22771
2026-07-17 07:08:58 -04:00
Ilia Alshanetsky 547ebc39c1 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/soap: fix NULL deref on malformed HTTP status line
2026-07-16 22:01:58 -04:00
Ilia Alshanetsky 888f7359c0 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/soap: fix NULL deref on malformed HTTP status line
2026-07-16 22:00:22 -04:00
Ilia Alshanetsky 1c4bf04783 ext/soap: fix NULL deref on malformed HTTP status line
make_http_soap_request() looked for the reason phrase with strstr(tmp, " ")
even when the first strstr() found no space, which happens for a status line
carrying a version but no status code, such as "HTTP/1.1". tmp is NULL there,
so strstr() dereferenced it and the client crashed.

Only parse the reason phrase when a status code field was present.

Closes GH-22761
2026-07-16 21:58:20 -04:00
Weilin Du 6bc7c26cf6 Replace dependencies on /ext/hash in various extensions (#21832)
Followup-PR for #21724. Using the new API in #21724 to replace dependencies
on /ext/hash in

- ext/opcache/ZendAccelerator/
- ext/soap/php_http.c
- Zend/zend_system_id.c

In the following ext, there are independent implementation of bin2hex. This PR
also change them to directly using the new Zend API.

- ext/standard/string.c
- ext/hash/php_hash.h
2026-07-09 20:03:34 +08:00
Weilin Du aa12a652c3 ext/soap: Add UNEXPECTED() in obvious error path (#22596)
This added `UNEXPECTED()` in several obvious error path for optimization
in ext/soap.
2026-07-05 12:28:12 +08:00
Gina Peter Banyard 8c1e00e379 ext/soap: use zend_string* in php_http.c where possible 2026-07-03 11:28:29 +01:00
Gina Peter Banyard 8c008042cb ext/soap: use bool type instead of int type in php_http.c 2026-07-03 11:28:29 +01:00
Weilin Du 9ae23bae5f Zend: Use zend_string_equals* APIs for string comparisons (#21707)
Use the zend_string APIs zend_string_equals* which are clearer,
and can also do some pointer comparisons if the strings are
interned for any reason.
2026-06-25 17:07:23 +08:00
ndossche cf9bb87ec2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  [ci skip] Update heading
  soap: do not overwrite the parsed host on a protocol-relative redirect
2026-06-25 08:31:03 +02:00
Ilia Alshanetsky 5cd9a3b047 soap: do not overwrite the parsed host on a protocol-relative redirect (#22431)
When a redirect Location is a protocol-relative reference (//host/path),
the URI parser already fills new_uri->host, but the scheme-less redirect
handling overwrote it with a copy of the request host without releasing
the parsed one. That leaks a zend_string per such redirect and pins the
redirect back to the original host instead of the one the server named.
Inherit host and port from the request URI only when new_uri->host is
NULL, mirroring the scheme guard directly above.
2026-06-24 16:35:25 -04:00
Ilia Alshanetsky 27c10ddce6 soap: do not overwrite the parsed host on a protocol-relative redirect
When a redirect Location is a protocol-relative reference (//host/path),
php_url_parse() already fills new_url->host, but the scheme-less redirect
handling overwrote it with a copy of the request host without releasing
the parsed one. That leaks a zend_string per such redirect and pins the
redirect back to the original host instead of the one the server named.
Inherit host and port from the request URL only when new_url->host is
NULL, mirroring the scheme guard directly above.

Closes GH-22434
2026-06-24 13:16:46 -04:00
Ilia Alshanetsky 5c163caf2b Fix GH-17976: CRLF injection via from and user_agent in HTTP wrapper (#21658)
The from and user_agent INI settings and the user_agent stream context
option were written into HTTP request headers without stripping CR/LF
characters, allowing header injection.

Truncate at the first \r or \n and emit E_WARNING. The from and
user_agent globals are stored as zend_string so the check scans the
full length and a NUL byte no longer pre-truncates the value before the
CR/LF scan.

Fixes GH-17976
2026-06-24 07:47:09 -04:00
Ilia Alshanetsky 78c08651f9 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix SOAP client failing to follow a scheme-less redirect Location
2026-06-20 18:13:42 -04:00
Ilia Alshanetsky de39a14cc7 Fix SOAP client failing to follow a scheme-less redirect Location
The HTTP redirect handler inherited scheme, host and port from the newly
parsed Location URI itself instead of the previous request URI, so a
scheme-less (relative or absolute-path) Location left the host NULL and
the retry aborted with "Unable to parse URL". Read the inherited
components and the path base from the request URI, restoring the
behaviour the URI-parser refactor changed.

Closes GH-22341
2026-06-20 18:11:48 -04:00
Ben Ramsey d14aad1d7b license-update: ext/soap source headers
RFC: https://wiki.php.net/rfc/php_license_update
2026-04-11 21:20:54 -05:00
Gina Peter Banyard f40b356ad9 Use smart_str_append() if we have a zend_string* (#21414) 2026-03-21 17:06:14 +00:00
David CARLIER b0aa6b9626 ext/soap: various optimisations
* replace strcat/strncpy with memcpy for pre-allocated buffers.
* remove redundant memset before struct copy.
2026-03-12 17:56:43 +00:00
David Carlier ed887241be Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/soap: Fix wrong cookie options offset calculation, using separator offset instead.
2026-03-10 22:01:03 +00:00
David Carlier f04873c1b8 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/soap: Fix wrong cookie options offset calculation, using separator offset instead.
2026-03-10 21:59:38 +00:00
David Carlier 1b61d555fb ext/soap: Fix wrong cookie options offset calculation, using separator offset instead.
The cookie option parser uses a wrong offset to start scanning
attributes, causing cookie values containing substrings like
"path=" or "domain=" to be falsely matched as attributes.

close GH-21400
2026-03-10 21:58:52 +00:00
David CARLIER e929602ed0 ext/soap: HTTP request micro optimisations. (#20516)
smart string is a bit overkill for the cookie id here.
2025-11-18 18:32:59 +00:00
Niels Dossche 8ea4d7b5fa Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix uninitialized soap lang_en string on ZTS
2025-09-29 16:11:47 +02:00
Niels Dossche 8987c0b661 Fix uninitialized soap lang_en string on ZTS
Replaces GH-19772.
Closes GH-19772.
Fixes GH-19773.
Closes GH-19819.
2025-09-29 16:11:29 +02:00
Tim Düsterhus 45bbe8c36d soap: Use return true / return false for functions returning bool
Changes done with Coccinelle:

    @r1@
    identifier fn;
    typedef bool;
    symbol false;
    symbol true;
    @@

    bool fn ( ... )
    {
    <...
    return
    (
    - 0
    + false
    |
    - 1
    + true
    )
    ;
    ...>
    }

Coccinelle patch sourced from
torvalds/linux@46b5c9b856.
2025-09-24 18:51:40 +02:00
Tim Düsterhus 59f2228667 soap: Use true / false instead of 1 / 0 when assigning to bool
Changes done with Coccinelle:

    @@
    bool b;
    @@

    - b = 0
    + b = false

    @@
    bool b;
    @@

    - b = 1
    + b = true
2025-09-24 18:51:40 +02:00
Tim Düsterhus 26eac7de17 uri: Clean up naming of public symbols (#19794)
* uri: Rename `uri_recomposition_mode_t` to `php_uri_recomposition_mode`

* uri: Align the names of the `php_uri_recomposition_mode` values

* uri: Rename `uri_component_read_mode_t` to `php_uri_component_read_mode`

* uri: Align the names of the `php_uri_component_read_mode` values

* uri: Rename `uri_property_name_t` to `php_uri_property_name`

* uri: Align the names of the `php_uri_property_name` values

* uri: Rename `uri_property_handler_t` to `php_uri_property_handler`

* uri: Rename `uri_(read|write)_t` to `php_uri_property_handler_(read|write)`

* uri: Rename `php_uri_property_handler`’s `(read|write)_func` to `read|write`

The `_func` is implied by the data type and the name of the struct.

* uri: Rename `uri_parser_t` to `php_uri_parser`

* uri: Shorten the names of `php_uri_parser` fields

The `_uri` suffix is implied, because this is an URI parser.
2025-09-11 12:10:41 +02:00
Tim Düsterhus 1faaa7224d uri: Remove useless layer of indirection in php_uri_get_parser() (#19774)
By using the `zend_hash_*()` functions directly, we can benefit from the
precalculated hash value in the given `zend_string *uri_parser_name`. We need
to deconstify the parameter, since the function might calculate the hash, thus
modifying the `zend_string*`.
2025-09-09 22:02:30 +02:00
Tim Düsterhus 49faa4df75 uri: Always use const pointers when referring to uri_parser_t (#19623)
The actual parser definitions are all `const` and must never be modified. Make
sure to always use `const` pointers.
2025-08-30 21:04:50 +02:00
Máté Kocsis e9c92a9739 ext/uri: Use the term "URI parser" instead of "URI handler" (#19530) 2025-08-21 07:23:47 +02:00
Máté Kocsis 1cff1815d0 Add internal URI handling API (#19073)
Part of https://github.com/php/php-src/pull/14461. Related to https://wiki.php.net/rfc/url_parsing_api.
2025-08-19 18:35:09 +02:00
Niels Dossche f6380e4a38 Merge branch 'PHP-8.4'
* PHP-8.4:
  ext/soap/php_http.c: Fix memory leak of header value
2025-07-10 22:32:58 +02:00
Niels Dossche de7a212630 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/soap/php_http.c: Fix memory leak of header value
2025-07-10 22:32:52 +02:00
Gina Peter Banyard 85a49d4198 ext/soap/php_http.c: Fix memory leak of header value 2025-07-10 22:32:31 +02:00
Niels Dossche aa0e8bf568 Use ZVAL_NULL() directly for Z_CLIENT_USE_PROXY_P()
This is just a `?int` property, no need to do anything fancy.
2025-07-03 20:37:10 +02:00