This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org

Difference between revisions of "Testing for NoSQL injection"

From OWASP
Jump to: navigation, search
m
(Background and References.)
Line 8: Line 8:
 
== Description of the Issue ==  
 
== Description of the Issue ==  
 
<br>
 
<br>
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as <pre> < > & ; </pre> will not prevent JSON attacks, whose special characters include <pre> / { } : </pre>
+
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as <code> < > & ; </code> will not prevent attacks against a JSON API, where special characters include <code> / { } : </code>.
  
 
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.
 
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.
 +
 +
NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.
  
 
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.
 
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.
  
 
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.
 
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.
 
 
 
 
<br>
 
<br>
 
== Black Box testing and example ==
 
== Black Box testing and example ==
Line 26: Line 25:
 
== References ==
 
== References ==
 
'''Whitepapers'''<br>
 
'''Whitepapers'''<br>
 +
http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf
 +
http://erlend.oftedal.no/blog/?blogid=110
 +
http://seclists.org/fulldisclosure/2011/Dec/383
 +
https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf
 +
http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection
 
...<br>
 
...<br>
 
'''Tools'''<br>
 
'''Tools'''<br>
 
...<br>
 
...<br>

Revision as of 15:36, 9 August 2013

This article is part of the new OWASP Testing Guide v4.
Back to the OWASP Testing Guide v4 ToC: https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents Back to the OWASP Testing Guide Project: https://www.owasp.org/index.php/OWASP_Testing_Project


Brief Summary


NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[1] language , rather than in the declarative[2] SQL language, the potential impacts are greater than traditional SQL injection.

Description of the Issue


NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as < > & ; will not prevent attacks against a JSON API, where special characters include / { } : .

There are now over 150 NoSQL databases available[3] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.

NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.

Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.

At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.

Black Box testing and example

Testing for Topic X vulnerabilities:
...
Result Expected:
...

References

Whitepapers
http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf http://erlend.oftedal.no/blog/?blogid=110 http://seclists.org/fulldisclosure/2011/Dec/383 https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection ...
Tools
...