[CLSA-2026:1791533149] alt-php56: Fix of CVE-2025-1218
Type:
security
Severity:
Important
Release date:
2026-10-09 08:06:01 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.el8.x86_64.rpm
    sha:d4d975d16163e0951c2452569be3c2a47a2ca76205b65815073c1b7653231088
  • alt-php56-bcmath-5.6.40-146.el8.x86_64.rpm
    sha:07a39f4a273b23e1ce3951a3db807213672f73c90be0ff52d1a0d9f6aa127e5e
  • alt-php56-cli-5.6.40-146.el8.x86_64.rpm
    sha:f207a66f2290707afc384535932224c9fa356fcb46bda79ed59c666dd82fb31d
  • alt-php56-common-5.6.40-146.el8.x86_64.rpm
    sha:4f22d10a735a6d36ca414fa5c870315e78e7f2ee67178223a8a5b8946472bfe0
  • alt-php56-dba-5.6.40-146.el8.x86_64.rpm
    sha:ef3b297dcd8ab35421f8e7528e38f1ce0ee7409540429209736e74c5719aff98
  • alt-php56-dbx-5.6.40-146.el8.x86_64.rpm
    sha:fdd77cfd28bf8e553e9640c069305784041b50485d77c133cde755674992ffa5
  • alt-php56-devel-5.6.40-146.el8.x86_64.rpm
    sha:4f6e09c77a3f27adcf53fd1ef71fb75afad95827fbc7d4818a6e380c574b46ce
  • alt-php56-enchant-5.6.40-146.el8.x86_64.rpm
    sha:a6039480e9515a22cf212f36234451e98f8b1c84a3ffcdf8e5109b3e1d032dfd
  • alt-php56-firebird-5.6.40-146.el8.x86_64.rpm
    sha:db09b5171398fa20cd9e285f11a2422c503996b54c65ac3a177fe0586b90ddfe
  • alt-php56-gd-5.6.40-146.el8.x86_64.rpm
    sha:91c29f17aa83dd5b7ebb6d81739187f753525fa629f6b832aae1465483f9bd47
  • alt-php56-imap-5.6.40-146.el8.x86_64.rpm
    sha:ba2182997366befb8acc9774fca1d970175bdd1188d8ad3afdd9a2da63814931
  • alt-php56-intl-5.6.40-146.el8.x86_64.rpm
    sha:8af425220d0fb274c323f15c48130c31bcde358f5f7f2f683d04de7adbf6835d
  • alt-php56-ldap-5.6.40-146.el8.x86_64.rpm
    sha:bc8aaf93ded502c5834dcde74dfc241140e50980a67ee9eb12d39d8c868d64e3
  • alt-php56-mbstring-5.6.40-146.el8.x86_64.rpm
    sha:21e77956899b64ce58ce35945649a79b4fc8b8e32414e3724405bbb0a6185499
  • alt-php56-mcrypt-5.6.40-146.el8.x86_64.rpm
    sha:1ba74835842b9469665f06fc025e3cbe84a229dc12ee6ea65d8db41e42da8134
  • alt-php56-mssql-5.6.40-146.el8.x86_64.rpm
    sha:8706da31cdae093736fbc84164a8e237605af209d0a2c7d3ae8b7660fc58380e
  • alt-php56-mysqlnd-5.6.40-146.el8.x86_64.rpm
    sha:9af66b205b69708f97751138d9c812f7ca79ff3ca14b4f81c4b64e8a7f273f4f
  • alt-php56-odbc-5.6.40-146.el8.x86_64.rpm
    sha:5bee8cfd2cd7755f149e412f866fd4ba1acb7eea6489069122ecf175ee926617
  • alt-php56-opcache-5.6.40-146.el8.x86_64.rpm
    sha:a54684315729dcf706a5312b20ea791840d85e57a3c93ebe5de757cbcae90afe
  • alt-php56-pdo-5.6.40-146.el8.x86_64.rpm
    sha:0fc6c1e1e6eb5642f078f8d3d19190851d1bb58803bf14a563de75405f97b376
  • alt-php56-pgsql-5.6.40-146.el8.x86_64.rpm
    sha:52239db505a56c576e762a2311840506c84010ef5f85ee42487f2681585f2053
  • alt-php56-php-fpm-5.6.40-146.el8.x86_64.rpm
    sha:fe94ab3d2845cec1bf44c18742749bbfb2652968c284f3062a558c15f3a4a8dd
  • alt-php56-process-5.6.40-146.el8.x86_64.rpm
    sha:1a8cd567229f39111cf9ecadb5966d4371953aa6329490b86e231f5df8481d50
  • alt-php56-pspell-5.6.40-146.el8.x86_64.rpm
    sha:1c2fd8a8d1084b85998056dc174a4e330ede0fe19498d9f1c96262c2009c2cc5
  • alt-php56-recode-5.6.40-146.el8.x86_64.rpm
    sha:d4855ea71510a96e74cebdff254a11730227b704a30aa1b2374f6dbbd500ec8a
  • alt-php56-snmp-5.6.40-146.el8.x86_64.rpm
    sha:6819fd98ec3a31854de61294e9b3b5de505533a9a91800cf35f7870672b12ac8
  • alt-php56-soap-5.6.40-146.el8.x86_64.rpm
    sha:74d7e637f1b5026ae528622c334aafd073585e4564b0a40bc443c499e75b6bc4
  • alt-php56-sybase-5.6.40-146.el8.x86_64.rpm
    sha:eec12792497a4fb1d78967c205922d6894d411bd1d52765006a20c9dd3cc814a
  • alt-php56-tidy-5.6.40-146.el8.x86_64.rpm
    sha:cbe4164d7683f5823ed595196adf07344b0b745a736f6746646cba18358e47a2
  • alt-php56-xml-5.6.40-146.el8.x86_64.rpm
    sha:19b0078f3e740e26d098b0c1ece54ed4890312f45b64833aceba7c76889b0e01
  • alt-php56-xmlrpc-5.6.40-146.el8.x86_64.rpm
    sha:34c0f6ce173ba0dcc3a2e2b8877118892c894ae3ee5823767d43e054cc38b5bf
Notes:
This page is generated automatically and has not been checked for errors. For clarification or corrections please contact the CloudLinux Packaging Team.