Zero Day Vulnerability in many Wordpress Themes
The timthumb.php image resizing utility, bundled with many WordPress themes, checked allowed hostnames with a partial string match, so an attacker could host a PHP file on a domain whose name contained an allowed hostname and have timthumb fetch it into a web-accessible cache directory. The attacker could then execute arbitrary PHP code on the server, as happened to the author's blog.
markmaunder.com
Published on markmaunder.com
Security, TimThumb, Wordpress
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 script used a substring search (strpos) to check whether the remote hostname contained an allowed domain, instead of matching the hostname exactly.
What the attacker needed
WordPress theme bundles timthumb.php; Cache directory executes PHP files; Attacker controls a domain containing an allowed name
The fix
The allowed-sites list should be emptied or the script removed, and the developer should use a regular expression to check external hostnames exactly.
How it was found
- Create a PHP file on a web server whose hostname contains an allowed domain name.
- Tell timthumb.php to fetch that file so it is saved in the cache directory.
- Access the saved file in the cache directory through a browser to execute it.
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 WordPress theme included a helper script that downloads images from other websites and saves them in a folder on your server. The script checked the website address with a loose text search, so a malicious site with an allowed name inside its address could trick it into downloading a PHP program. Because that folder could run PHP, the attacker could then run 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.