Skip to content
RCE Write-up Advanced

WP Engine security issues

WP Engine's managed WordPress hosting allowed an attacker with admin access or an XSS to escalate to arbitrary PHP code execution via the HTML Post-Processing regex 'e' modifier, and then to OS-level code execution by uploading a shared library and using LD_PRELOAD with the mail() function. The attacker could also enable /server-status to view sensitive information about other sites on the same server.

klikki Follow

Published on klikki.fi

WP Engine is a managed WordPress hosting platform. When it comes to security, WP Engine seems to offer a lot of protection.

klikki, on klikki.fi

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 HTML Post-Processing feature allowed the dangerous 'e' modifier in regular expressions, which evaluates the replacement string as PHP code, and the server permitted setting LD_PRELOAD via putenv() and executing external binaries like sendmail.

Impact

An attacker with admin access or an XSS could achieve arbitrary PHP evaluation and OS-level code execution, and could access sensitive information about other sites on the same server; WP Engine later hardened putenv() to block the LD_PRELOAD technique.

What the attacker needed

WordPress admin access or XSS in admin browser; WP Engine hosting

The fix

WP Engine hardened the putenv() function to prevent setting system-level environment variables, and the issues were fixed in 2016.

How it was found

  1. Compromise the WordPress administrator account or inject JavaScript into the admin's browser.
  2. Add a replacement pattern using the 'e' modifier in the HTML Post-Processing settings to execute PHP code.
  3. Trigger the code by causing the site to generate content matching the pattern, for example by searching for the pattern text.
  4. Compile a shared library and upload it to the server.
  5. Use PHP's putenv() to set LD_PRELOAD to the uploaded library and call mail() to execute an external binary, running the library's init function.
  6. Manipulate .htaccess to enable access to /server-status and view sensitive information about other sites.

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.

WP Engine is a hosting service for WordPress sites. The researcher found that if someone got into a site's admin area, they could use a feature meant for search-and-replace to run their own code on the server, and then use another trick to run programs on the underlying operating system. This meant that a stolen admin password or a cross-site scripting bug could lead to full control of 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.

More by klikki

View all

6 more disclosed reports, best first.

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.