what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Time-Based Blind NoSQL Injection

Time-Based Blind NoSQL Injection
Posted Dec 19, 2011
Authored by Felipe Daragon | Site syhunt.com

This is a brief write up discussing time-based NoSQL injection attacks using javascript.

tags | paper, javascript, sql injection
SHA-256 | 38f29f6bb429406f5f75bcf44692f842d085e1f1bc2d98124da439be4d863cc3

Time-Based Blind NoSQL Injection

Change Mirror Download
Time-Based Blind NoSQL Injection - Detecting server-side JavaScript 
injection vulnerabilities

In July 2011, Bryan Sullivan, a senior security researcher at Adobe
Systems, demonstrated server-side JavaScript injection vulnerabilities
in web applications using MongoDB and other NoSQL database engines. He
demonstrated how they could be used to perform Denial of Service, File
System, Remote Command Execution, and many other attacks, including the
easy extraction of the entire contents of the NoSQL database -- a blind
NoSQL injection attack (paper here at
https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf).


We not only confirmed the published data about the NoSQL injection
vulnerabilities, but also discovered that the MongoDB shell supports a
sleep() function which makes time-based detection possible of vulnerable
web applications.

It is also possible to inject a custom sleep code, a technique that may
be used to spot injection vulnerabilities in web applications using
server-side JavaScript execution. This is not restricted to MongoDB.

Below you can find two examples of NoSQL injection vulnerabilities in
PHP that could be spotted using these techniques.

Example 1: NoSQL Injection Vulnerability in PHP

The following requests would make these (or similar) vulnerable web
application sleep for 10 seconds:

vulnerable.php?msg=1';sleep(10000);var%20foo='bar

The MongoDB sleep() function works with milliseconds.

Alternative technique using a custom sleep code:

vulnerable.php?msg=1';var%20d%20=%20new%20Date();%20var%20cd%20=%20null;%20do%20{%20cd%20=%20new%20Date();%20}%20while(cd-d%20<%2010000);var%20foo='bar


<?
$mongo = new Mongo();
$db = $mongo->demo;
$id = $_GET['id'];
$js = "function() {
var id = '$id';
SOME CODE...
}";
$response = $db->execute($js);
...
?>

Example 2: NoSQL Injection Vulnerability in PHP

<?
$mongo = new Mongo();
$db = $mongo->demo;
$year = $_GET['year'];
$collection = $db->demo;
$query = 'function() {var search_year = \'' .
$year . '\';' .
'return this.publicationYear == search_year || ' .
' this.filmingYear == search_year || ' .
' this.recordingYear == search_year;}';
$cursor = $collection->find(array('$where' => $query));
...
?>


Example 3: Sleep in JavaScript

var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < 10000); // delay time (ms)

Solution

Always validate user input used in server-side JavaScript commands.

Article by Felipe Aragon. Originally published at
http://www.syhunt.com/?n=Articles.NoSQLInjection

---

Copyright © 2010 Syhunt Security

Disclaimer:
The information in this article is provided "as is" without
warranty of any kind. Details provided are strictly for
educational and defensive purposes.

Syhunt is not liable for any damages caused by direct or
indirect use of the information provided by this article.

Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close