Test WordPress REST batch endpoint for RCE

Remote code execution (RCE)Discovery

Written with a model's help from “Patching WP2Shell in the dark using PAI” by Andrea Menin on Sicuranext (WAAP research). Read the writeup before relying on it.

To test for the WordPress core pre-authentication remote code execution vulnerability, send a POST request to the /wp-json/batch/v1 endpoint or use the query-string router with ?rest_route=/batch/v1. Look for a response that indicates the request was processed, such as a 200 OK status code. You can also try injecting malicious sub-requests inside the body of the request to see if the vulnerability is present. The author_exclude parameter on certain WordPress core REST routes, such as /wp/v2/users, can be used to inject malicious input. To confirm the vulnerability, look for signs of SQL injection, such as error messages or unexpected responses. Blocking the entry point to the batch endpoint can be an effective mitigation strategy, as it prevents the malicious sub-requests from being dispatched. You can use a rule like if REQUEST_URI regexMatch "(?i)(/wp-json/batch/v1|[?&]rest_route=/?batch/v1)" to block requests to the endpoint.

Follow #rce or #wordpress for new tips like this one, on your notifications page and, if you choose, in a daily or weekly email.

Comments

No comments yet.