Changes between Initial Version and Version 1 of Ticket #65839
- Timestamp:
- 08/09/2026 11:30:08 AM (2 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #65839 – Description
initial v1 1 WordPress Site Health reports a false positive ofthe REST API as failing with:1 WordPress Site Health can falsely report the REST API as failing with: 2 2 3 ```text 4 REST API Endpoint: https://example.com/wp-json/wp/v2/types/post?context=edit 5 REST API Response: (403) Forbidden 6 ``` 3 REST API Endpoint: https://example.com/wp-json/wp/v2/types/post?context=edit 4 REST API Response: (403) Forbidden 7 5 8 6 The REST response body is: 9 7 10 ```json8 {{{#!json 11 9 {"code":"rest_cookie_invalid_nonce","message":"Cookie check failed","data":{"status":403}} 12 ``` 10 }}} 13 11 14 12 In `WP_Site_Health::get_test_rest_availability()`, core builds the loopback request using: 15 13 16 ```php 14 {{{#!php 15 <?php 17 16 $cookies = wp_unslash( $_COOKIE ); 18 ...19 17 $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout', 'sslverify' ) ); 20 ``` 18 }}} 21 19 22 20 This sends the entire browser cookie jar to the REST endpoint, not just WordPress authentication cookies. … … 24 22 On the affected site, a diagnostic confirmed: 25 23 26 ```text 27 WordPress auth cookies only -> 200 28 WP_Http_Cookie objects only -> 200 29 Explicit Cookie header only -> 200 30 Full $_COOKIE jar, as Site Health -> 403 rest_cookie_invalid_nonce 31 ``` 24 WordPress auth cookies only -> 200 25 WP_Http_Cookie objects only -> 200 26 Explicit Cookie header only -> 200 27 Full $_COOKIE jar, as Site Health -> 403 rest_cookie_invalid_nonce 32 28 33 29 The full cookie jar included unrelated cookies from analytics, LiteSpeed, Cloudflare, WooCommerce, Sourcebuster, Jetpack, `wp-settings-*`, and others. When the outgoing Site Health REST loopback request was filtered to include only: 34 30 35 ```text 36 wordpress_logged_in_* 37 wordpress_sec_* 38 wordpress_test_cookie 39 ``` 31 wordpress_logged_in_* 32 wordpress_sec_* 33 wordpress_test_cookie 40 34 41 35 the Site Health REST API warning cleared immediately. 42 36 43 Expected behavior: 37 **Expected behavior:** 44 38 45 39 Site Health’s authenticated REST loopback test should only send the WordPress cookies required for authentication, or otherwise avoid allowing unrelated browser cookies to interfere with REST nonce/cookie validation. 46 40 47 Actual behavior: 41 **Actual behavior:** 48 42 49 Site Health passes all of `$_COOKIE` into the loopback request. A sufficiently large or complexbrowser cookie jar can cause the REST API availability test to return a false 403, even though the REST endpoint and WordPress authentication cookies are working correctly.43 Site Health passes all of `$_COOKIE` into the loopback request.A sufficiently large or otherwise problematic browser cookie jar can cause the REST API availability test to return a false 403, even though the REST endpoint and WordPress authentication cookies are working correctly. 50 44 51 Suggested fix: 45 **Suggested fix:** 52 46 53 47 In `WP_Site_Health::get_test_rest_availability()`, filter `$cookies` before passing them to `wp_remote_get()` so only WordPress authentication/test cookies are sent.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)