A WordPress AJAX handler does not check the user's capabilities
What it finds
A WordPress AJAX handler does not check the user's capabilities
<?phpadd_action('wp_ajax_delete_item', 'delete_item');tx0 reports: the handler delete_item never checks the user's capabilitiesadd_action('wp_ajax_edit_item', 'edit_item'); function delete_item(){ check_ajax_referer('items'); wp_delete_post((int) $_POST['id']);} function edit_item(){ check_ajax_referer('items'); if (!current_user_can('edit_posts')) { wp_die(); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/php:ajax-handler-without-capability" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/php:ajax-handler-without-capability] reason="..."tx0 explain tx0/php:ajax-handler-without-capability shows the same in the terminal. Found a false positive? Report it.