From ed4d7d168027bc8fc574f532decc1108463e16f9 Mon Sep 17 00:00:00 2001 From: Shane Rounce Date: Mon, 23 Nov 2026 21:12:21 +0000 Subject: [PATCH] Networks and Sites: Return a 404 from `ms-files.php` when the file name contains a NUL byte. As of PHP 8.6, `is_file()` throws a `ValueError` for a path containing a NUL byte, where earlier versions returned `false`. A request to `ms-files.php` with `%00` in the `file` argument would then end in an uncaught error instead of the existing 404. This returns the 404 before the path reaches `is_file()`. Follow-up to [65552]. See #66793. --- src/wp-includes/ms-files.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/ms-files.php b/src/wp-includes/ms-files.php index 497cc43e8083a..759adc1370b15 100644 --- a/src/wp-includes/ms-files.php +++ b/src/wp-includes/ms-files.php @@ -30,7 +30,8 @@ die( '500 — Directory not configured.' ); } -if ( ! isset( $_GET['file'] ) || ! is_string( $_GET['file'] ) ) { +// As of PHP 8.6, is_file() throws a ValueError for a path containing a NUL byte. +if ( ! isset( $_GET['file'] ) || ! is_string( $_GET['file'] ) || str_contains( $_GET['file'], "\0" ) ) { status_header( 404 ); die( '404 — File not found.' ); }