Mitigation Strategy: Enable Authentication
- Description:
- Access MongoDB Configuration File: Locate the MongoDB configuration file, typically named
mongod.conf
. - Edit Configuration: Open the
mongod.conf
file with a text editor. - Enable Authorization: Find or add the
security
section. Within, add or modifyauthorization: enabled
. - Save Configuration: Save changes to
mongod.conf
. - Restart MongoDB Server: Restart the MongoDB server (
mongod
). - Create Administrative User: Connect to MongoDB shell without auth initially. Create an admin user with
userAdminAnyDatabase
role usingdb.createUser()
.
- Access MongoDB Configuration File: Locate the MongoDB configuration file, typically named
- List of Threats Mitigated:
- Unauthorized Access (High Severity): Prevents anonymous database access.
- Data Breach (High Severity): Reduces risk by requiring credentials for access.
- Data Manipulation (High Severity): Prevents unauthorized data modification.
- Impact:
- Unauthorized Access: High Risk Reduction
- Data Breach: High Risk Reduction
- Data Manipulation: High Risk Reduction
- Currently Implemented: Yes, on production and staging MongoDB instances.
- Missing Implementation: N/A - Implemented across all environments.
Mitigation Strategy: Implement Role-Based Access Control (RBAC)
- Description:
- Identify Required Permissions: Determine minimum permissions for each application component/user role.
- Define Custom Roles (If Needed): Create custom roles using
db.createRole()
inmongo
shell if built-in roles are insufficient. Specify precise permissions. - Assign Roles to Users: Create dedicated MongoDB users using
db.createUser()
ordb.updateUser()
. Assign restrictive roles, avoiding overly permissive roles. - Test Permissions: Verify assigned roles ensure users can perform tasks and are restricted from unauthorized actions.
- Regularly Review and Adjust Roles: Periodically review and adjust roles as application evolves, maintaining least privilege.
- List of Threats Mitigated:
- Privilege Escalation (High Severity): Prevents unauthorized access to more data/operations.
- Data Breach (Medium Severity): Limits breach scope if component is compromised.
- Insider Threats (Medium Severity): Reduces damage from malicious insiders.
- Impact:
- Privilege Escalation: High Risk Reduction
- Data Breach: Medium Risk Reduction
- Insider Threats: Medium Risk Reduction
- Currently Implemented: Partially implemented. Basic roles used, custom roles not fully defined.
- Missing Implementation: Refine roles with custom roles for granular control. Implement regular role review process.
Mitigation Strategy: Strong Password Policies and Management
- Description:
- Enforce Password Complexity: Use strong, complex passwords when creating/updating users with
db.createUser()
/db.updateUser()
. - Discourage Default Passwords: Avoid default/guessable passwords. Use strong temporary passwords initially, require change on first login.
- Password Rotation Policy: Implement regular password rotation, especially for admin accounts (e.g., every 90 days).
- Secure Password Storage (Internal Documentation): Document secure practices for managing MongoDB credentials within teams. Avoid plain text storage. Consider password managers/secrets management.
- Enforce Password Complexity: Use strong, complex passwords when creating/updating users with
- List of Threats Mitigated:
- Brute-Force Attacks (High Severity): Harder to guess passwords via brute-force.
- Dictionary Attacks (High Severity): Reduces effectiveness of dictionary attacks.
- Credential Stuffing (Medium Severity): Less likely compromised credentials from elsewhere will work.
- Impact:
- Brute-Force Attacks: High Risk Reduction
- Dictionary Attacks: High Risk Reduction
- Credential Stuffing: Medium Risk Reduction
- Currently Implemented: Partially implemented. Strong passwords encouraged, formal rotation policy missing.
- Missing Implementation: Formalize password policy, implement rotation schedule, consider secrets management integration.
Mitigation Strategy: Bind MongoDB to Specific Interfaces
- Description:
- Access MongoDB Configuration File: Locate
mongod.conf
. - Edit Configuration: Open
mongod.conf
with text editor. - Configure
bindIp
: Find/addnet
section. Locate/addbindIp
setting. - Specify Interface(s): Set
bindIp
to specific interface IPs.- Loopback:
bindIp: 127.0.0.1
(local access only). - Private Network:
bindIp: <private_ip_address>
(private network access).
- Loopback:
- Comment out
bindIpAll
: Remove/comment outbindIpAll: true
if present. - Save Configuration: Save changes to
mongod.conf
. - Restart MongoDB Server: Restart
mongod
service. - Verify Binding: Use
netstat
orss
to confirm binding to specified interfaces.
- Access MongoDB Configuration File: Locate
- List of Threats Mitigated:
- Unauthorized Network Access (High Severity): Prevents external network connections.
- Remote Exploitation (Medium Severity): Reduces attack surface by limiting accessibility.
- Impact:
- Unauthorized Network Access: High Risk Reduction
- Remote Exploitation: Medium Risk Reduction
- Currently Implemented: Yes, on production and staging. Bound to private network interface.
- Missing Implementation: N/A - Implemented across all environments.
Mitigation Strategy: Enable TLS/SSL Encryption for Connections
- Description:
- Obtain TLS/SSL Certificates: Get TLS/SSL certificates (CA-signed recommended for production).
- Configure MongoDB Server for TLS/SSL:
- Access
mongod.conf
: Openmongod.conf
. - Configure TLS Section: Add/modify
net.tls
section. - Specify Certificate/Key Files: Set
net.tls.certificateKeyFile
to certificate and key file paths (PEM). - Enable TLS: Set
net.tls.mode
torequireTLS
(enforce TLS) orpreferTLS
(prefer TLS, allow non-TLS).
- Access
- Configure MongoDB Driver for TLS/SSL:
- Connection String Options: Modify connection string to enable TLS (e.g.,
tls=true
). - Driver-Specific TLS Options: Consult driver docs for TLS configuration details.
- Connection String Options: Modify connection string to enable TLS (e.g.,
- Restart MongoDB Server: Restart
mongod
after server-side TLS config. - Test TLS Connections: Verify application connects via TLS/SSL. Confirm encrypted connections using network tools/driver logs.
- List of Threats Mitigated:
- Eavesdropping (High Severity): Prevents interception of data in transit.
- Man-in-the-Middle Attacks (Medium Severity): Reduces risk of MITM attacks.
- Impact:
- Eavesdropping: High Risk Reduction
- Man-in-the-Middle Attacks: Medium Risk Reduction
- Currently Implemented: Yes, on production and staging. TLS/SSL enabled for all connections.
- Missing Implementation: N/A - Implemented across all environments.
Mitigation Strategy: Resource Limits and Connection Limits
- Description:
- Access MongoDB Configuration File: Locate
mongod.conf
. - Edit Configuration: Open
mongod.conf
. - Set Connection Limits: Configure
net.maxIncomingConnections
to limit concurrent connections. - Set Resource Limits (OS Level - if needed): Use OS-level tools (e.g.,
ulimit
on Linux) to limit resources like memory and file handles for themongod
process. - Save Configuration: Save changes to
mongod.conf
. - Restart MongoDB Server: Restart
mongod
service. - Monitor Resource Usage: Monitor MongoDB resource consumption after implementing limits.
- Access MongoDB Configuration File: Locate
- List of Threats Mitigated:
- Denial of Service (DoS) (Medium Severity): Prevents resource exhaustion DoS attacks.
- Performance Degradation (Medium Severity): Limits impact of resource-intensive operations.
- Impact:
- Denial of Service (DoS): Medium Risk Reduction
- Performance Degradation: Medium Risk Reduction
- Currently Implemented: Partially implemented. Connection limits are set, OS-level resource limits not fully configured.
- Missing Implementation: Review and configure OS-level resource limits for
mongod
process for enhanced resource control.
Mitigation Strategy: Query Optimization and Indexing
- Description:
- Identify Slow Queries: Use MongoDB profiling tools (profiler,
db.setProfilingLevel()
,db.system.profile
) to find slow queries. - Analyze Query Execution Plans: Use
explain()
on queries to analyze execution plans, identify inefficiencies (collection scans). - Create Indexes: Create indexes using
db.collection.createIndex()
for frequently used query fields (filters, sorts, aggregation). - Optimize Query Structure: Refactor slow queries:
- Use covered queries (index contains all data).
- Use
limit()
andskip()
for result set control. - Optimize aggregation pipelines.
- Regular Performance Monitoring: Continuously monitor query performance, address regressions and new slow queries.
- Identify Slow Queries: Use MongoDB profiling tools (profiler,
- List of Threats Mitigated:
- Denial of Service (DoS) (Medium Severity): Prevents slow queries from causing DoS.
- Performance Degradation (Medium Severity): Maintains application performance.
- Impact:
- Denial of Service (DoS): Medium Risk Reduction
- Performance Degradation: High Risk Reduction
- Currently Implemented: Partially implemented. Indexes for common queries exist, ongoing optimization lacking.
- Missing Implementation: Implement regular query performance analysis, optimization process, performance monitoring dashboards/alerts.