Skip to content
RCE Write-up Advanced

Who is affected?

WordPress allowed users with author privileges to overwrite arbitrary post meta entries, enabling a path traversal that could plant a crafted image in the theme directory and then include it to execute PHP code. An attacker with such access could achieve remote code execution on the server.

blog.ripstech.com

Published on blog.ripstech.com

An attacker who gains access to an account with at least author privileges on a target WordPress site can execute arbitrary PHP code on the underlying server, leading to a full remote takeover. We sent the WordPress security team details about another vulnerability in the WordPress core that can give attackers exactly…

The author, on blog.ripstech.com

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 `edit_post()` function allowed arbitrary post meta entries to be updated without validation, and the image cropping function used the attacker-controlled `_wp_attached_file` value without sanitisation, leading to a path traversal and local file inclusion.

Impact

An attacker with author privileges could execute arbitrary PHP code, leading to full remote takeover; however, the vulnerability was rendered non-exploitable by a patch in versions 4.9.9 and 5.0.1, though the path traversal remains and can be exploited if certain plugins are installed.

What the attacker needed

Account with at least author privileges; WordPress version before 4.9.9 or 5.0.1; or a plugin that mishandles post meta

The fix

The vulnerability was fixed by preventing attackers from setting arbitrary post meta entries, but the path traversal itself remains unpatched.

How it was found

  1. Log in with at least author privileges and upload an image.
  2. Update the image's post meta to set `_wp_attached_file` to a value containing a path traversal and a query string.
  3. Crop the image, causing WordPress to download it from its own server and save the cropped result into the theme directory.
  4. Create a new post and set its `_wp_page_template` meta entry to the path of the planted image.
  5. Visit the post to trigger inclusion of the image, executing the embedded PHP 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 authors edit their posts and attach images. A flaw let them change hidden data about an image, so that when they cropped it, WordPress saved the result outside the normal upload folder and into the theme folder. By putting PHP code inside the image and then making WordPress load it as a template, they could run their own code 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.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.