Remote Code Execution in the Import Channel function
An administrator can upload a zip archive containing a PHP script during channel import; if the import fails, the extracted files remain in a temporary directory. The attacker can then execute the PHP script by accessing it directly, leading to remote code execution.
- Triaged in 4 days
- Fixed in 11 days
- Disclosed after 10 months
Hello,
Administrators are allow to import channels by visiting http://HOST/PATH_TO_EE/admin.php?/cp/channels/sets and uploading .zip archives that contain the information about the channels to be imported. The archives are then extracted into temporary directories, which are kept in the /system/user/cache/cset/ directory. The problem is that, if the archive doesn't have all the required files for the import to be successful, the extracted files remain in their folders and an error is thrown to the administrator stating that a file doesn't exist in the archive.
This allows an administrator to upload .php scripts to the server, which is not allowed by default in ExpressionEngine as far as I can see.
###Steps to reproduce: 1- Download the attached .zip archive and browse to http://HOST/PATH_TO_EE/admin.php?/cp/channels/sets 2- Try to upload the zip file you just downloaded as the imported channel 3- Navigate to http://HOST/PATH_TO_EE/system/user/cache/cset/, which will show a directory listing of all the temporary directories, this is a problem by itself 4- If this is your first time trying this, you should find a single directory, click the directory's name and then click the test.php file and edit the URL in the address bar by adding "?cmd=whoami" to the URL 5- Notice that the command has executed and that the information is returned in the page
Regards,
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the import process extracts uploaded archives into a web-accessible directory and does not clean up on failure, allowing execution of uploaded PHP files.
Impact
An administrator can execute arbitrary commands on the server.
What the attacker needed
Administrator access
The fix
The import process should clean up extracted files on failure and store them outside the web root.
How it was found
- Download the provided zip archive and go to the channel import page.
- Upload the zip file as the channel import.
- Navigate to the temporary directory listing at /system/user/cache/cset/.
- Open the extracted directory and click on test.php.
- Append ?cmd=whoami to the URL to execute a command.
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 report has not been written yet. The Original tab links to the source.
The software lets an admin upload a zip file to import settings. If the zip is missing some files, the import fails but the uploaded files are left behind in a web-accessible folder. Because one of those files is a PHP script, the attacker can run it and execute commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.