Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Multiple Web Application Vulnerabilities in RockMongo

During a recent code review for a client, I also took a brief look at a tool they were using to manage their MongoDB platform. The tool, called RockMongo, provides similar functionality for MongoDB NoSQL databases as PHPMyAdmin does for MySQL. Fortunately this client follows recommended practices and has restricted this tool to internal access only.

We have attempted multiple times to contact the RockMongo developers to disclose these vulnerabilities to them. However, we have received no response. Our recommendation is to restrict access to this tool and not expose it to the Internet. Additionally, I will be providing mitigation recommendations in this post.

The first vulnerability identified was Reflected Cross-Site Scripting (XSS) in the main login page of the application. It was as simple as this…



The interesting thing about this vulnerability was that they actually have a means to mitigate it in their code already. This is the function in "rock.php" that gets the parameters from the URL…

* 获取参数的值
* 与x($name)不同的是,该函数获取的参数不会被自动过滤(通过trim和htmlspecialchars)
* @param string $name 参数名
* @return mixed
* @see x
function xn($name = nil) {
if ($name == nil) {
array_merge(rock_filter_param($GLOBALS["ROCK_HTTP_VARS"], false), $GLOBALS["ROCK_USER_VARS"]);

if (array_key_exists($name,
return $GLOBALS["ROCK_USER_VARS"][$name];
if (array_key_exists($name,
rock_filter_param($GLOBALS["ROCK_HTTP_VARS"][$name], false);
return null;

When the comments are translated, we find this "theparameters of this function are not automatically get filtered (through thetrim and htmlspecialchars)". Filtering is normally provided by anotherfunction…

* 过滤参数
* @param string $param 参数
* @param boolean $filter 是否过滤
* @return mixed
function rock_filter_param($param, $filter = true) {
if (!is_array($param) && !is_object($param)) {
if (ini_get("magic_quotes_gpc")) {
$param = stripslashes($param);
return $filter ? htmlspecialchars(trim($param)) : $param;
foreach ($param as $key => $value) {
$param[$key] = rock_filter_param($value, $filter);
return $param;

As you can see in the xn()function, they are explicitly disabling the filter [rock_filter_param($GLOBALS["ROCK_HTTP_VARS"], false)]. As such, anywhere that function gets used isvulnerable. Until an official patch is available from the vendor, you mightconsider changing this second parameter to true in the calls to rock_filter_param() from the xn() function.

The second vulnerability discovered was a Local FileInclusion (LFI) and Path Traversal vulnerability. This vulnerability is alsopre-authentication. It allows an attacker to read arbitrary files on the serverand possibly execute arbitrary code.

The vulnerability lies with the use of the "ROCK_LANG"cookie. The application uses this cookie's value in the included path to alanguage file, and since the platform runs on PHP it also suffers from NULLbyte injection. The following example shows how this can be used to display theserver's "/etc/password" file.

Here is the request to the server…

GET/index.php?action=login.index&host=0 HTTP/1.1
Host: A.B.C.D
User-Agent: Mozilla/5.0
(Macintosh; Intel Mac OS X 10.8; rv:18.0) Gecko/20100101 Firefox/18.0
Accept-Encoding: gzip,deflate
Connection: keep-alive

…with the following result.


There appear to be two functions that arevulnerable to this attack, rock_lang() in "rock.php" and message() in"app/lib/page/RPage.php". For example in "rock.php", the __LANG__constant gets set from rock_init_lang() function…

function rock_init_lang()
if (isset($_COOKIE["ROCK_LANG"])) {
define("__LANG__", $_COOKIE["ROCK_LANG"]);

…which is then included in the rock_lang()function.

function rock_lang($code)
if (!isset($GLOBALS["ROCK_LANGS"])) {
$file = __ROOT__ . "/langs/" . __LANG__ . "/message.php";

Until the developer can provide a patch, you may consider validating the __LANG__ parameter in "rock.php" with a regular expression like so…

function rock_init_lang()
if (isset($_COOKIE["ROCK_LANG"])) {
if (preg_match('/^[a-z]{2}_[a-z]{2}$/', $_COOKIE["ROCK_LANG"]) {
else {
define("__LANG__", "en_en");

I would also recommend you keep checking back with the developer to see if they release a patch. The latest version of RockMongo can be downloaded here.

Latest SpiderLabs Blogs

Hunting For Integer Overflows In Web Servers

Allow me to set the scene and start proceedings off with a definition of an integer overflow, according to Wikipedia:

Read More

Welcome to Adventures in Cybersecurity: The Defender Series

I’m happy to say I’m done chasing Microsoft certifications (AZ104/AZ500/SC100), and as a result, I’ve had the time to put some effort into a blog series that hopefully will entertain and inform you...

Read More

Trustwave SpiderLabs: Insights and Solutions to Defend Educational Institutions Against Cyber Threats

Security teams responsible for defending educational institutions at higher education and primary school levels often find themselves facing harsh lessons from threat actors who exploit the numerous...

Read More