Time-Based Blind NoSQL Injection

简介:  http://packetstorm.wowhacker.com/papers/general/timebased-nosql.
 
http://packetstorm.wowhacker.com/papers/general/timebased-nosql.txt
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.

目录
相关文章
|
4月前
|
人工智能 运维 NoSQL
云栖大会|AI浪潮下的NoSQL演进:下一代数据库的破局之道
AI浪潮下的NoSQL演进:下一代数据库的破局之道
|
8月前
|
存储 NoSQL 搜索推荐
NoSQL数据库分类概览
以上就是我们的NoSQL数据库奇幻之旅。每一种NoSQL数据库都有自己独特的魅力和专长,择选合适的数据库,就像在魔法世界中挑选最适合自己的魔杖,使你的数据管理变得更加高效和神奇。在当今数据驱动的时代,懂得这些数据库的秘密,就掌握了处理各种数据挑战的关键。
431 61
|
存储 监控 NoSQL
九大核心NoSQL数据库及使用场景详解
【10月更文挑战第6天】在当今大数据与云计算飞速发展的时代,NoSQL数据库以其灵活的数据模型、可扩展性和高性能,成为了众多应用场景下的首选。本文将为您详细介绍九大核心NoSQL数据库及其典型使用场景,帮助您在工作和学习中更好地选择和应用。
686 3
|
NoSQL 关系型数据库 MySQL
微服务架构下的数据库选择:MySQL、PostgreSQL 还是 NoSQL?
在微服务架构中,数据库的选择至关重要。不同类型的数据库适用于不同的需求和场景。在本文章中,我们将深入探讨传统的关系型数据库(如 MySQL 和 PostgreSQL)与现代 NoSQL 数据库的优劣势,并分析在微服务架构下的最佳实践。
|
存储 NoSQL 关系型数据库
【赵渝强老师】什么是NoSQL数据库?
随着大数据技术的兴起,NoSQL数据库(Not Only SQL)得到广泛应用。它不局限于二维表结构,允许数据冗余。常见的NoSQL数据库包括Redis、MongoDB和HBase。Redis是基于内存的高性能数据库,采用单线程模型和多路复用I/O,支持高效的数据结构。MongoDB使用BSON格式存储文档,查询语言强大,类似关系型数据库。HBase基于HDFS,适合数据分析,采用列式存储,支持灵活的列族设计。视频讲解及更多内容见下文。
694 79
|
存储 缓存 NoSQL
常见的 NoSQL 数据库有哪些?
常见的 NoSQL 数据库有哪些?
974 59
|
存储 SQL JSON
介绍一下RDBMS和NoSQL数据库之间的区别
【10月更文挑战第21天】介绍一下RDBMS和NoSQL数据库之间的区别
520 2
|
存储 SQL NoSQL
数据库技术深度探索:从关系型到NoSQL的演变
【10月更文挑战第21天】数据库技术深度探索:从关系型到NoSQL的演变
347 1
|
存储 NoSQL 搜索推荐
nosql
【10月更文挑战第14天】nosql
276 2
|
NoSQL MongoDB 数据库
MongoDB是一个NoSQL数据库,有着多种不同的命令和操作。以下是一些常见的MongoDB命令:
一些常用的MongoDB命令,如数据库和集合的管理、数据的插入、查询、更新、删除以及聚合操作等。
201 1

热门文章

最新文章