WordPress Hardening Mechanisms
WordPress allows administrators to change the media upload path to the theme directory, and a local file inclusion flaw in theme handling lets them include an uploaded text file containing PHP code, achieving remote code execution even when file editing and modification are disabled. An attacker who hijacks an administrator session via XSS could therefore still execute code on the server.
blog.ripstech.com
Published on blog.ripstech.com
WordPress per default allows users with the administrator role to install plugins and even edit the .php files of plugins from within the admin dashboard. Although this allows for the easy modification of plugins and themes, it also allows malicious administrators to execute code on the underlying web server and…
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
Likely the theme template inclusion mechanism does not properly restrict which files can be included, allowing an uploaded file in the theme directory to be executed as PHP.
Impact
An attacker with administrator access could execute arbitrary code on the web server, even when the DISALLOW_FILE_EDIT and DISALLOW_FILE_MODS hardening options are enabled.
What the attacker needed
Administrator access; WordPress prior to 5.2.4
The fix
The vulnerability was fixed in WordPress version 5.2.4.
How it was found
- Log in as an administrator.
- Change the media upload path to the theme directory.
- Upload a text file containing PHP code to the theme directory.
- Set a post to use the uploaded file as its template.
- View the post to trigger inclusion and execute the code.
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.
WordPress lets administrators upload files and choose where they are saved. A flaw in how WordPress loads theme templates means it can be tricked into running a file that was uploaded as plain text. This lets an attacker who takes over an admin account still run harmful code on the server, even if the site owner has turned off the usual file-editing features.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.