Make WordPress Core

Opened 10 years ago

Last modified 3 months ago

#38076 new defect (bug)

Network admin plugin pages can be accessed on non-multisite

Reported by: flixos90 Owned by:
Priority: normal Milestone: Future Release
Component: Administration Version:
Severity: normal Keywords: has-patch dev-feedback has-unit-tests
Cc: Focuses: multisite

Description

I just noticed that it's theoretically possible to access a plugin-generated page in the network admin panel even if we're not on a multisite setup. The same applies to the user admin panel as well.

To replicate, create a plugin that uses add_menu_page() with a slug my_test_page, hooked into network_admin_menu. Then manually go to the URL http://yourdomain.com/wp-admin/network/admin.php?page=my_test_page.

This happens because the is_multisite() check happens only after including the general wp-admin/admin.php administration bootstrap file which takes care of any plugin pages by itself. The problem is we can't do it before because WordPress hasn't been loaded then. A possible solution would be to split the require_once statement in wp-admin/network/admin.php into two, one to load the WordPress core functions, the other to load wp-admin/admin.php.

I don't think this is a very critical issue, but I thought it should be a ticket. It's very unlikely that anyone tries to access a network admin URL when they don't have a multisite. On the other hand, we catch that in other areas (through ! is_multisite() checks), so we might try to do it here as well.

Attachments (1)

38076.diff​ (708 bytes ) - added by ilovecats7 5 years ago.

Download all attachments as: .zip

Change History (8)

#1 @desrosj
8 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review → Future Release

#2 @ilovecats7
5 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed

When I replicate this bug as per instructions in the ticket description, I get a fatal error. I added a patch that redirects to the admin URL when attempting to access a plugin generated page in the network admin panel when multisite is not enabled.

This ticket was mentioned in ​PR #12933 on ​WordPress/wordpress-develop by ​@arkaprabhachowdhury.


3 months ago
#3

  • Keywords has-unit-tests added

## Summary

  • Load WordPress before the network administration bootstrap.
  • Reject network-admin requests on single-site installs before plugin-page dispatch.
  • Add regression coverage for the single-site bootstrap path.

## Why

wp-admin/network/admin.php previously loaded wp-admin/admin.php before checking is_multisite(). That allowed plugin-generated network admin pages to be dispatched on single-site installations before the request was rejected.

## Testing

  • php -l src/wp-admin/network/admin.php
  • php -l tests/phpunit/tests/admin/wpNetworkAdmin.php
  • php vendor/bin/phpcbf --standard=phpcs.xml.dist src/wp-admin/network/admin.php tests/phpunit/tests/admin/wpNetworkAdmin.php
  • php vendor/bin/phpcs --standard=phpcs.xml.dist src/wp-admin/network/admin.php tests/phpunit/tests/admin/wpNetworkAdmin.php
  • PHPUnit is blocked locally because the test database is unavailable.

#6 @arkaprabhachowdhury
3 months ago

I investigated this ticket against current trunk and confirmed that the network-admin bootstrap can load wp-admin/admin.php before the multisite check rejects the request.

The proposed change moves the WordPress bootstrap before the network-admin dispatch path, rejects network-admin requests on single-site installations before plugin-page dispatch, and adds regression coverage for this bootstrap path.

Pull request: ​https://github.com/WordPress/wordpress-develop/pull/12933

Validation completed:

  • php -l src/wp-admin/network/admin.php
  • php -l tests/phpunit/tests/admin/wpNetworkAdmin.php
  • PHPCBF passed for the touched files.
  • PHPCS passed for the touched files.
  • Focused PHPUnit tests passed with Docker.

I picked this up because the ticket remains relevant to the current bootstrap flow and has a narrow, testable fix.

The PR is ready for core developer feedback, especially on the bootstrap ordering and regression coverage.

#7 @arkaprabhachowdhury
3 months ago

Opened [PR #12933](​https://github.com/WordPress/wordpress-develop/pull/12933) to address this ticket. It guards the network administration bootstrap on single-site installations, moves the bootstrap before network-admin dispatch, and adds regression coverage for the single-site path.

I picked this up because the ticket describes a concrete bootstrap and dispatch-order issue that remains relevant in current WordPress. The change is scoped to the ticket and submitted here for code review.

Last edited 3 months ago by arkaprabhachowdhury (previous) (diff)
Note: See TracTickets for help on using tickets.