Skip to content

Reject site paths that shadow wp-json or core PHP files (Trac #40365) - #66

Merged
lloc merged 2 commits into
dev/mainfrom
fix/valid-path
Oct 26, 2026
Merged

lloc merged 2 commits into
dev/mainfrom
fix/valid-path

Conversation

@lloc

@lloc lloc commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

POST /wp/v2/sites and PUT /wp/v2/sites/<id> accept any well-formed path. In a subdirectory network, a site's path takes priority over everything beneath it so that a single request could take over network-wide routes:

  • /wp-json/: every /wp-json/… request on the network went to the new site and returned a 404 HTML page, so the REST API was down until the site was deleted with WP-CLI. Only ?rest_route= still worked.
  • /wp-login.php/: the network's login page rendered in the subsite's context, with that site's name, options and plugins, and /wp-admin/ redirected there. /xmlrpc.php/ was accepted the same way.

Changes

is_valid_path() now also rejects:

  • a first segment that's one of get_subdirectory_reserved_names() (wp-json, wp-admin, wp-includes, wp-content, feed, embed, comments, blog, page, files). These are the names core already reserves for subdirectory sites.
  • any segment ending in .php.

The patch and tests are synced verbatim from the wordpress-develop branch for #40365, which already has this change.

@lloc
lloc requested review from InpsydeNiklas and amiut October 24, 2026 09:22
@lloc
lloc marked this pull request as ready for review October 24, 2026 09:22
@lloc lloc changed the title eject site paths that shadow wp-json or core PHP files (Trac #40365) Reject site paths that shadow wp-json or core PHP files (Trac #40365) Oct 24, 2026
@github-actions

Copy link
Copy Markdown

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
1 0 1

⚠️ Warnings (1)

📁 modules/SiteActivePlugins/Feature.php (1 warning)
📍 Line 🔖 Check 💬 Message
169 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::FILTER_MAX_SITES".

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@lloc
lloc changed the base branch from main to dev/main October 26, 2026 12:47
Comment thread modules/RestSitesEndpoint/tests/core/wpRestSitesController.php

@amiut amiut left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for incorporating all the changes, LGTM 💪

@lloc
lloc merged commit 144bb9e into dev/main Oct 26, 2026
7 checks passed
@lloc
lloc deleted the fix/valid-path branch October 26, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants