Exploit-DB #43361
Description: vBulletin 5.x - 'routestring' Remote Code Execution
Type: webapps
Platform: multiple
Date: 2017-12-13
Author: SecuriTeam

Exploit:
# SSD Advisory – vBulletin routestring Unauthenticated Remote Code Execution
Source: https://blogs.securiteam.com/index.php/archives/3569

## Vulnerability Summary
The following advisory describes a unauthenticated file inclusion vulnerability that leads to remote code execution found in vBulletin version 5.

vBulletin, also known as vB, is a widespread proprietary Internet forum software package developed by vBulletin Solutions, Inc., based on PHP and MySQL database server. vBulletin powers many of the largest social sites on the web, with over 100,000 sites built on it, including Fortune 500 and Alexa Top 1M companies websites and forums. According to the latest W3Techs1 statistics, vBulletin version 4 holds more than 55% of the vBulletin market share, while version 3 and 5 divide the remaining percentage

## Credit
An independent security researcher has reported this vulnerability to Beyond Security’s SecuriTeam Secure Disclosure program

## Vendor response
We tried to contact vBulletin since November 21 2017, repeated attempts to establish contact went unanswered. At this time there is no solution or workaround for these vulnerabilities.

## Vulnerability details
vBulletin contains a vulnerability that can allow a remote attacker to include any file from the vBulletin server and execute arbitrary PHP code.

An unauthenticated user is able to send a GET request to /index.php which can then trigger the file inclusion vulnerability with parameter routestring=.

The request allows an attacker to create a crafted request to Vbulletin server installed on Windows OS and include any file on the web server.

**Listing of /index.php:**

```
/* 48 */ $app = vB5_Frontend_Application::init('config.php');
/* 49 */ //todo, move this back so we can catch notices in the startup code. For now, we can set the value in the php.ini
/* 50 */ //file to catch these situations.
/* 51 */ // We report all errors here because we have to make Application Notice free
/* 52 */ error_reporting(E_ALL | E_STRICT);
/* 53 */  
/* 54 */ $config = vB5_Config::instance();
/* 55 */ if (!$config->report_all_php_errors) {
/* 56 */  // Note that E_STRICT became part of E_ALL in PHP 5.4
/* 57 */  error_reporting(E_ALL & ~(E_NOTICE | E_STRICT));
/* 58 */ }
/* 59 */  
/* 60 */ $routing = $app->getRouter();
/* 61 */ $method = $routing->getAction();
/* 62 */ $template = $routing->getTemplate();
/* 63 */ $class = $routing->getControllerClass();
/* 64 */  
/* 65 */ if (!class_exists($class))
/* 66 */ {
/* 67 */  // @todo - this needs a proper error message
/* 68 */  die("Couldn't find controller file for $class");
/* 69 */ }
/* 70 */  
/* 71 */ vB5_Frontend_ExplainQueries::initialize();
/* 72 */ $c = new $class($template);
/* 73 */  
/* 74 */ call_user_func_array(array(&$c, $method), $routing->getArguments());
/* 75 */  
/* 76 */ vB5_Frontend_ExplainQueries::finish();
```

**Let’s take a closer look on vB5_Frontend_Application::init() – Listing of /includes/vb5/frontend/application.php:**

```
/* 15 */   public static function init($configFile)
/* 16 */    {
/* 17 */       parent::init($configFile);
/* 18 */    
/* 19 */       self::$instance = new vB5_Frontend_Application();
/* 20 */       self::$instance->router = new vB5_Frontend_Routing();
/* 21 */       self::$instance->router->setRoutes();
/* ... */
```

We can see that setRoutes() is called:

**Listing of /includes/vb5/frontend/routing.php:**

```
/* 47 */      public function setRoutes()            
/* 48 */      {            
/* 49 */         $this->processQueryString();        
/* 50 */                  
/* 51 */         //TODO: this is a very basic and straight forward way of parsing the URI, we need to improve it        
/* 52 */         //$path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';        
/* 53 */                  
/* 54 */         if (isset($_GET['routestring']))        
/* 55 */         {        
/* 56 */            $path = $_GET['routestring'];      
/* ... */                  
/* 73 */         }        
/* 74 */                  
/* 75 */         if (strlen($path) AND $path{0} == '/')        
/* 76 */         {        
/* 77 */            $path = substr($path, 1);      
/* 78 */         }        
/* 79 */                  
/* 80 */         //If there is an invalid image, js, or css request we wind up here. We can't process any of them        
/* 81 */         if (strlen($path) > 2 )        
/* 82 */         {        
/* 83 */            $ext = strtolower(substr($path, -4)) ;      
/* 84 */            if (($ext == /* 47 */      public function setRoutes()            
/* 48 */      {            
/* 49 */         $this->processQueryString();        
/* 50 */                  
/* 51 */         //TODO: this is a very basic and straight forward way of parsing the URI, we need to improve it        
/* 52 */         //$path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';        
/* 53 */                  
/* 54 */         if (isset($_GET['routestring']))        
/* 55 */         {        
/* 56 */            $path = $_GET['routestring'];      
/* ... */                  
/* 73 */         }        
/* 74 */                  
/* 75 */         if (strlen($path) AND $path{0} == '/')        
/* 76 */         {        
/* 77 */            $path = substr($path, 1);      
/* 78 */         }        
/* 79 */                  
/* 80 */         //If there is an invalid image, js, or css request we wind up here. We can't process any of them        
/* 81 */         if (strlen($path) > 2 )        
/* 82 */         {        
/* 83 */            $ext = strtolower(substr($path, -4)) ;      
/* 84 */            if (($ext == '.gif') OR ($ext == '.png') OR ($ext == '.jpg') OR ($ext == '.css')      
/* 85 */               OR (strtolower(substr($path, -3)) == '.js') )  
/* 86 */            {      
/* 87 */               header("HTTP/1.0 404