27017,27018 - Pentesting MongoDB
Tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें और HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में PRs सबमिट करें।
बुनियादी जानकारी
MongoDB एक ओपन सोर्स डेटाबेस प्रबंधन प्रणाली है जो विभिन्न प्रकार के डेटा को संभालने के लिए दस्तावेज़-उन्मुख डेटाबेस मॉडल का उपयोग करती है। यह अन-संरचित या अर्ध-संरचित डेटा के प्रबंधन के लिए लचीलापन और स्केलेबिलिटी प्रदान करती है, जैसे बड़े डेटा एनालिटिक्स और सामग्री प्रबंधन जैसी एप्लिकेशन में। डिफ़ॉल्ट पोर्ट: 27017, 27018
PORT STATE SERVICE VERSION
27017/tcp open mongodb MongoDB 2.6.9 2.6.9
Enumeration
Manual
from pymongo import MongoClient
client = MongoClient(host, port, username=username, password=password)
client.server_info() #Basic info
#If you have admin access you can obtain more info
admin = client.admin
admin_info = admin.command("serverStatus")
cursor = client.list_databases()
for db in cursor:
print(db)
print(client[db["name"]].list_collection_names())
#If admin access, you could dump the database also
कुछ MongoDB कमांड:
show dbs
use <db>
show collections
db.<collection>.find() #Dump the collection
db.<collection>.count() #Number of records of the collection
db.current.find({"username":"admin"}) #Find in current db the username admin
स्वचालित
nmap -sV --script "mongo* and default" -p 27017 <IP> #By default all the nmap mongo enumerate scripts are used
Shodan
- सभी mongodb:
"mongodb server information" - खुले पूर्ण mongodb सर्वरों के लिए खोजें:
"mongodb server information" -"partially enabled" - केवल आंशिक रूप से सक्षम auth:
"mongodb server information" "partially enabled"
Login
डिफ़ॉल्ट रूप से mongo को पासवर्ड की आवश्यकता नहीं होती।
Admin एक सामान्य mongo डेटाबेस है।
mongo <HOST>
mongo <HOST>:<PORT>
mongo <HOST>:<PORT>/<DB>
mongo <database> -u <username> -p '<password>'
nmap स्क्रिप्ट: mongodb-brute जांचेगी कि creds की आवश्यकता है या नहीं.
nmap -n -sV --script mongodb-brute -p 27017 <ip>
Brute force
जानने के लिए /opt/bitnami/mongodb/mongodb.conf के अंदर देखें कि credentials की आवश्यकता है या नहीं:
grep "noauth.*true" /opt/bitnami/mongodb/mongodb.conf | grep -v "^#" #Not needed
grep "auth.*true" /opt/bitnami/mongodb/mongodb.conf | grep -v "^#\|noauth" #Not needed
Mongo Objectid Predict
उदाहरण यहाँ से।
Mongo Object IDs are 12-byte hexadecimal strings:

