Commit graph

58448 commits

Author SHA1 Message Date
Niels Dossche
62228a2568
Disable global state test on Windows
It looks like the config.w32 uses CHECK_HEADER_ADD_INCLUDE to add the include
path to libxml into the search path.
That doesn't happen in zend-test.
To add to the Windows trouble, libxml is statically linked in, ext/libxml can
only be built statically but ext/zend-test can be built both statically and
dynamically.
So the regression tests won't work in all possible configurations anyway on Windows.
All of this is no problem on Linux because it just uses dynamic linking
and pkg-config, without any magic.

Signed-off-by: Ben Ramsey <ramsey@php.net>
2023-07-31 19:55:10 -05:00
Niels Dossche
c283c3ab0b Sanitize libxml2 globals before parsing
Fixes GHSA-3qrf-m4j2-pcrr.

To parse a document with libxml2, you first need to create a parsing context.
The parsing context contains parsing options (e.g. XML_NOENT to substitute
entities) that the application (in this case PHP) can set.
Unfortunately, libxml2 also supports providing default set options.
For example, if you call xmlSubstituteEntitiesDefault(1) then the XML_NOENT
option will be added to the parsing options every time you create a parsing
context **even if the application never requested XML_NOENT**.

Third party extensions can override these globals, in particular the
substitute entity global. This causes entity substitution to be
unexpectedly active.

Fix it by setting the parsing options to a sane known value.
For API calls that depend on global state we introduce
PHP_LIBXML_SANITIZE_GLOBALS() and PHP_LIBXML_RESTORE_GLOBALS().
For other APIs that work directly with a context we introduce
php_libxml_sanitize_parse_ctxt_options().
2023-07-31 19:47:19 +01:00
Niels Dossche
80316123f3 Fix buffer mismanagement in phar_dir_read()
Fixes GHSA-jqcx-ccgc-xwhv.
2023-07-31 19:47:05 +01:00
Pierrick Charron
32c7c433ac
Fix wrong backporting of previous soap patch 2023-06-06 18:49:32 -04:00
Remi Collet
0572448263
Fix GH-11382 add missing hash header for bin2hex 2023-06-06 17:56:19 -04:00
Niels Dossche
ac4254ad76
Fix missing randomness check and insufficient random bytes for SOAP HTTP Digest
If php_random_bytes_throw fails, the nonce will be uninitialized, but
still sent to the server. The client nonce is intended to protect
against a malicious server. See section 5.10 and 5.12 of RFC 7616 [1],
and bullet point 2 below.

Tim pointed out that even though it's the MD5 of the nonce that gets sent,
enumerating 31 bits is trivial. So we have still a stack information leak
of 31 bits.

Furthermore, Tim found the following issues:
* The small size of cnonce might cause the server to erroneously reject
  a request due to a repeated (cnonce, nc) pair. As per the birthday
  problem 31 bits of randomness will return a duplication with 50%
  chance after less than 55000 requests and nc always starts counting at 1.
* The cnonce is intended to protect the client and password against a
  malicious server that returns a constant server nonce where the server
  precomputed a rainbow table between passwords and correct client response.
  As storage is fairly cheap, a server could precompute the client responses
  for (a subset of) client nonces and still have a chance of reversing the
  client response with the same probability as the cnonce duplication.

  Precomputing the rainbow table for all 2^31 cnonces increases the rainbow
  table size by factor 2 billion, which is infeasible. But precomputing it
  for 2^14 cnonces only increases the table size by factor 16k and the server
  would still have a 10% chance of successfully reversing a password with a
  single client request.

This patch fixes the issues by increasing the nonce size, and checking
the return value of php_random_bytes_throw(). In the process we also get
rid of the MD5 hashing of the nonce.

[1] RFC 7616: https://www.rfc-editor.org/rfc/rfc7616

Co-authored-by: Tim Düsterhus <timwolla@php.net>
2023-06-06 17:53:45 -04:00
Niels Dossche
ec10b28d64 Fix array overrun when appending slash to paths
Fix it by extending the array sizes by one character. As the input is
limited to the maximum path length, there will always be place to append
the slash. As the php_check_specific_open_basedir() simply uses the
strings to compare against each other, no new failures related to too
long paths are introduced.
We'll let the DOM and XML case handle a potentially too long path in the
library code.
2023-02-12 20:56:19 -07:00
Tim Düsterhus
a92acbad87 crypt: Fix possible buffer overread in php_crypt() 2023-02-12 20:46:51 -07:00
Tim Düsterhus
c840f71524 crypt: Fix validation of malformed BCrypt hashes
PHP’s implementation of crypt_blowfish differs from the upstream Openwall
version by adding a “PHP Hack”, which allows one to cut short the BCrypt salt
by including a `$` character within the characters that represent the salt.

