[CLSA-2026:1791528807] alt-php56: Fix of CVE-2025-1218
Type:
security
Severity:
Important
Release date:
2026-10-09 06:53:38 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.el9.x86_64.rpm
    sha:9f6f205788793f6a203bd954e670268bdddb1bdafc0d808322c13e8a7fe88079
  • alt-php56-bcmath-5.6.40-146.el9.x86_64.rpm
    sha:829687e6c8317c2ab7d7bdf9cde3c10af20144c906afbb5f34df6505833c1e6a
  • alt-php56-cli-5.6.40-146.el9.x86_64.rpm
    sha:8ea4a9b74e0210a1ec8d59d87f87e976dab54dcb82a8ac403d2f78736f10800c
  • alt-php56-common-5.6.40-146.el9.x86_64.rpm
    sha:1fec14dbd83d3ed0f30910d3c64628c8cc4632bf9696391ea54f99ab67f86201
  • alt-php56-dba-5.6.40-146.el9.x86_64.rpm
    sha:db329fdad99ea66f3da44d3ea0cb87829e8b31ad6f1de60791938f8e31ed90e5
  • alt-php56-dbx-5.6.40-146.el9.x86_64.rpm
    sha:5eaec8e368ce83fe4a1433cb90712c0e4887ed7a244874af4d771e24763ccc84
  • alt-php56-devel-5.6.40-146.el9.x86_64.rpm
    sha:e928371c34bec52cdbe3838cb3eb30a47d52866b17d80e38a83238fcea872bdb
  • alt-php56-enchant-5.6.40-146.el9.x86_64.rpm
    sha:1d94c527632dd656f03c88f238905ec6dfca924864fe5d8aa83ec276d34f8229
  • alt-php56-firebird-5.6.40-146.el9.x86_64.rpm
    sha:d200b650054e321bce2fb130372eddf935b39568ccc033bbb5b1b394247abb41
  • alt-php56-gd-5.6.40-146.el9.x86_64.rpm
    sha:d20787a8f945838fb9e82d8b49619aa2def343a527ae6500f98855e239b5a4cf
  • alt-php56-imap-5.6.40-146.el9.x86_64.rpm
    sha:81b3c416b612d25341249a1e9312b4edd32e8a5d89fd5e33fb62ac0c362a9629
  • alt-php56-intl-5.6.40-146.el9.x86_64.rpm
    sha:14d79e563dc363b01bf46039737962438f295914722d5a33b061eb05bf823181
  • alt-php56-ldap-5.6.40-146.el9.x86_64.rpm
    sha:992f1ebce5369d618a35330e0ab4ed63bcf020f5c6d83955fbd3cec90a1bc101
  • alt-php56-mbstring-5.6.40-146.el9.x86_64.rpm
    sha:12c0d11fbaed835e7c198f84497522ebca7c361ddbb5bf0653431885da9f5964
  • alt-php56-mcrypt-5.6.40-146.el9.x86_64.rpm
    sha:eb3a9882a56bb6130daac733a52ad27332b85ebd307a688a43dfc785efe5ed35
  • alt-php56-mssql-5.6.40-146.el9.x86_64.rpm
    sha:b9d777f407c96de85e0162ede51c770e35d1a5e6d4b24fdc6a61196aebc16aa6
  • alt-php56-mysqlnd-5.6.40-146.el9.x86_64.rpm
    sha:82e7f0cd9f84e95ddd8341023a7037066d882848119e51fd0d938a60e387fd0a
  • alt-php56-odbc-5.6.40-146.el9.x86_64.rpm
    sha:1f0dbccb6f4692a30f38889771c31ba3e70a6d7ef63e6f6f2b36f3573b8293cf
  • alt-php56-opcache-5.6.40-146.el9.x86_64.rpm
    sha:a177069a901e024b622cab9ee322f51e67c9e257cfabf3e51fc3bb1e16295798
  • alt-php56-pdo-5.6.40-146.el9.x86_64.rpm
    sha:b8fc2219692be72c81114a975a2e5230fb86ae7f952187b437fe281782548d0c
  • alt-php56-pgsql-5.6.40-146.el9.x86_64.rpm
    sha:83b7bca818db4a40e01bd3029315f3a91f7c42493a46255f2bd334722a9b8ce7
  • alt-php56-php-fpm-5.6.40-146.el9.x86_64.rpm
    sha:e77fb723f9c8fcdad7e5574f27d2d00f019b77f7e2c9e2435229ae091075f9c7
  • alt-php56-process-5.6.40-146.el9.x86_64.rpm
    sha:3189863d8c4ad589df670318e5ab9d9e5f49d15971df3467694d7b7c052b678b
  • alt-php56-pspell-5.6.40-146.el9.x86_64.rpm
    sha:c627ef209084db47cdcb1a84c5c6b9121b4eee17439f4c8c5f5916bc40b43e7d
  • alt-php56-recode-5.6.40-146.el9.x86_64.rpm
    sha:6dbf4f5c0580a8e2b74f1b728dfffa032b8a45aba9370c9b92cb8f5c07da6065
  • alt-php56-snmp-5.6.40-146.el9.x86_64.rpm
    sha:2d2ebfa5fc6432bbb8af06b6ade65cb67c28837aba05a63634dba1a8c564bcbd
  • alt-php56-soap-5.6.40-146.el9.x86_64.rpm
    sha:7268baa70e5dad5dc041a471e5b7edb0a0074bcdf629818860a33d121e567159
  • alt-php56-sybase-5.6.40-146.el9.x86_64.rpm
    sha:00dfc7e4b02a8e1f176e8801b162dac270c6cac1920cded5bd0790571ed1f265
  • alt-php56-tidy-5.6.40-146.el9.x86_64.rpm
    sha:eba1ec9df5a884ecd887df64cc532678f2916d4ecb4557567bf30c043b300bac
  • alt-php56-xml-5.6.40-146.el9.x86_64.rpm
    sha:016cb749cb9b70943247bfc8578d14cc05fc7c1029a172ff5749a5e7943c7db0
  • alt-php56-xmlrpc-5.6.40-146.el9.x86_64.rpm
    sha:a01388cc6099e16a203bab8f1fb9e57b9a3d2749878d22649a9c7159d071b41b
Notes:
This page is generated automatically and has not been checked for errors. For clarification or corrections please contact the CloudLinux Packaging Team.