Error-Based MongoDB Injection

Severity: High
Summary#

Invicti detected that the application is vulnerable to error-based MongoDB injection. MongoDB injections occur when applications doesn't sanitize user input, which is then interpreted by a MongoDB database.

Impact#

Depending on the backend database version, an attacker can perform one of the following types of attacks successfully:

  • Read arbitrary data
  • Collect sensitive information about the backend server configuration
Actions To Take#
  1. See the remedy for solution.
  2. If you are not using a database access layer (DAL) within the architecture consider its benefits and implement if appropriate. As a minimum the use of s DAL will help centralize the issue and its resolution. You can also use ORM (object relational mapping). Most ORM systems use parameterized queries and this can solve many if not all SQL injection based problems.
  3. Locate all of the dynamically generated SQL queries and convert them to parameterized queries. (If you decide to use a DAL/ORM, change all legacy code to use these new libraries.)
  4. Monitor and review weblogs and application logs to uncover active or previous exploitation attempts.
Remediation#

To avoid this vulnerability;

  • Sanitize user-supplied input
  • Avoid using where, mapReduce and group operators with user input
  • If possible set javascriptEnabled to false in mongod.conf
  • Use most recent version of MongoDB.
Required Skills for Successful Exploitation#
There are numerous freely available tools to test for SQL injection vulnerabilities. This is a complex area with many dependencies; however, it should be noted that the numerous resources available in this area have raised both attacker awareness of the issues and their ability to discover and leverage them. SQL injection is one of the most common web application vulnerabilities.
Invicti

Dead accurate, fast & easy-to-use Web Application Security Scanner

Get a demo