[CLSA-2026:1791442745] alt-php56: Fix of CVE-2025-1218
Type:
security
Severity:
Important
Release date:
2026-10-08 06:59:19 UTC
Description:
- CVE-2025-1218: various out-of-bounds reads in the mysqlnd wire-protocol parser (ext/mysqlnd/mysqlnd_wireprotocol.c, mysqlnd_wireprotocol.h, mysqlnd_ps_codec.c, mysqlnd_ps.c; GHSA-r6x9-5r99-36j7). The parser read fields out of a server packet before checking that the packet still held enough bytes, so a malicious or compromised MySQL server could make the client read past the end of the packet buffer. Backport of upstream commit 114dbb74368e: BAIL_IF_NO_MORE_DATA, which noticed an over-read only after it had happened, is replaced by the BAIL_PREMATURE_END / BAIL_IF_NOT_ENOUGH_DATA_EX family; php_mysqlnd_net_field_length() and its _ll() variant take the remaining packet size and report MYSQLND_INVALID_NET_FIELD_LENGTH instead of blindly consuming 2, 3 or 8 bytes; the server version and the auth-switch plugin names are located with memchr() over the remaining bytes instead of strdup()/strlen(); and the greeting's fixed block and extended scramble, the result-set field metadata lengths, the in-row EOF marker, the text-protocol field lengths and the declared lengths of TIME/DATE/DATETIME all gain real bounds checks. - Prerequisite note: the CVE-2024-8929 backport already on this branch is what supplies the three mysqlnd_ps_codec.c over-read helpers, the packet_end guard and the fake_server.inc test harness that upstream's change builds on; none of it is in the 5.6.40 tarball. - php-5.6.40-caching-sha2-password.patch introduces php_mysqlnd_cached_sha2_result_read() here, so both of its over-reads are live and are fixed: an unbounded stack over-read of the auth-switch plugin name off a 2048-byte buffer that nothing NUL-terminates (whose result is handed to the caller, with a length that underflows into a large emalloc/memcpy), and a one-byte read past a one-byte packet for the second response code. This patch is therefore applied after the caching-sha2 patch, not alongside the other CVE patches. - The greeting's authentication plugin name is still read with an unbounded estrdup() on 5.6.40, so php-8.1.34's bounded form is carried as a prerequisite before upstream's removal of the "buf[header.size] = 0" hack, which on its own would have turned a terminated read into an unbounded one. - Honest scope: php_mysqlnd_prepare_read() and php_mysqlnd_sha256_pk_request_response_read() are hardening, not memory-safety fixes - behind the existing PREPARE_RESPONSE_SIZE gate the new prepare_read checks cannot fire - and the mysqlnd_ps.c hunk is a leak fix on the newly reachable failure path, not an over-read. - Not applicable on this branch: upstream's guard around MARIADB_RPL_VERSION_HACK, which does not exist here. Upstream's rejection of any "def" value in the result-set field packet is deliberately not taken, because COM_FIELD_LIST is still supported on 5.6; the existing def bounds check is kept and only given the remaining size. - Upstream's 38 regression tests are NOT carried: they drive the dynamic-port fake server upstream added in the same commit, while the harness this branch has (ext/mysqli/tests/fake_server.inc, from the CVE-2024-8929 backport) binds a fixed port, so carrying them means rewriting all 38 and dropping the address assertion. Nothing would run them either way - the spec runselftest toggle defaults to 0 and debian/rules runs no suite. They were run locally instead, on a tree built from this repository's own patch series, first patched and then with only the C hunks of this patch reversed out and rebuilt: 32 of 38 pass patched / 0 fail, against 8 of 38 pass unpatched / 24 fail. The 6 skips in both arms are the cached-sha2 and sha256-pk tests, which need an ext/openssl this build did not have, PHP 5.6's openssl extension not compiling against OpenSSL 3 - The same mysqlnd_ps.c hunk also corrects that path's result free from mnd_efree() to upstream's php-7.0 form, mnd_pefree(stmt->result, stmt->result->persistent): mysqlnd_result_init() allocates the result with mnd_pecalloc(..., persistent), so on a persistent connection the Zend allocator was being handed a malloc()ed block. Before the change a hostile prepare over p:127.0.0.1 aborts with "zend_mm_heap corrupted" on a build with the Zend MM heap checks compiled in; after it the same run completes, and a non-persistent connection is unaffected either way - Also fixes a pre-existing use-after-free on the row-reader failure path: the CVE-2024-8929 error loops free every field decoded so far without clearing the zvals, and the result set frees them again at teardown. All 2 sites now clear after freeing. Confirmed under AddressSanitizer with the Zend allocator disabled - heap-use-after-free before, clean after, on the three new short-length tests and the nine CVE-2024-8929 stmt-row tests. Upstream still carries the same loops unguarded in php-8.2.34 through php-8.5.11 - The mysqlnd_ps.c hunk additionally releases the result's own connection reference on the prepare-EOF path: before PHP 7.4 (upstream f365d0e00ed9) free_result_contents() did not drop it, so that path leaked one reference - mysqlnd: initialise every pre-allocated row field before decoding (php-5.6.40-mysqlnd-rowp-init-fields.patch). The row readers pre-allocate a zval per column with MAKE_STD_ZVAL(), which sets no type, and only type it when the decode loop reaches that column; the CVE-2024-8929 error paths abandon a row part-way, leaving the rest allocated but never typed, and the result set still frees the whole row at teardown. Each column is now ZVAL_NULL()ed at allocation. Verified with valgrind under USE_ZEND_ALLOC=0. PHP 5 only, and kept separate from the CVE patch because the defect predates it and is reachable without it
CVEs fixed:
Updated packages:
  • alt-php56-5.6.40-146.el6.x86_64.rpm
    sha:ca7bb2425bb2b2cd926f81c0fa8cd2af54a16a6c52d31d1dd0698f97ff4417f4
  • alt-php56-bcmath-5.6.40-146.el6.x86_64.rpm
    sha:f7e387b53092f547be7345b86c22ce7af4a2cf5a3d0892c57d9522af60ce4eb3
  • alt-php56-cli-5.6.40-146.el6.x86_64.rpm
    sha:f0177827af75b5baa911b5979a54d0bfb3bcf38c91febf013b42c56f2da0d7c5
  • alt-php56-common-5.6.40-146.el6.x86_64.rpm
    sha:ec9ba2ceac1cba0d9b1f1f8bf55c6c5b26168bca5cc1f604083d7fb5525213e8
  • alt-php56-dba-5.6.40-146.el6.x86_64.rpm
    sha:9bfa0d12790574d6000e0f41a21812fd4aadfee54adbcd967df39cfa08a3ada7
  • alt-php56-dbx-5.6.40-146.el6.x86_64.rpm
    sha:3e9aef83f9f8689799b44f18e316e7506f1577aa176c63d64875a0baf3d1af67
  • alt-php56-devel-5.6.40-146.el6.x86_64.rpm
    sha:20242e46d91448dfe9da3cf87418c72978d743296934aa7fda6dfb60666fb0e9
  • alt-php56-enchant-5.6.40-146.el6.x86_64.rpm
    sha:5655f9e2a73145a8a492c545918c691fb5b8a114d6ca30cbf5496b34559b81f9
  • alt-php56-firebird-5.6.40-146.el6.x86_64.rpm
    sha:aae9b34abc3393ccf0c1f9f21f7cc369e199c1f4419264285ef378d0c6f97842
  • alt-php56-gd-5.6.40-146.el6.x86_64.rpm
    sha:689af62651b9585e4f5b15e61afbbe749a1fedcddbdb47d33ceeb3d264a10419
  • alt-php56-imap-5.6.40-146.el6.x86_64.rpm
    sha:300899ef402e33398a0acde72140a95f043df61c31558903739d7ebc441e646b
  • alt-php56-intl-5.6.40-146.el6.x86_64.rpm
    sha:c866f166f3e2b718390c3835e3ef00999c338466c801d77d4d90c1726e43184a
  • alt-php56-ldap-5.6.40-146.el6.x86_64.rpm
    sha:e55f4de969a82f5026a1dc6d0f147d43648cda55db55193378672a97896ea519
  • alt-php56-mbstring-5.6.40-146.el6.x86_64.rpm
    sha:fd337a87d9775fa5afe6a705bef73ad79b277e298eb7b8bc33dcc546e279076d
  • alt-php56-mcrypt-5.6.40-146.el6.x86_64.rpm
    sha:e376d2a6656938fa497f30cd4797716fe4c23c4bb41400952e8d8380aac57cf7
  • alt-php56-mssql-5.6.40-146.el6.x86_64.rpm
    sha:787f834264e283e4801c813b264841d694272f17a56973a126267f87d2e72894
  • alt-php56-mysqlnd-5.6.40-146.el6.x86_64.rpm
    sha:a9e205d8eaa9d936f8f4b41a49305c710170d2c6211ab80f62dc23bc5061b4cf
  • alt-php56-odbc-5.6.40-146.el6.x86_64.rpm
    sha:ccd794449446c02c7470d4ceb11bb8170d35c504919bb68c35a05662216bcfa6
  • alt-php56-opcache-5.6.40-146.el6.x86_64.rpm
    sha:a5d395815f6d47aac40ad3bf3b6f562d9fe08403ee30846504e5114c847c0312
  • alt-php56-pdo-5.6.40-146.el6.x86_64.rpm
    sha:26b7e9f21fce22d075386f311b08521d420d81f5263e81c1312df21079a39d4e
  • alt-php56-pgsql-5.6.40-146.el6.x86_64.rpm
    sha:9df3993e049d06e85de33a9dec21f977d68f5c13171746f3a539e7377d3c6108
  • alt-php56-php-fpm-5.6.40-146.el6.x86_64.rpm
    sha:2121c86245812bec4843a601c66be43969822d3a824f0e8f03569f1b1d150738
  • alt-php56-process-5.6.40-146.el6.x86_64.rpm
    sha:999c90451028ca8f9fbef59e76c28d46d9302c825661b68e4c49327d35b76453
  • alt-php56-pspell-5.6.40-146.el6.x86_64.rpm
    sha:99a4f0bf5fd968b65622a0148ee8d0ef3befb5f6e6531788202621a7cb7930b5
  • alt-php56-recode-5.6.40-146.el6.x86_64.rpm
    sha:f25b13f4256d4c4fbe6cba4f633906dab6627a55cb6ad2cde69595dfcc5df967
  • alt-php56-snmp-5.6.40-146.el6.x86_64.rpm
    sha:9732c9468ac0f08fc8a646e520f649beade2c4fdf3c0333e1a5981064424c4c3
  • alt-php56-soap-5.6.40-146.el6.x86_64.rpm
    sha:a5e8b58160cc1b0ee64a42543c9faede492a68bf9d9a6dbe0e92ccebaf1e6c41
  • alt-php56-sybase-5.6.40-146.el6.x86_64.rpm
    sha:4312af5a4a93e0d7bbe009a86cc8c85b9a72e87b112a159d1728eb812832781f
  • alt-php56-tidy-5.6.40-146.el6.x86_64.rpm
    sha:36787bacf64a9fb8dd68b466bb2c387151bce6d50b32e3222b37125232e17381
  • alt-php56-xml-5.6.40-146.el6.x86_64.rpm
    sha:74fca928f0c5d4bbd9ab05f1b44002615df1fc1a41a1c76e5a71e337dc31659a
  • alt-php56-xmlrpc-5.6.40-146.el6.x86_64.rpm
    sha:c7c18f424144864b1c5bd114276be78e56193277d906336e604ac9fffdf3e997
Notes:
This page is generated automatically and has not been checked for errors. For clarification or corrections please contact the CloudLinux Packaging Team.