Home > Blog

How Researchers Discover MongoDB and Elasticsearch Open Databases


Some time ago among security researchers, it was very fashionable to find improperly configured AWS cloud storages with various kinds of confidential information. At that time, I even published a small note about how Amazon S3 open cloud storage is discovered.

However, time passes and the focus in research has shifted to the search for unsecured and exposed public domain databases. More than half of the known cases of large data leaks over the past year are leaks from open databases.

Today we will try to figure out how such databases are discovered by security researchers...

Required disclaimer: this article does not address and does not raise legal and ethical issues related to the search and identification of publicly available databases. All the information below should be considered solely as educational.

I will not discover America if I say that the main tools for searching open databases are the specialized search engines Shodan.io, BinaryEdge.io and Censys.io. Ill just make a note that these are not free services, and you have to pay for access to the full search results (in the case of Shodan it is $59/month, BinaryEdge - $50/month, and for Censys - $99/month for the minimum basic packages). Free versions of search engines severely limit the number of results in the issuance.

In addition to the classic Google-like search experience using the search function, these search engines provide the ability to connect to them through the API. The lucky owner of a paid subscription will receive an API key. This allows one to significantly facilitate the task of clearing the heap of search rubbish. I have provided a list of useful scripts and search automation programs that use API keys at the end of this article.

Let's take a look at the example of the Shodan search engine: how to find open MongoDB and Elasticsearch databases.

The simplest and most obvious request that begs an attempt is MongoDB:

The simple MongoDB search query

From a screenshot above, we can see that this request returned all indexed MongoDB servers (on default port 27017). Moreover, most of them (the first three in the screenshot ) will be closed databases requiring account credentials. Its not exactly what we are interested in finding. More precisely, it is not interesting at all.

Let's slightly complicate the query using the search filters all:" mongodb server information "all:" metrics ":

The MongoDB search query with filters

The results look much better. All found databases were freely available at the time when the search engine indexed them. It is very likely that we will be able to connect to the specified IP addresses using any manager for MongoDB (for example, NoSQL Manager for MongoDB or Studio 3T for MongoDB).

One can limit the search to any country. Let's say to look for the open MongoDBs in China: (query all:" mongodb server information "all:" metrics "country:" cn ""):

The MongoDB search query for China only

To search for Elasticsearch open databases, it is convenient to use the query port:" 9200 "all:" elastic indices "":

The Elasticsearch search query

To impose more complex filters (restrictions on the size of the database, the date of the server in the index, etc.) on the search results, one can use specialized scripts and programs. To do this, one will need paid access and an API key, as I wrote above.

Here is a small list of links that might be useful:

Author: Ashot Oganesyan, Co-Founder and CTO, DeviceLock Inc.