[php-src] PR #25900: Fix UAF in MessageFormatter::format() on re-entrant setPattern()

From: Date: Sun, 29 Nov 2026 13:32:53 +0000
Subject: [php-src] PR #25900: Fix UAF in MessageFormatter::format() on re-entrant setPattern()
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41199@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25900 Author: hohphu8 In umsg_format_helper() (ext/intl/msgformat/msgformat_helpers.cpp), local pointers mf (mfo->mf_data.umsgf) and types (mfo->mf_data.arg_types) are cached before iterating over arguments. If an argument's __toString() calls $mf->setPattern(), msgfmt_set_pattern() destroys both mfo->mf_data.umsgf and mfo->mf_data.arg_types (and resets tz_set), causing a use-after-free on the next iteration (ht is already destroyed assertion failure in debug builds) and when calling mf->format() (even with a single argument). Exceptions thrown from __toString() were also not checked before continuing argument processing or returning from msgfmt_do_format(). Return cached mfo->mf_data.arg_types directly in umsg_get_types(), re-fetch types per iteration, reload mfo->mf_data.umsgf and run umsg_set_timezone() after the loop, and bail out when EG(exception) is set (including RETURN_THROWS() in msgfmt_do_format()). Added a regression test covering single-argument (mf UAF) and multi-argument (types + mf UAF) re-entrant setPattern(), incompatible pattern mutation, and exceptions thrown from __toString(). Note: AI-assisted code audit; manually verified and reproduced locally.

« previous php.git-pulls (#41199) next »