Arbitrary File Deletion
Introduction
This article covers cases of possible Arbitrary File Deletion on WordPress. This includes improper file or directory deletion handling inside of the plugin/theme which can be used to delete arbitrary local files and directories inside of the server.
Useful Functions
Several functions could be useful to identify a possible Arbitrary File Deletion vulnerability:
-
PHP related
-
WordPress related
Example Cases
Below is an example of vulnerable code:
To exploit this, any unauthenticated user just needs to perform a POST request to the /wp-json/myplugin/v1/deletemedia
endpoint specifying the needed parameter to trigger the wp_delete_file
function.