MongoDB Unauthorized Access Vulnerability
Vulnerability Description
When starting the MongoDB service without adding any parameters, it defaults to having no authentication. The logged in user can perform any operation on the database (high risk operations such as adding, deleting, and modifying) without a password via the default port, and can also remotely access the database.
Environment Setup
Download the MongoDB image from Docker
Vulnerability Reproduction
Execution with CLI
Execution with MSF
Repair Suggestions
(1). Create a New Admin Account to Enable MongoDB Authorization Create a new terminal [parameters can be omitted by default, only add if there are custom parameters, similarly below] mongod --port 27017 --dbpath /data/db1
In another terminal, run the following commands:
The administrator has been created successfully and now has the administrator user adminUser
with the password adminPass
(2). Local Access
(3). Modify the Default Port Change the default MongoDB port (default: TCP 27017) to another port
(4). Disable the HTTP and REST Ports MongoDB has its own HTTP service and supports REST interfaces. These interfaces are turned off by default in version 2.6 and later. MongoDB defaults to listening for web services on the default port, and remote management through the web is generally not needed, so it is recommended to disable it. Modify the configuration file or choose the -nohttpinterface
parameter when starting nohttpinterface = false
(5). Enable Log Audit Functionality The audit function can be used to record all related operations on the database by the user. These records can allow the system administrator to analyze what happened to the database at what time when necessary.
(6). Enable Auth Authentication
Last updated