[php-src] PHP-8.2: Fix GHSA-fm2m-fjf5-v3cp: RCE via corrupted session file

From: Date: Thu, 19 Nov 2026 15:26:26 +0000
Subject: [php-src] PHP-8.2: Fix GHSA-fm2m-fjf5-v3cp: RCE via corrupted session file
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143908@lists.php.net to get a copy of this message
Author: Ilija Tovilo (iluuu1994) Committer: Jakub Zelenka (bukka) Date: 2026-11-19T16:08:08+01:00 Commit: https://github.com/php/php-src/commit/e2d3cee9ad4b0b739f4a8ebe6a69c938399b7da6 Raw diff: https://github.com/php/php-src/commit/e2d3cee9ad4b0b739f4a8ebe6a69c938399b7da6.diff Fix GHSA-fm2m-fjf5-v3cp: RCE via corrupted session file If the session write is interrupted, and the previous session file wasn't truncated, we can end up with two partial sessions concatenated together. The approximate location of failure may be attacker-controllable in threaded environments if another thread causes the process to _exit(). Changed paths: M ext/session/mod_files.c Diff: diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 9396f16b9358..c619b26bd222 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -236,9 +236,9 @@ static zend_result ps_files_write(ps_files *data, zend_string *key, zend_string return FAILURE; } - /* Truncate file if the amount of new data is smaller than the existing data set. */ - if (ZSTR_LEN(val) < data->st_size) { - php_ignore_value(ftruncate(data->fd, 0)); + if (ftruncate(data->fd, 0) != 0) { + php_error_docref(NULL, E_WARNING, "ftruncate() failed: %s (%d)", strerror(errno), errno); + return FAILURE; } #ifdef HAVE_PWRITE

« previous php.cvs (#143908) next »