How I Find an Arbitrary File Upload Vulnerability with a Unique Bypass
The WordPress plugin cubewp-framework allowed uploading a ZIP archive whose extracted files were not checked for type or extension, so an attacker could upload PHP files. A recursive deletion routine failed to remove files inside subdirectories because of a PHP scoping mistake, leaving the uploaded PHP files on the server.
I am writing this article to elaborate on a very interesting Arbitrary File Upload (AFU) vulnerability I found during my WordPress Bug Bounty journey on Patchstack’s monthly competition. I caught this AFU from the WordPress plugin cubewp-framework <=1.1.12 and reported it to Patchstack in February 2024.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The plugin extracted ZIP contents without validating file types or extensions, and its recursive cleanup called a class method without $this->, causing an undefined function error that stopped deletion of files in subdirectories.
Impact
An attacker could upload and execute arbitrary PHP code on the WordPress server, though the report notes the fix is not complete.
What the attacker needed
Access to the vulnerable import feature; ability to upload a ZIP archive
The fix
The plugin was patched, but the report says the fix is not complete; properly, uploaded archives should be validated and extracted files checked for type and extension rather than relying on post-upload deletion.
How it was found
- Create a ZIP archive containing a PHP file at the top level and another PHP file inside a subdirectory.
- Upload the ZIP archive through the vulnerable import function.
- The extraction writes the PHP files to the server.
- The cleanup routine fails on the subdirectory, so the PHP file inside it remains accessible.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A plugin let people upload a ZIP file and unpacked it on the server without checking what was inside. Because a cleanup step was broken, a PHP file hidden in a subfolder stayed on the server, and PHP files can run code when visited. This is called an arbitrary file upload.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.