Description
Description
The page template in packages/wp-build/templates/page.php.template hooks an interceptor to admin_init that renders the full generated page whenever $_GET['page'] matches the page slug, then exits (lines 329 to 341 on trunk):
function {{PREFIX}}_{{PAGE_SLUG_UNDERSCORE}}_intercept_render() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['page'] ) && '{{PAGE_SLUG}}' === $_GET['page'] ) { {{PREFIX}}_{{PAGE_SLUG_UNDERSCORE}}_render_page(); exit; } } add_action( 'admin_init', '{{PREFIX}}_{{PAGE_SLUG_UNDERSCORE}}_intercept_render' );
There is no capability check, and the template has no capability placeholder at all. Since wp-admin/admin-post.php fires admin_init for logged-out requests (to support admin_post_nopriv_ actions), every page generated from this template is served to anonymous visitors.
Suggested fix
Add a capability to the page build config, emit it into the template, and guard the interceptor with is_user_logged_in() and current_user_can() before rendering. Limiting the interceptor to the intended admin screen instead of every admin_init would also keep it off admin-post.php entirely. I am happy to work on a PR for this.
Step-by-step reproduction instructions
- Clean WordPress trunk install, no plugins.
- Log out, or use a session with no cookies.
- Request
/wp-admin/admin-post.php?page=font-library.
Result: HTTP 200 with the full font library app shell, block editor scripts, module preloads for the font-list and fonts-home routes, and REST preload data. A PHP deprecation notice from wp-admin/includes/plugin.php also leaks into the page title. The same applies to page=options-connectors and any other page generated from this template. In core, the Fonts menu entry is registered with the edit_theme_options capability, so the interceptor bypasses the gate the menu enforces.
Reported against core as https://core.trac.wordpress.org/ticket/66001. The affected files in core are build artifacts generated from this template, so the fix belongs here.
Screenshots, screen recording, code snippet
No response
Environment info
- WordPress: 7.2-alpha-63166-src (wordpress-develop trunk, local Docker environment)
- PHP: 8.3.33
- Browser: n/a, reproducible with curl
- Plugins: none
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
annezazu commentedon Aug 31, 2026
@draganescu / @aaronjorbin this would be a good candidate for a 7.1.x release. Added it to the project board for consideration.
youknowriad commentedon Aug 31, 2026
Agreed that a capability check seems to be a good addition here. The REST APIs used by these pages are already controlled properly and the menu items linking to these pages as well but a capability check to improve the UX would be better indeed.
courtneyr-dev commentedon Aug 31, 2026
Adding a capability-check control test, since the thread is weighing exposure vs. a hardening gap. I split it into two questions — is the interceptor reachable without the capability, and does anything private actually cross the boundary — and ran both against WordPress 7.1 (the GA release), on single-site and multisite (
wp-includes/build/pages/font-library/page.php, the generated artifact of this template).Reachability (shipped-source). In 7.1
admin-post.phpcallsdo_action( 'admin_init' )at line 27, before itsis_user_logged_in()check at line 36. The interceptor is hooked toadmin_initandexits inside the render, so it runs and returns before auth is ever evaluated. Confirmed — matches the report.What actually crosses the boundary.
wp_font_library_render_page()has nocurrent_user_can()anywhere, but the only server-side data it emits is fromwp_font_library_preload_data(), which preloads exactly two paths:rest_preload_api_request()dispatches each in the current user's context. I dispatched both as logged-out, as an authenticated Subscriber (noedit_theme_options), and as an admin:edit_theme_options/preloadGET /wp/v2/settingsSame numbers on single-site and multisite. The index preload returns only the fields
WP_REST_Server::get_index()adds unconditionally —name,description,url,home,gmt_offset,timezone_string,page_on_front, etc. — which is exactly what any anonymous client already reads from/wp-json/. The fields core gates behindcurrent_user_can( 'upload_files' )(image_sizes,image_size_threshold,image_strip_meta,image_max_bit_depth) showed up for the admin on the multisite run and never for anon or the Subscriber — the boundary holds field by field. The admin's200on the direct settings GET is the positive control: the probe can see private values when they're exposed, and they never appear in the anonymous render.admin_emailand every other gated setting stay behind their permission callback.So @youknowriad's read holds up under test — the REST layer enforces capabilities correctly and independently of this page. The Subscriber row is the piece the logged-out repro doesn't cover: it isolates the capability boundary from the auth boundary and shows the gap is specifically a missing check on the renderer, not anything the data layer gets wrong.
What the gap is, then. An unauthenticated request reaches an admin-screen renderer that runs
set_current_screen(), dispatches two REST requests, and firesfont-library_init,admin_head, andadmin_footer— hooks an extension author can reasonably assume only fire for an authorized admin. No core data leaks; the residual risk is whatever an extension does on those hooks pre-auth. That's a real reason to add the guard, as hardening rather than disclosure.Same in options-connectors, and not new in 7.1. The other generated page preloads the identical two paths, so it's no worse. The interceptor and the absent check are the same in the 7.0.4 build too (0
current_user_can/is_user_logged_inin thatpage.php; only the preloaded_fieldslist differs), so this has shipped for at least two releases — relevant to the 7.1.x backport question.Suggested guard matches what's already proposed: gate the interceptor with
is_user_logged_in()+current_user_can( <the page's cap> ), or only hang it on the intended admin screen so it never runs onadmin_initforadmin-post.php. Emitting a capability into the page config (there's no placeholder today) is the template change that needs to happen.Environment: WordPress 7.1 (GA), single-site and multisite, SQLite, PHP 8.5, no plugins. Same result on both. Happy to share the control-test script and raw output.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Used for: drafting the reproduction and the capability-check control test, running the three-context control matrix against local WordPress 7.1 GA builds (single-site and multisite), and reading the generated
page.phpandWP_REST_Server::get_index()in core source. I reviewed the analysis, re-ran the control test, and take responsibility for the finding and its severity assessment.shameemreza commentedon Sep 1, 2026
Thanks @courtneyr-dev for the detailed test matrix. The Subscriber row separating the capability boundary from the auth boundary is a distinction the original report didn't make, and confirming that nothing capability-gated crosses the REST layer settles the disclosure question. The hardening framing matches what surfaced during the fix too.
The template change you explained is implemented in #82254: the interceptor now calls
auth_redirect()for logged-out visitors andcurrent_user_can()with a per-page capability before rendering, and the page config gained a capability field. It defaults tomanage_options, font-library declaresedit_theme_options, and the other generated pages are matched to the capabilities their menu registrations use. I ran the three contexts from your table against wp-env with the patched build: anonymous gets a 302 to the login screen, a Subscriber gets a 403, and an admin renders normally.The PR is approved and waiting on a committer. If you want to run your matrix against that branch, that would be a useful extra data point, especially for the 7.1.x backport consideration @annezazu raised: #82254