Common attacks and weaknesses
- Instances without authentication exposing every collection.
- Mass wiping and ransom campaigns on open databases.
- Data leaks indexed by Internet scanners.
MongoDB database server.
The application asks for documents stored as JSON and gets them back over port 27017. Encryption is optional: traffic is only protected if TLS is enabled on the server and the client.
| Service | Port | Transport | Description | Reference | Updated |
|---|---|---|---|---|---|
| mongodb | 27017 | TCP | Mongo database system | - | 2019-02-21 |
| - | 27017 | - | Reserved | - | - |
// source: IANA service name and port number registry
Linux
sudo ss -ltnup 'sport = :27017' # process listening on 27017
sudo lsof -nP -i :27017macOS
sudo lsof -nP -i :27017
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 27017 -State Listen | Select LocalAddress, OwningProcess Get-NetUDPEndpoint -LocalPort 27017 netstat -ano | findstr :27017
From another machine
nmap -p 27017 -sV <host> nc -zv <host> 27017
Block it in the firewall
sudo ufw deny 27017/tcp # Linux (ufw) New-NetFirewallRule -DisplayName "Block 27017" -Direction Inbound -LocalPort 27017 -Protocol TCP -Action Block # Windows
MongoDB database server.
Port 27017 is registered for TCP.
It is rated 9/10 (critical) when exposed to the Internet. Instances without authentication exposing every collection. Enable authorization and bind to private addresses.
On Linux run "ss -ltnup 'sport = :27017'", on macOS "lsof -nP -i :27017", and on Windows "netstat -ano | findstr :27017" to see the local process. From another machine, "nmap -p 27017 <host>" shows whether it is reachable.