For example, here’s how we can dissect an actual Object ID returned by an application: 5f2459ac9fa6dc2500314019
- 5f2459ac: 1596217772 in decimal = Friday, 31 July 2020 17:49:32
- 9fa6dc: Machine Identifier
- 2500: Process ID
- 314019: An incremental counter
उपरोक्त तत्वों में, machine identifier वही रहेगा जब तक डेटाबेस उसी physical/virtual machine पर चल रहा है। Process ID केवल तब बदलेगा जब MongoDB process को restart किया जाएगा। Timestamp हर सेकंड अपडेट होगा। Object IDs को केवल counter और timestamp को increment करके अनुमान लगाने में चुनौती यह है कि MongoDB System स्तर पर Object IDs जनरेट और असाइन करता है।
The tool https://github.com/andresriancho/mongo-objectid-predict, given a starting Object ID (you can create an account and get a starting ID), it sends back about 1000 probable Object IDs that could have possibly been assigned to the next objects, so you just need to bruteforce them.
Post
If you are root you can modify the mongodb.conf file so no credentials are needed (noauth = true) and login without credentials.
MongoBleed zlib Memory Disclosure (CVE-2025-14847)
A widespread unauthenticated memory disclosure (“MongoBleed”) impacts MongoDB 3.6–8.2 when the zlib network compressor is enabled. The OP_COMPRESSED header trusts an attacker-supplied uncompressedSize, so the server allocates a buffer of that size and copies it back into responses even though only a much smaller compressed payload was provided. The extra bytes are uninitialized heap data from other connections, /proc, or the WiredTiger cache. Attackers then omit the expected BSON \x00 terminator so MongoDB’s parser keeps scanning that oversized buffer until it finds a terminator, and the error response echoes both the malicious document and the scanned heap bytes pre-auth on TCP/27017.
Exposure requirements & quick checks
- Server version must be within the vulnerable ranges (3.6, 4.0, 4.2, 4.4.0–4.4.29, 5.0.0–5.0.31, 6.0.0–6.0.26, 7.0.0–7.0.27, 8.0.0–8.0.16, 8.2.0–8.2.2).
net.compression.compressorsornetworkMessageCompressorsmust includezlib(default on many builds). Check it from the shell with:
db.adminCommand({getParameter: 1, networkMessageCompressors: 1})
- The attacker को केवल MongoDB पोर्ट तक नेटवर्क एक्सेस चाहिए। No authentication आवश्यक नहीं है।
Exploitation & harvesting workflow
compressors:["zlib"]advertise करते हुए wire-protocol handshake शुरू करें ताकि session zlib उपयोग करे।- वास्तविक decompressed payload की तुलना में घोषित
uncompressedSizeबहुत बड़ी बताने वालेOP_COMPRESSEDframes भेजें ताकि oversized heap allocation full of old data मजबूर हो। - embedded BSON को without a final
\x00craft करें ताकि parser terminator ढूँढते हुए attacker-controlled डेटा को पार कर oversized buffer में चला जाए। - MongoDB एक error emit करता है जो original message के साथ-साथ scanned heap bytes को शामिल करता है, leaking memory. अलग-अलग lengths/offsets के साथ इसे repeat करें ताकि secrets (creds/API keys/session tokens), WiredTiger stats, और
/procartifacts को aggregate किया जा सके।
The public PoC probing offsets और returned fragments की carving को automate करता है:
python3 mongobleed.py --host <target> --max-offset 50000 --output leaks.bin
डिटेक्शन शोर संकेत (उच्च-दर कनेक्शनों)
यह हमला आमतौर पर कई अल्पकालिक अनुरोध उत्पन्न करता है। mongod/mongod.exe की ओर इनबाउंड कनेक्शनों में अचानक वृद्धि पर ध्यान दें। उदाहरण XQL hunt (>500 कनेक्शन/मिनट प्रति रिमोट IP, डिफ़ॉल्ट रूप से RFC1918/loopback/link-local/mcast/broadcast/reserved रेंजेस को छोड़कर):
Cortex XQL high-velocity Mongo connections
```sql // High-velocity inbound connections to mongod/mongod.exe (possible MongoBleed probing)dataset = xdr_data | filter event_type = ENUM.NETWORK | filter lowercase(actor_process_image_name) in (“mongod”, “mongod.exe”) | filter action_network_is_server = true | filter action_remote_ip not in (null, “”) | filter incidr(action_remote_ip, “10.0.0.0/8”) != true and incidr(action_remote_ip, “192.168.0.0/16”) != true and incidr(action_remote_ip, “172.16.0.0/12”) != true and incidr(action_remote_ip, “127.0.0.0/8”) != true and incidr(action_remote_ip, “169.254.0.0/16”) != true and incidr(action_remote_ip, “224.0.0.0/4”) != true and incidr(action_remote_ip, “255.255.255.255/32”) != true and incidr(action_remote_ip, “198.18.0.0/15”) != true | filter action_network_session_duration <= 5000 | bin _time span = 1m | comp count(_time) as Counter by agent_hostname, action_remote_ip, _time | filter Counter >= 500
</details>
## संदर्भ
- [Unit 42 – Threat Brief: MongoDB Vulnerability (CVE-2025-14847)](https://unit42.paloaltonetworks.com/mongobleed-cve-2025-14847/)
- [Tenable – CVE-2025-14847 (MongoBleed): MongoDB Memory Leak Vulnerability Exploited in the Wild](https://www.tenable.com/blog/cve-2025-14847-mongobleed-mongodb-memory-leak-vulnerability-exploited-in-the-wild)
- [MongoDB Security Advisory SERVER-115508](https://jira.mongodb.org/browse/SERVER-115508)
- [Censys – MongoBleed Advisory](https://censys.com/advisory/cve-2025-14847)
- [MongoBleed PoC (joe-desimone/mongobleed)](https://github.com/joe-desimone/mongobleed)
---
> [!TIP]
> AWS हैकिंग सीखें और अभ्यास करें:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> GCP हैकिंग सीखें और अभ्यास करें: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
> Azure हैकिंग सीखें और अभ्यास करें: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://training.hacktricks.xyz/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>HackTricks का समर्थन करें</summary>
>
> - [**सदस्यता योजनाओं**](https://github.com/sponsors/carlospolop) की जांच करें!
> - **हमारे** 💬 [**Discord समूह**](https://discord.gg/hRep4RUj7f) या [**टेलीग्राम समूह**](https://t.me/peass) में शामिल हों या **हमें** **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)** पर फॉलो करें।**
> - **हैकिंग ट्रिक्स साझा करें और** [**HackTricks**](https://github.com/carlospolop/hacktricks) और [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) गिटहब रिपोजिटरी में PRs सबमिट करें।
>
> </details>