Hashes that are affected by the “PHP Hack” may erroneously validate any
password as valid when used with `password_verify` and when comparing the
return value of `crypt()` against the input.

The PHP Hack exists since the first version of PHP’s own crypt_blowfish
implementation that was added in 1e820eca02.

No clear reason is given for the PHP Hack’s existence. This commit removes it,
because BCrypt hashes containing a `$` character in their salt are not valid
BCrypt hashes.
2023-02-12 20:46:44 -07:00
Gabriel Caruso
255e08ac56
Revert "Make build work with newer OpenSSL"
This reverts commit 5f90134bb6.
2023-01-03 13:00:44 -03:00
Christoph M. Becker
cf5dac07d2
Skip newly added test on 32bit platforms
That bug didn't affect 32bit platforms, and besides, it is rather
unlikely that allocating a 2GB string works on such platforms.
2022-12-19 16:04:29 +01:00
Stanislav Malyshev
5f90134bb6 Make build work with newer OpenSSL 2022-12-18 22:52:30 -07:00
Christoph M. Becker
921b6813da Fix #81740: PDO::quote() may return unquoted string
`sqlite3_snprintf()` expects its first parameter to be `int`; we need
to avoid overflow.
2022-12-18 22:41:43 -07:00
Christoph M. Becker
4c35d6440b
Don't skip test on Windows due to missing ext/posix
ext/posix is not available on Windows, but there is no need to check
for root (i.e. elevated privileges) on this platform, either.

