Broken Access Control
Introduction
This article covers cases of possible Broken Access Control on WordPress. This includes improper hook/function/code usage inside of the plugin/theme which can be used to access or update sensitive information.
By default, processes on hooks or functions that are used on plugins or themes donβt have a permission and nonce value check, thatβs why the developer needs to manually perform a permission check using current_user_can
function and the nonce value check using wp_verify_nonce
, check_admin_referer
or check_ajax_referer
functions.
init
hook
For more details on the init
hook, please refer to this documentation.
Example of vulnerable code:
To exploit this, an unauthenticated user just needs to visit the front page of a WordPress site and specify the parameter to trigger the update_option
function which in this case will modify sensitive information.
admin_init
hook
For more details about the admin_init
hook, please refer to this documentation.
Example of vulnerable code:
To exploit this, the unauthenticated user just needs to perform a POST request to the admin-ajax.php
and admin-post.php
endpoints specifying the needed parameter to trigger the delete_option
function to remove sensitive data.
wp_ajax_{$action}
hook
For more details on the wp_ajax_{$action}
hook, please refer to this documentation.
Example of vulnerable code:
To exploit this, any authenticated user (Subscriber+ role) just needs to perform a POST request to the admin-ajax.php
endpoint specifying the needed action and parameter to trigger the update_post_meta
function to update arbitrary WP Post metadata.
wp_ajax_nopriv_{$action}
hook
For more details on the wp_ajax_nopriv_{$action}
hook, please refer to this documentation.
Example of vulnerable code:
To exploit this, any unauthenticated user just needs to perform a POST request to the admin-ajax.php
endpoint specifying the needed action and parameter to trigger the update_option
function.
register_rest_route
function
For more details on the register_rest_route
function, please refer to this documentation.
Sometimes, developers donβt implement a proper permission check on the custom REST API route and use the __return_true
string as the permission callback. This makes the custom REST API route to be publicly accessible.
To exploit this, any unauthenticated user just needs to perform a POST request to the /wp-json/myplugin/v1/delete/author
endpoint specifying the needed parameter to trigger the wp_delete_user
function.
Other cases could exist where developers already specify a proper function on the permission_callback
parameter, however, the permission check implemented inside the function itself is not proper to what process can be done from the REST API route callback
function.