{"id":23698,"date":"2015-07-28T16:03:17","date_gmt":"2015-07-28T10:33:17","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=23698"},"modified":"2015-12-14T12:13:12","modified_gmt":"2015-12-14T06:43:12","slug":"is-your-mongodb-publicly-accessible","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/is-your-mongodb-publicly-accessible\/","title":{"rendered":"Is your MongoDB publicly accessible?"},"content":{"rendered":"<p>MongoDB is a NoSQL database that delivers a performance oriented, highly available and scalable database system. Recently, a <a title=\"MongoDb Instances Consulting\" href=\"http:\/\/www.tothenew.com\/mean-stack-web-development-consulting\">large number of MongoDB instances<\/a> were found to be publicly accessible over the Internet. A large amount of data was leaked due to the fact that these instances were running an outdated and unpatched version of MongoDB. It is much of a misconfiguration than a vulnerability. This raises a serious question:<strong> &#8220;Is your MongoDB publicly accessible?&#8221;<\/strong><\/p>\n<h3 style=\"text-align: justify;color: #ff9900\"><span style=\"color: #ff9900\">What is this issue about?<\/span><\/h3>\n<p>In 2012, this issue was first reported. It made a database server vulnerable if they were not properly configured. The default installation of MongoDB did not have a \u2018bind_ip 127.0.0.1\u2019 option set in the mongodb.conf file. The best practice proposed was to control the database access to allow access from least possible sources. Although, this issue is being resolved in 2.6.0 version of MongoDb. The configuration file &#8220;mongod.conf&#8221;(which is located in \/etc directory) has the net.bindIp address set to 127.0.0.1.<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-23700\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/Mongo_bind.png\" alt=\"Mongo_bind\" width=\"571\" height=\"365\" \/><\/p>\n<h3 style=\"text-align: justify;color: #ff9900\"><span style=\"color: #ff9900\">Significance of bindIp<\/span><\/h3>\n<p>It is the IP address that MongoDB binds to listen for connections from different applications. We can attach MongoDB to a different interface as well. To bind MongoDB to multiple IP addresses, we have to enter a list of comma separated values.<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\"><span style=\"color: #ff9900\">Origin of vulnerability<\/span><\/h3>\n<p>There are instances, such that the application which uses MongoDB probably has an authentication mechanism, but the database itself doesn&#8217;t have any authentication. Also, it is found in many cases, the database and the application using the database are present on different servers.The system adminstrator may have removed the \u201cbind_ip\u201d flag, in order to allow all network connections to the MongoDB database. This allows access from all untrusted network and if encryption of transmission and access control are not implemented properly, the database becomes publicly exposed.<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\"><span style=\"color: #ff9900\">Possible detection<\/span><\/h3>\n<ul>\n<ul>\n<li>In the mongo.conf file, look for the bindIp address as 0.0.0.0 or any value that might be making it accessible from insecure and not required origins.<\/li>\n<li>We can use Mongo Management Service and set an alert to notify host being exposed to the public internet.<\/li>\n<\/ul>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-23699\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/07\/create_a_new_alert.png\" alt=\"create_a_new_alert\" width=\"2115\" height=\"1421\" \/><br \/>\nFor setting up Mongo Management Service, you can follow a previous <a title=\"blog post\" href=\"http:\/\/www.tothenew.com\/blog\/mongo-monitoring-service-to-ensure-uptime-of-mongodb\/\" target=\"_blank\">blog<\/a> of mine.<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\"><span style=\"color: #ff9900\">How to solve this issue<\/span><\/h3>\n<ul>\n<ul>\n<li>Carefully, set the bind_ip to localhost or 127.0.0.1 (avoid using 0.0.0.0 ).<\/li>\n<li>Try to use the latest version of MongoDB.<\/li>\n<li>Make sure to install all security patches of the version being used.<\/li>\n<li>Keep the MongoDB instance in a private subnet.<\/li>\n<li>Follow the <a title=\"Security Checklist\" href=\"http:\/\/docs.mongodb.org\/manual\/administration\/security-checklist\/\" target=\"_blank\">Security Checklist<\/a> documented by MongoDB.<\/li>\n<\/ul>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB is a NoSQL database that delivers a performance oriented, highly available and scalable database system. Recently, a large number of MongoDB instances were found to be publicly accessible over the Internet. A large amount of data was leaked due to the fact that these instances were running an outdated and unpatched version of MongoDB. [&hellip;]<\/p>\n","protected":false},"author":166,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":17},"categories":[2026,1],"tags":[4843,2027,345,1596,1900,1936,1252],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/23698"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/166"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=23698"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/23698\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=23698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=23698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=23698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}