WordPress REST API, Expired Nonce from Cache results in 403 forbidden

My wordpress site sits behind Akamai, which is a cacheing service similar to Cloudflare. I make the following API call: GET /wp-json/mytheme/v1/get-posts?post_type=videos This is done using apiFetch from ‘@wordpress/api-fetch’; And it automatically includes this in the request header X-WP-Nonce: 12323423 This works fine until 24 hours later, when the nonce expires. The cache still continues … Read more

Verify Nonce returns false – Request Nonce returns correct value

I’m trying to verify that the nonce I created exists but for some reason it keeps returning false, why is this happening? Creating my nonce: <?php wp_nonce_field(‘test_slider_action’,’test_slider_options_nonce’); ?> Verifying my nonce exists: if($_POST && wp_verify_nonce($_REQUEST[‘test_slider_options_nonce’])) echo “TEST”; if I dump my $_REQUEST I get the correct value, but if I dump my wp_verify_nonce it returns … Read more

How to get the wpnonce value?

On using inspect element to check the ‘href’ attribute of ‘Deactivate’ links for the plugins listed on plugins.php page, I found that the url contains a wpnonce field with a certain value. I need to get this value. For eg, <a href=”https://wordpress.stackexchange.com/questions/115624/plugins.php?action=deactivate&amp;plugin=my-custom-css%2Fmy-custom-css.php&amp;plugin_status=all&amp;paged=1&amp;s&amp;_wpnonce=08a2b0d940″ title=”Deactivate this plugin”>Deactivate</a> How do I get this value ’08a2b0d940′ as in the … Read more

Full page NGINX (or Cloudflare) caching and WordPress nonces

Goal: I want to cache the full WordPress response via NGINX and exclusively use the REST API for the user specific parts. Issue: I can’t get an authenticated nonce to use against the API. My plan was to expose a rest endpoint that returns a valid nonce shown below: add_action( ‘rest_api_init’, function () { register_rest_route( … Read more

Nonces, AJAX, script variables & security in WordPress

Alright, so let’s say you develop a website where you enqueue a js script on a page X of your frontend, using: wp_enqueue_script( ‘script_handle’, PATH_TO_SCRIPT, array(), ‘1.0.0’, true ); Inside this script, you use a simple AJAX request. You then use the nonce feature of wordpress to have what is stated as a safer AJAX … Read more

Nonce actions and names available via open source

I am using a plugin which makes its code publicly available. Therefore, anyone can see the $action and $name parameters used to generate the nonces. Does this make my site more vulnerable since this reduces the added security provided by these parameters? Should I thus replace these parameters with my own values for them? Thanks. … Read more