Cross-Site Request Forgery (CSRF)
Introduction
This article covers cases of possible CSRF on WordPress. This includes improper hook/function/code usage inside of the plugin/theme which can be used to trick privileged users into doing sensitive actions.
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, unauthenticated users just need to craft and serve a malicious HTML file and trick privileged users into visiting the HTML file to do the sensitive actions.
admin_init
hook
For more details on the admin_init
hook, please refer to this documentation.
Example of vulnerable code :
To exploit this, unauthenticated users just need to craft and serve a malicious HTML file and trick privileged users into visiting the HTML file to do the sensitive actions.
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, unauthenticated users just need to craft and serve a malicious HTML file and trick privileged users into visiting the HTML file to do the sensitive actions.