sqlmap icon indicating copy to clipboard operation
sqlmap copied to clipboard

noSQL DB Support Feature Request

Open pand0rausa opened this issue 10 years ago • 16 comments

Would love to see support for nosql databases such as Mongo.

pand0rausa avatar Jan 18 '16 18:01 pand0rausa

But what would be the support for nosql database(s)? To dump the current table (iterating through index values)? Execution of malicious Javascript?

stamparm avatar Jan 18 '16 21:01 stamparm

ping?

stamparm avatar Jan 21 '16 09:01 stamparm

Automated identification of vulnerable systems. Dumping of data/information, list databases. Identification of noSQL db type. inject shell (where possible). Does that answer your question?

pand0rausa avatar Jan 22 '16 03:01 pand0rausa

Nope. Have you ever done the noSQL injection? Are you aware of its possibilities? Things like list databases and inject shell are something from SQL world

stamparm avatar Jan 22 '16 08:01 stamparm

I have been using noSqlMap to do those exact tests. Was hoping that sqlmap would be able to incorporate them into it so that there was only one tool to rule them all. You should go take a look at noSqlMap.

pand0rausa avatar Jan 22 '16 15:01 pand0rausa

Ok. You are not first one that is asking this. I guess that this means that I've already previously considered this, but I have kind of objection here.

Please, you should take a look into the nosqlmap source to continue this conversation.

nosqlmap is not an injection tool. It uses open management ports of (currently only 2) NoSQL DBMSes, connects directly and does the enumeration/dumping.

sqlmap uses primarily web based SQL injections to perform this. Nevertheless, there is also a -d option which could be further improved and/or revamped to assimilate nosqlmap efforts.

So, if users are ok with -d option for this purpose (e.g. mongo://..) then I can do this. If users will expect NoSQL injections in web pages, then I'll need to drop this whole nosqlmap assimilation idea

stamparm avatar Jan 22 '16 17:01 stamparm

I wrote a boolean-based NoSQL injection module for Metasploit which takes advantage of a feature of older MongoDB to enumerate document stores.

https://community.rapid7.com/community/metasploit/blog/2014/06/12/you-have-no-sql-inj--sorry-nosql-injections-in-your-application

https://www.rapid7.com/db/modules/auxiliary/gather/mongodb_js_inject_collection_enum

TBH, I am not sure if NoSQL is something that sqlmap should really care about. If it were implemented, I would hope it is not on by default.

brandonprry avatar Jan 22 '16 17:01 brandonprry

NoSQLmap also targets the web application to find where validation isn't being done to output/dump the data (options of doing either a GET or POST and over SSL). The management port is definitely a much bigger issue/risk but (IMO) and there are potential (depending on content) benefits of dumping from the web app (just like SQL). I think the world of sqlmap and IMO think there is a crossover here. nosqlmap is good for it's purpose and I hate to ask someone to redo work that is already out there though I would like to have only one tool to work with.

pand0rausa avatar Jan 22 '16 22:01 pand0rausa

I've seen this discussion just at the time when I'm implementing application that uses MongoDB for the first time. While researching Mongo, among the first blog posts/code samples I've found, there is one that, at least to my inexperienced Mongo eyes, looks injectable:

    def city = jongo.getCollection("city").findOne("{name:'$cityName'}").as(City)

In that code sample, $cityName is a variable that comes unfiltered from the user input, and could possibly be used to inject an always true filtering criteria where such an option was not intended by the application logic.

But what would be the support for nosql database(s)? To dump the current table (iterating through index values)? Execution of malicious Javascript?

In my opinion, it would be nice if sqlmap could attempt to test for and detect such issues, possibly also offering to dump collections etc...

knes1 avatar Feb 11 '16 11:02 knes1

Actually nosql injections do exist, as well as, remote file reads, rce, etc. I actually am not a fan of not nosqlmap. Currently I do all my nosql exploitation manually and have small tools I've wrote for fuzzing with burp. I may fork this project and integrate myself because I'm encountering couch,redis,and Mongo regularly. If your open to it, I'll submit a PR.

ustayready avatar May 26 '16 18:05 ustayready

remote file reads, rce + nosql injections

can anybody please contact me privately with "real" examples for this (other than the claims that they exist around)? connecting directly to administration ports doesn't count. Also, exploits that work on certain range of deprecated versions doesn't count either.

stamparm avatar May 26 '16 23:05 stamparm

Leaving this here for reference: http://www.slideshare.net/cyber-punk/mongo-db-eng http://blog.securelayer7.net/mongodb-security-injection-attacks-with-php/

stamparm avatar Jun 03 '16 10:06 stamparm

I would really like to leverage the automated aspect (i.e. API) of SQLmap for nosql attacks, so +1 from me

HowWeRollingham avatar Mar 09 '18 12:03 HowWeRollingham

@HowWeRollingham Do you have an example NoSQL injection that you can leverage to extract data? If so, could you provide the details?

brandonprry avatar Mar 09 '18 14:03 brandonprry

SQL and NoSQL are two different beasts. Attack plane for SQL (injection) vulnerable targets is something completely different than in case of NoSQL. While in SQL injection you really need only one vulnerable parameter to pivot through the backend DBMS stored content, in case of NoSQL you either target the misconfiguration of the service itself (direct access through the Internet accessible port) or you have a pretty limited "injection" potential in web application part. Now, ideally, both cases would both have an "injection" as a primary attack plane, which would lead to some kind of merging of those two projects (sqlmap and noSQLmap). Reality is different and that prevents us in sqlmap to expand in this area. sqlmap is a specialized tool for SQL injection, where NoSQL could hardly be incorporated. Hence, it is normal to have two different tools for two different purposes.

stamparm avatar Feb 20 '19 23:02 stamparm

implemented recently with --nosql Test for NoSQL injection

stamparm avatar Jul 07 '26 15:07 stamparm