Closes GH-9886.
2022-11-07 15:01:25 +01:00
Ilija Tovilo
75970077b0
Migrate i386 to GitHub actions
Closes GH-9856
2022-11-03 14:34:54 +01:00
Derick Rethans
2b5bed904e Updated to version 2022.6 (2022f) 2022-11-02 09:43:37 +00:00
Kamil Tekiela
e713a8e8e5
Add a temporary fix for insufficient buffer size in mysqlnd (#9835) 2022-10-27 18:25:17 +01:00
Kamil Tekiela
5b60370906
mysqli_query throws warning despite using silenced error mode (#9842) 2022-10-27 18:24:28 +01:00
Stanislav Malyshev
1d83a407d1 Merge branch 'PHP-7.4' into PHP-8.0 2022-10-23 18:49:21 -06:00
Christoph M. Becker
d50532be91 Fix #81739: OOB read due to insufficient validation in imageloadfont()
If we swap the byte order of the relevant header bytes, we need to make
sure again that the following multiplication does not overflow.
2022-10-23 18:41:48 -06:00
Jakub Zelenka
fa1b6ab5db Fix GH-8430: OpenSSL compiled with old disgests does not build
Specifically no-md2, no-md4 or no-rmd160 were not supported
2022-10-22 22:11:05 +01:00
Stanislav Malyshev
beff4278a4 Merge branch 'PHP-7.4' into PHP-8.0 2022-10-21 00:04:43 -06:00
Stanislav Malyshev
248f647724 Fix bug #81738 (buffer overflow in hash_update() on long parameter) 2022-10-20 23:57:35 -06:00
Ilija Tovilo
4071e18620
[skip ci] Mark frequently failing hrtime test as XFAIL 2022-10-20 10:59:07 +02:00
Ilija Tovilo
4e8a6554cb
Fix failing date test
INCLUDE_END_DATE has only been introduced in PHP 8.2.
2022-10-20 10:48:57 +02:00
Derick Rethans
011b7f9840 Test for bug #78055 (DatePeriod's getRecurrences and ->recurrences don't match) 2022-10-19 16:02:49 +01:00
Derick Rethans
7b48053293 Fixed GH-9763: DateTimeZone ctr mishandles input and adds null byte if the argument is an offset larger than 100*60 minutes 2022-10-17 17:08:44 +01:00
Dmitry Stogov
cefb228e15 Discard disasm symbols on opcache restart 2022-10-17 11:22:59 +03:00
Christoph M. Becker
e440e37fa8
Fix GH-9720: Null pointer dereference while serializing the response
When traversing the result array, we need to cater to `param_name`
possibly being `NULL`.  Prior to PHP 7.0.0, this was implicitly done
because `param_name` was of type `char*`.

Closes GH-9739.
2022-10-13 15:56:08 +02:00
Derick Rethans
24963be8ef Updated to version 2022.5 (2022e) 2022-10-12 09:37:28 +01:00
Dmitry Stogov
d9651a9419 Fix GH-9697: array_walk($ffiInstance, function () {}) crashes due to expecting mutable array 2022-10-10 11:21:05 +03:00
Michael Voříšek
b43e49437c
Prepare for Windows CI with Github Actions 2022-10-09 18:44:59 +02:00
George Peter Banyard
499fbcd679
Actually fix GH-9583
The issue is that PS(mod)->s_validate_sid is always defined for user modules, thus we need to check that the actual callable is set
Add another regression test to ensure current working behaviour is not broken (which was by the previous incorrect fix)

Closes GH-9638
2022-10-06 14:29:13 +01:00
Dmitry Stogov
072dc3c857 Fix typo 2022-10-05 21:39:16 +03:00
Dmitry Stogov
ed652a514f Fix register allocation (missing store)
This fixes oss-fuzz #52022
2022-10-03 17:08:11 +03:00
Dmitry Stogov
5ca4113386 Fix abstract trace consisency for FE_FETCH instruction 2022-10-03 14:48:03 +03:00
Arnaud Le Blanc
80232de0e4
Return immediately when FD_SETSIZE is exceeded (#9602) 2022-10-01 11:20:43 +02:00
Andy Postnikov
c58241a003
Make socket path shorter for ext/sockets/tests/socket_cmsg_{rights|credentials}.phpt
When running in CI it fails when path/address is longer 108
2022-09-30 17:07:40 +01:00
David Carlier
257f108924 fix php_init_crypt_r/php_shutdown_crypt_r signatures warning. 2022-09-29 20:40:16 +01:00
Derick Rethans
d16b5d3803 Updated to version 2022.4 (2022d) 2022-09-29 11:52:06 +01:00
Athos Ribeiro
e6a822d437
Revert unintended test expectation change
Commit fbe3059 included an unintended change to the test which checks if
dns_get_record populates its additional parameter. This patch reverts
such change.

The issue was not detected by the CIs because their tests run in
the --offline mode, and the test in question needs internet connection.

Closes GH-9625.
2022-09-28 12:12:21 +02:00
Christoph M. Becker
809176dab0
Fix new bug81726.phpt for PHP 8.0
The error message has slightly changed, so we adapt our expectations.
2022-09-27 18:40:02 +02:00
Christoph M. Becker
3477499d26
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix regression introduced by fixing bug 81726
2022-09-27 18:22:57 +02:00
Christoph M. Becker
432bf196d5
Fix regression introduced by fixing bug 81726
When a tar phar is created, `phar_open_from_fp()` is also called, but
since the file has just been created, none of the format checks can
succeed, so we continue to loop, but must not check again for the
format.  Therefore, we bring back the old `test` variable.

Closes GH-9620.
2022-09-27 18:21:32 +02:00
George Peter Banyard
8b115254c0
Fix GH-9583: session_create_id() fails with user defined save handler that doesn't have a validateId() method 2022-09-27 15:52:21 +01:00
Derick Rethans
def8c8d174 Merge branch 'PHP-7.4' into PHP-8.0 2022-09-27 14:11:14 +01:00
Ilija Tovilo
9377c30577
Migrate MSAN build to GitHub actions 2022-09-25 16:18:58 +02:00
Dmitry Stogov
e488f7b0eb Reorder conditions to avoid valgrind "Conditional jump or move depends on uninitialised value" warning. 2022-09-19 17:17:53 +03:00
Michael Voříšek
9a73ec0367
Always skip randomly failing OCI8 extauth tests
This might be caused by an issue with the Oracle Instant Client
libraries[1]; we skip the tests for the time being.

[1] <https://github.com/php/php-src/pull/9524#issuecomment-1244409815>

Closes GH-9524.
2022-09-13 14:21:23 +02:00
George Peter Banyard
47500f3300 Fix GH-9421 Incorrect argument number for ValueError in NumberFormatter
Closes GH-9489
2022-09-13 12:42:58 +01:00