Select any two versions of this STIG to compare the individual requirements
Select any old version/release of this STIG to view the previous requirements
Verify that the MongoDB configuration file (default location: /etc/mongod.conf) contains the following: security: authorization: "enabled" If this parameter is not present, this is a finding. If using organization-mandated authorization: Verify that the MongoDB configuration file (default location: /etc/mongod.conf) contains the following to ensure LDAP auth is enabled as well: security: ldap: servers: [list of ldap servers] If this parameter is not present, this is a finding. Refer to Security LDAP configuration documentation for additional details: https://www.mongodb.com/docs/v7.0/core/security-ldap-external/#configuration
Edit the MongoDB configuration file (default location: /etc/mongod.conf) to include the following: security: authorization: "enabled" This will enable SCRAM-SHA-256 authentication (default). Instruction on configuring the default authentication is provided here: https://www.mongodb.com/docs/v7.0/tutorial/enable-authentication/ The high-level steps described by the above will require the following: 1. Start MongoDB without access control. 2. Connect to the instance. 3. Create the user administrator. 4. Restart the MongoDB instance with access control. 5. Connect and authenticate as the user administrator. 6. Create additional users as needed for the deployment. Configuration information for LDAP for MongoDB can be found here: https://www.mongodb.com/docs/v7.0/core/security-ldap-external/ https://www.mongodb.com/docs/v7.0/core/security-ldap-external/#configuration
The MongoDB administrator must ensure that additional application access control is enforced. Review the system documentation to determine the required levels of protection for MongoDB server securables by type of login. Review the permissions actually in place on the server. Run the command to view roles and privileges in a particular <database> : use <database> db.getRoles( { rolesInfo: 1, showPrivileges: true, showBuiltinRoles: true } ) If the permissions do not match the documented requirements, this is a finding.
Use the following statements to add and remove permissions on MongoDB server securables, bringing them into line with the documented requirements: createRole(), updateRole(), dropRole(), grantRolesToUser() MongoDB commands for role management can be found here: https://www.mongodb.com/docs/v7.0/reference/method/js-role-management/
Check the MongoDB configuration file (default location: /etc/mongod.conf) for a key named "auditLog:". Examples shown below: auditLog: destination: file format: BSON path: <mongodb audit log directory>/auditLog.bson filter: '{ atype: { $in: [ "createCollection", "dropCollection" ] } }' -OR- auditLog: destination: syslog If an "auditLog:" key is not present, this is a finding. If the "auditLog:" key is present, ensure the subkey of "destination:" is set to either "file" or "syslog". If not, this is a finding. If the "auditLog:" key is present and contains a subkey of "filter:", ensure the filter is valid. If the filter is invalid, this is a finding. The site auditing policy must be reviewed to determine if the "filter:" being applied meets the site auditing requirements. If not, this is a finding. Check the MongoDB configuration file (default location: /etc/mongod.conf) for the following entry: setParameter: auditAuthorizationSuccess: true If this setParameter entry does not have "auditAuthorizationSuccess: true", this is a finding.
Edit the MongoDB configuration file (default location: /etc/mongod.conf) and add a configured "auditLog" setting: auditLog: destination: file format: BSON path: <mongodb audit log directory>/auditLog.bson -OR- auditLog: destination: syslog Add the following entry to the MongoDB configuration file: setParameter: auditAuthorizationSuccess: true Restart the MongoDB service from the OS. $ sudo systemctl restart mongod Setting of auditAuthorizationSuccess enables auditing of authorization success for the authCheck action. The parameter value must be true to audit read and write operations. However, when auditAuthorizationSuccess is false, auditing has less performance impact because the audit system only logs authorization failures. If the "auditLog" setting was present and contained a "filter:" parameter, ensure the "filter:" expression does not prevent the auditing of events that should be audited. The filter can be modified accordingly to ensure it complies. Alternatively, remove the "filter:" parameter to enable auditing for all events. Refer to the MongoDB documentation for details of audit operations and event configuration: https://www.mongodb.com/docs/v7.0/core/auditing/ https://www.mongodb.com/docs/v7.0/tutorial/configure-audit-filters/
MongoDB must not permit access to its audit logs by unprivileged users. The official installation packages restrict which operating system users and groups may read or modify files. The audit log destination is not configured or created at installation time and must be manually done with appropriate ownership and permissions applied with the MongoDB user and MongoDB group. Check the MongoDB configuration file (default location: /etc/mongod.conf) for a key named "auditLog:" with "destination" set to "file". Example shown below: auditLog: destination: file format: BSON path: <MongoDB auditLog directory>/auditLog.bson If "auditLog" does not exist this is a finding. If the auditLog.destination is "file" in the MongoDB configuration file (default location /etc/mongod.conf) then the following will check ownership and permissions of the MongoDB auditLog directory: Verify User ownership, Group ownership, and permissions on the "<MongoDB auditLog directory>": $ stat <MongoDB auditLog directory> If the User owner is not "mongod", this is a finding. If the Group owner is not "mongod", this is a finding. If the directory is more permissive than "700", this is a finding. To find the auditLog directory name, view and search for the entry in the MongoDB configuration file (default location /etc/mongod.conf) for auditLog.destination. If this parameters value is "file" then use the directory portion of the auditLog.path setting as the MongoDB auditLog directory location. Example: auditLog: destination: file format: BSON path: /var/log/mongodb/audit/auditLog.bson Given the example above, to find the auditLog directory ownership and permissions run the following command: > stat /var/log/mongodb/audit The output will look similar to the following: File: '/var/log/mongodb/audit' Size: 48 Blocks: 0 IO Block: 4096 directory Device: 808h/2056d Inode: 245178 Links: 2 Access: (0700/drwx------) Uid: ( 997/ mongod) Gid: ( 996/ mongod) Context: unconfined_u:object_r:mongod_log_t:s0 Access: 2020-03-16 12:51:16.816000000 -0400 Modify: 2020-03-16 12:50:48.722000000 -0400 Change: 2020-03-16 12:50:48.722000000 -0400 Birth: -
It is recommended to use the official installation packages provided by MongoDB. In the event the software was installed manually and permissions need to be restricted, consider a clean reinstallation. To correct finding where auditLog.destination is set to "file", run these commands: $ chown mongod <MongoDB auditLog directory> $ chgrp mongod <MongoDB auditLog directory> $ chmod 700 <MongoDB auditLog directory> (The path for the MongoDB auditLog directory will vary according to local circumstances. The auditLog directory will be found in the MongoDB configuration file whose default location is /etc/mongod.conf.) To find the auditLog directory name, view and search for the entry in the MongoDB configuration file for the auditLog.path: Example: auditLog: destination: file format: BSON path: /var/log/mongodb/audit/auditLog.bson Given the example above, the "MongoDB auditLog directory" is "/var/log/mongodb/audit".
To ensure audit configurations are protected from unauthorized modification, the default installation of MongoDB restricts permission on the configuration file. Verify User ownership, Group ownership, and permissions on the "<MongoDB configuration file>": (default name and location is /etc/mongod.conf) (The name and location for the MongoDB configuration file will vary according to local circumstances.) Using the default name and location the command would be: $ stat /etc/mongod.conf If the User owner is not "mongod", this is a finding. If the Group owner is not "mongod", this is a finding. If the filename is more permissive than "600", this is a finding. Note that the audit destination cannot be modified at runtime.
Run these commands: "chown mongod <MongoDB configuration file>" "chgrp mongod <MongoDB configuration file>" "chmod 600 <MongoDB configuration file>" (The name and location for the MongoDB configuration file will vary according to local circumstances. The default name and location is /etc/mongod.conf.) Using the default name and location the commands would be: $ chown mongod /etc/mongod.conf $ chgrp mongod /etc/mongod.conf $ chmod 660 /etc/mongod.conf
Review monitoring procedures and implementation evidence to verify monitoring of changes to database software libraries, related applications, and configuration files occurs. Verify the list of files, directories, and database application objects (procedures, functions, and triggers) being monitored is complete. There are many possible options to monitor the database. The most common are making use of a monitoring tool or running a script periodically. If a monitoring tool is actively being used to monitor the database and there is proof of the tool being active, this is not a finding. Where monitoring is implemented by a scheduled or on-demand running of a Bash shell script to check the current SHA-256 checksum of the MongoDB files with the original SHA-256 Checksum after installation and configuration. Run the following shell script "check_mongodb_256sha_hashes.sh" from its containing Linux directory as a system administrator. $ ./check_mongodb_256sha_hashes.sh If the output is not the following, this is a finding: "No changes detected in the monitored files." The shell script file "check_mongodb_2456sha_hashes.sh" is as follows: # filename: check_mongodb_256sha_hashes.sh #!/bin/bash # Function to compute SHA-256 hash of the specified file file_hash() { sha256sum "$1" | awk '{print $1}' } # Function to check the list of files for any changes based on their SHA-256 hashes check_files() { local changed=0 declare -A stored_hashes # Try to load last known hashes if [ -f file_hashes.txt ]; then while IFS=: read -r file hash; do stored_hashes["$file"]=$hash done < file_hashes.txt fi # Check each file's hash against stored hashes for file in "$@"; do if [ -f "$file" ]; then current_hash=$(file_hash "$file") if [[ "${stored_hashes[$file]}" != "$current_hash" ]]; then if [[ -n "${stored_hashes[$file]}" ]]; then echo "Change detected in $file" else echo "New file added or first time hashing: $file" fi changed=1 stored_hashes["$file"]=$current_hash fi else echo "Warning: $file does not exist." fi done # Save the updated hashes > file_hashes.txt for file in "${!stored_hashes[@]}"; do echo "$file:${stored_hashes[$file]}" >> file_hashes.txt done if [ "$changed" -eq 0 ]; then echo "No changes detected in the monitored files." fi } # List of files to monitor files_to_check=( "/etc/mongod.conf" "/usr/bin/mongod" "/usr/bin/mongos" "/usr/bin/mongosh" "/usr/bin/mongocryptd" "/usr/bin/mongodecrypt" "/usr/bin/mongodump" "/usr/bin/mongoexport" "/usr/bin/mongofiles" "/usr/bin/mongoimport" "/usr/bin/mongokerberos" "/usr/bin/mongoldap" "/usr/bin/mongorestore" "/usr/bin/mongostat" "/usr/bin/mongotop" ) # Invoke check_files function with the list of files check_files "${files_to_check[@]}"
Implement procedures to monitor for unauthorized changes to DBMS software libraries, related software application libraries, and configuration files. If a third-party automated tool is not employed, an automated job that reports file information on the directories and files of interest and compares them to the baseline report for the same will meet the requirement. Examples of such products are Puppet, Chef, or Ansible. Alternately, scripts can also be written to inspect the database software libraries, related applications, and configuration files to detect changes and to take appropriate actions or notifications if changes are detected. Use file hashes or checksums for comparisons, as file dates may be manipulated by malicious users. For example, if the running of the monitoring shell script "check_mongodb_256sha_hashes.sh" shown in the "Check" returned the following: $ ./check_mongodb_256sha_hashes.sh "Change detected in /etc/mongod.conf" For each file in which a change has been detected, investigate the possible causes of the change for that file. In this case, inspect the "/etc/mongod.conf" file for changes in its content.
To ensure log, network, security, and other audit configurations are not modifiable by unauthorized operating system users, the default installation of MongoDB restricts permission on the configuration file. Verify User ownership, Group ownership, and permissions on the "<MongoDB configuration file>": (default name and location is /etc/mongod.conf) Using the default name and location the command would be: $ stat /etc/mongod.conf If the User owner is not "mongod", this is a finding. If the Group owner is not "mongod", this is a finding. If the filename is more permissive than "600", this is a finding. Note that the audit destination cannot be modified at runtime.
It is recommended to use the official installation packages provided by MongoDB. In the event the software was installed manually, and permissions need to be restricted, consider a clean reinstallation. Alternatively, run the following commands to properly set permissions on the configuration file: $ chown mongod <MongoDB configuration file> $ chgrp mongod <MongoDB configuration file> $ chmod 600 <<MongoDB configuration file> The name and location for the MongoDB configuration file will vary according to local circumstances. The default name and location is /etc/mongod.conf. Using the default name and location the commands would be: $ chown mongod /etc/mongod.conf $ chgrp mongod /etc/mongod.conf $ chmod 600 /etc/mongod.conf
By default MongoDB, runs using "mongod" user account (both user and group) and uses the following default directories: MongoDB created directories (default): /var/lib/mongo (the data directory) +-- diagnostic.data +-- _tmp +-- journal /var/log/mongodb (the mongod process log directory) +-- audit (the auditLog directory) Standard directories: /bin (the executable directory) /etc (the configuration file directory) Check if any non-MongoDB application, non-MongoDB data, or non-MongoDB directories exists under any of the MongoDB-created directories or subdirectories. If any non-MongoDB application, non-MongoDB data, or non-MongoDB directories exists under the MongoDB-created directories, this is a finding.
The official installation packages from MongoDB segregates MongoDB executable software from MongoDB data directories by default. For any non-MongoDB application found, reinstall that application to use directories that are not under the MongoDB created directories. For any non-MongoDB application that stores data under the MongoDB-created directories, reinstall the application and configure the application to use non-MongoDB-created directories to store its data. For any non-MongoDB data that is found under the MongoDB-created directories that cannot be associated with a MongoDB application, either move or delete that data from the MongoDB-created directories.
For each database in MongoDB, run the following commands: use <database> db.getUsers() Example output: { _id: 'admin.user1', userId: UUID('b78e490a-4661-491f-8197-c3251934e785'), user: 'user1', db: 'admin', roles: [ { role: 'readWrite', db: 'myDatabase' }, { role: 'dbOwner', db: 'myDatabase' }, { role: 'dbOwner', db: 'anotherDatabase' } ] Here, the user named "user1" in the "admin" database has a role of "dbOwner" for the database (db:) "myDatabase" and the database (db:) "anotherDatabase". For users where the role of "dbOwner" is found, verify with the organization or site-specific documentation whether the user is authorized for the "dbOwner" role on the database resources listed. If the user account has the role of "dbOwner" but is not authorized for the role for any database listed in their output, this is a finding.
For each user identified as having a "dbOwner" role on a database they are not authorized for, revoke the "dbOwner" role from that user on that database by running the following commands: use <database> db.revokeRolesFromUser() command https://www.mongodb.com/docs/v7.0/reference/command/revokeRolesFromUser/ Example to revoke "dbOwner" role from "user1" on the "anotherDatabase" in the "admin" database: use admin db.revokeRolesFromUser( "user1", [ { role: "dbOwner", db: "anotherDatabase" } ] )
Run the following command to get the roles from a MongoDB database. For each database in MongoDB: use <database> db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true } ) Run the following command to the roles assigned to users: use admin db.system.users.find() Analyze the output and if any roles or users have unauthorized access, this is a finding. This will vary on an application basis.
Use the following commands to remove unauthorized access to a MongoDB database: db.revokePrivilegesFromRole() db.revokeRolesFromUser() MongoDB commands for role management can be found here: https://www.mongodb.com/docs/v7.0/reference/method/js-role-management/
MongoDB operations permit arbitrary JavaScript expressions to be run directly on the server. If the following parameter is not present or not set as show below in the MongoDB configuration file (default location: /etc/mongod.conf), this is a finding. security: javascriptEnabled: false
Disable the "javascriptEnabled" option. Edit the MongoDB configuration file (default location: /etc/mongod.conf) to include the following: security: javascriptEnabled: false
For each database in the system, run the following command: > use <database> > db.getUsers() Ensure each user identified is a member of an appropriate organization that can access the database. Alternatively, if LDAP/AD is being used for authentication/authorization, the mongoldap tool can be used to verify user account access. If a user is found not be a member of an appropriate organization that can access the database, this is a finding. Verify that the MongoDB configuration file (default location: /etc/mongod.conf) contains the following: security: authorization: "enabled" If this parameter is not present, this is a finding.
For any user not a member of an appropriate organization and has access to a database in the system run the following command: // Change to the appropriate database > use <database> > db.dropUser("<username>", {w: "majority", wtimeout: 5000}) The MongoDB configuration file (default location: /etc/mongod.conf) must contain the following: security: authorization: "enabled" If not, edit the MongoDB configuration file. Add the parameters and stop/start (restart) any mongod or mongos process using this MongoDB configuration file.
MongoDB supports several authentication mechanisms, some of which store credentials on the MongoDB server. If these mechanisms are in use, MongoDB's authSchemaVersion in the admin.system.version collection must be set to "5". 1. Validate that authenticationMechanisms is defined in config file (default location /etc/mongod.conf). The MongoDB Configuration file should contain the similar to the following entry: setParameter: authenticationMechanisms: SCRAM-SHA-256 If the config file does not contain an authenticationMechanisms entry, that is a finding. 2. Validate authSchemaVersion is set to "5". Using the shell, run the following command: > db.getSiblingDB("admin").system.version.find({ "_id" : "authSchema"}, {_id: 0}) It should return: { "currentVersion" : 5 } If currentVersion is less than 5, this is a finding.
1. Define authenticationMechanisms in the MongoDB Configuration file (default location: /etc/mongod.conf), define one of more authenticationMechanisms, from the subset below: SCRAM-SHA-256 MONGODB-X509 GSSAPI PLAIN Example: setParameter: authenticationMechanisms: SCRAM-SHA-256 2. authSchemaVersion should be more than 5. Run the following command: > db.adminCommand({authSchemaUpgrade: 1}) In the unlikely event that an error is encountered, users may safely rerun the authSchemaUpgrade command.
In the MongoDB database configuration file (default location: /etc/mongod.conf), verify the following parameters in the "net.tls" (network TLS) section of the file: net: tls: mode: requireTLS certificateKeyFile: /etc/ssl/server.pem CAFile: /etc/ssl/ca.crt allowInvalidCertificates: false allowConnectionsWithoutCertificates: false If the "net.tls" parameter is not present, this is a finding. If the "net.tls.certificateKeyFile" parameter is not present, this is a finding. If the "net.tls.CAFile" parameter is not present, this is a finding. If the "net.tls.allowInvalidCertificates" parameter is found and set to "true", this is a finding. If the "net.tls.allowConnectionsWithoutCertificates" parameter is found and set to "true", this is a finding.
In the MongoDB database configuration file (default location: /etc/mongod.conf) ensure the following parameters are present in the "net.tls" (network TLS) section of the file and are configured correctly for the site and server: net: tls: mode: requireTLS certificateKeyFile: /etc/ssl/server.pem CAFile: /etc/ssl/ca.crt allowInvalidCertificates: false allowConnectionsWithoutCertificates: false Restart the MongoDB service from the OS. $ sudo systemctl restart mongod More information for configuring TLS/SSL for MongoDB can be found here: https://www.mongodb.com/docs/manual/tutorial/configure-ssl/
In the MongoDB database configuration file (default location: /etc/mongod.conf), review the following parameters: net: tls: mode: requireTLS certificateKeyFile: /etc/ssl/mongodb.pem CAFile: /etc/ssl/mongodbca.pem Verify ownership, group ownership, and permissions for the MongoDB config file (default: /etc/mongod.conf), the certificateKeyFile (default '/etc/ssl/mongodb.pem'), and the CAFile (default '/etc/ssl/mongodbca.pem'). For each file: Run following command and review its output: ls -al <filepath> example output: -rw------- 1 mongodb mongodb 566 Apr 26 20:20 <filepath> If the user owner is not "mongodb", this is a finding. If the group owner is not "mongodb", this is a finding. If the file is more permissive than "600", this is a finding.
Run these commands: chown mongodb:mongodb /etc/ssl/mongodb.pem chmod 600 /etc/ssl/mongodb.pem chown mongodb:mongodb /etc/ssl/mongodbca.pem chmod 600 /etc/ssl/mongodbca.pem
Note: This is not applicable if using LDAP for authentication. Each unique x.509 client certificate corresponds to a single MongoDB user; meaning a single client certificate cannot authenticate more than one MongoDB user. Login to MongoDB and run the following command: > db.runCommand( {connectionStatus: 1} ); Example output being: > db.runCommand({connectionStatus:1}).authInfo { "authenticatedUsers" : [ { "user" : "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry", "db" : "mydb1" } ], "authenticatedUserRoles" : [ { "role" : "dbOwner", "db" : "mydb1" } ] } If the authenticated MongoDB user displayed does not have a user value equal to the x.509 cert's Subject Name, this is a finding.
Add x.509 Certificate subject as an authorized user. To authenticate with a client certificate, first add the value of the subject from the client certificate as a MongoDB user. Each unique x.509 client certificate corresponds to a single MongoDB user; meaning a single client certificate cannot authenticate more than one MongoDB user. Note: The RDNs in the subject string must be compatible with the RFC2253 standard. Retrieve the RFC2253 formatted subject from the client certificate with the following command: $ openssl x509 -in <pathToClient PEM> -inform PEM -subject -nameopt RFC2253 The command returns the subject string as well as certificate: subject= CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry -----BEGIN CERTIFICATE----- # ... -----END CERTIFICATE----- Add the RFC2253 compliant value of the subject as a user. Omit spaces as needed. For example, in the mongo shell, to add the user with both the "readWrite" role in the test database and the "userAdminAnyDatabase" role which is defined only in the admin database: > db.getSiblingDB("$external").runCommand( { createUser: "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry", roles: [ { role: 'readWrite', db: 'test' }, { role: 'userAdminAnyDatabase', db: 'admin' } ], writeConcern: { w: "majority" , wtimeout: 5000 } } ) In the above example, to add the user with the "readWrite" role in the test database, the role specification document specified "test" in the "db" field. To add "userAdminAnyDatabase" role for the user, the above example specified "admin" in the "db" field. Note: Some roles are defined only in the admin database, including: clusterAdmin, readAnyDatabase, readWriteAnyDatabase, dbAdminAnyDatabase, and userAdminAnyDatabase. To add a user with these roles, specify "admin" in the "db" field. Refer to Manage Users and Roles for details on adding a user with roles. To remove a user that is not authorized run the following command: > use $external > db.dropUser("<RDN of user>")
Restrict the environment to tools which meet this requirement. For the MongoDB command-line tools mongo shell "mongosh", "mongodump", "mongorestore", "mongoimport", "mongoexport", which cannot be configured not to obfuscate a plain-text password, and any other essential tool with the same limitation, verify that the system documentation explains the need for the tool, who uses it, and any relevant mitigations and that authorizing official (AO) approval has been obtained. If it is not documented, this is a finding. Request evidence that all users of these MongoDB command-line tools are trained in the use of the "-p" or "--password" option plain-text password option and how to keep the password protected from unauthorized viewing/capture and that they adhere to this practice. If evidence of training does not exist, this is a finding.
For the mongo shell "mongosh", "mongodump", "mongorestore", "mongoimport", "mongoexport", which can accept a plain-text password, and any other essential tool with the same limitation: - Document the need for it, who uses it, and any relevant mitigations, and obtain AO approval. - Train all users of the tool in the nature of using the plain-text password option and in how to keep the password protected from unauthorized viewing/capture and document they have been trained. To view the acceptable command line flags, execute the commands with --help for the various parameters that can be used. For example: mongosh --help Example output: mongosh Authentication Options: -u, --username [arg] Username for authentication -p, --password [arg] Password for authentication
Verify that FIPSMode: true is configured in the mongod.conf file (default location: /etc/mongod.conf) as shown below: net: tls: FIPSMode: true If net.tls.FIPSMode is not present or not configured as shown above in the MongoDB configuration file, this is a finding. Alternatively, run the following command from the MongoDB shell: > db.getSiblingDB("admin").runCommand({getCmdLineOpts: 1}).parsed.net.tls.FIPSMode If the server is running with FIPS mode, this command will return "true". Any other output or no output is a finding. Verify that FIPS has been enabled at the OS level. Refer to the OS specific documentation on how to verify.
Enable FIPS mode for MongoDB Enterprise. Edit the MongoDB database configuration file (default location: /etc/mongod.conf) to contain the following parameter setting: net: tls: FIPSMode: true Restart the MongoDB service from the OS. $ sudo systemctl restart mongod For the operating system finding, refer to the appropriate operating system documentation for the procedure to install, configure, and test FIPS mode.
MongoDB grants access to data and commands through role-based authorization and provides built-in roles that provide the different levels of access commonly needed in a database system. You can additionally create user-defined roles. Check a user's role to ensure correct privileges for the function: Prerequisite: To view a user's roles, users must have the "viewUser" privilege. Connect to MongoDB. For each database in the system, identify the user's roles for the database: use <database> db.getUser("[username]") The server will return a document with the user's roles. View a role's privileges: Prerequisite: To view a user's roles, users must have the "viewUser" privilege. For each database, identify the privileges granted by a role: use <database> db.getRole( "read", { showPrivileges: true } ) The server will return a document with the "privileges" and "inheritedPrivileges" arrays. The "privileges returned document lists the privileges directly specified by the role and excludes those privileges inherited from other roles. The "inheritedPrivileges" returned document lists all privileges granted by this role, both directly specified and inherited. If the role does not inherit from other roles, the two fields are the same. If a user has a role with inappropriate privileges, this is a finding.
Administrators using MongoDB should document the appropriate privileges for various roles appropriate to the application. Prerequisite: To view a user's roles, must have the "viewUser" privilege. Connect to MongoDB. For each database, identify the user's roles for the database. use <database> db.getUser("[username]") The server will return a document with the user's roles. To revoke a user's role from a database use the db.revokeRolesFromUser() method. To grant a role to a user use the db.grantRolesToUser() method.
MongoDB grants access to data and commands through role-based authorization and provides built-in roles that provide the different levels of access commonly needed in a database system. Additionally, user-defined roles can be created. Check a user's role to ensure correct privileges for the function: Run the following command to get a list of all the databases in the system: > show dbs For each database in the system, identify the user's roles for the database: > use <database> > db.getUsers() The server will return a document with the all users in the data and their associated roles. View a role's privileges: For each database, identify the privileges granted by a role: > use <database> > db.getRole( "<role name>", { showPrivileges: true } ) The server will return a document with the "privileges" and "inheritedPrivileges" arrays. The "privileges returned document lists the privileges directly specified by the role and excludes those privileges inherited from other roles. The "inheritedPrivileges" returned document lists all privileges granted by this role, both directly specified and inherited. If the role does not inherit from other roles, the two fields are the same. If a user has a role with inappropriate privileges, this is a finding.
Administrators using MongoDB should document the appropriate privileges for various roles appropriate to the application. For each database, identify the user's roles for the database. > use <database> > db.getUser("<username>") The server will return a document with the user's roles. To revoke a user's role from a database use the following: > db.revokeRolesFromUser( "<username>", [ <roles> ], { <writeConcern> } ) To grant a role to a user use the following: > db.grantRolesToUser( "<username>", [ <roles> ], { <writeConcern> } )
Check the MongoDB configuration file (default location: /etc/mongod.conf). The following option must be present ( "net.tls.mode") and set to "requireTLS": net: tls: mode: requireTLS If this is not found in the MongoDB configuration file, this is a finding.
Edit the MongoDB configuration file to ensure the "net.tls.mode" option is included and set to the value "requireTLS" as shown below: net: tls: mode: requireTLS Restart the MongoDB service from the OS $ sudo systemctl restart mongod Further documentation is here: https://www.mongodb.com/docs/v7.0/tutorial/configure-ssl/
To provide integrity and confidentiality for data at rest, MongoDB must be configured to use the Encrypted Storage Engine. Run the following command to verify whether or not the Encrypted Storage Engine is enabled: > db.serverStatus().encryptionAtRest.encryptionEnabled Any output other than "true" is a finding. Validate whether the Encrypted Storage Engine is running with an AEAD block cipher, which provides integrity, by running the following command: > db.serverStatus().encryptionAtRest.encryptionCipherMode Any response other than "AES256-GCM" is a finding. Validate that the system is configured to use KMIP to obtain a master encryption key, rather than storing the master key on the local filesystem. Run: > db.serverStatus().encryptionAtRest.encryptionKeyId If the response is "local" or no response, this is a finding.
Enable the Encrypted Storage Engine with KMIP as the key storage mechanism and AES256-GCM as the encryption mode. Consult MongoDB documentation for encryption setup instruction here: https://www.mongodb.com/docs/v7.0/tutorial/configure-encryption/
Review the procedures for the refreshing of development/test data from production. Review any scripts or code that exists for the movement of production data to development/test systems, or to any other location or for any other purpose. Verify that copies of production data are not left in unprotected locations. If the code that exists for data movement does not comply with the organization-defined data transfer policy and/or fails to remove any copies of production data from unprotected locations, this is a finding.
Modify any code used for moving data from production to development/test systems to comply with the organization-defined data transfer policy, and to ensure copies of production data are not left in unsecured locations.
By default, the MongoDB official installation packages restrict user and group ownership and read/write permissions on the underlying data files and critical configuration files from other operating system users. In addition, process and memory isolation is used by default. System administrators should also consider if whole database encryption would be an effective control on an application basis. Run the following commands to verify proper permissions for the following database files or directories: $ stat /etc/mongod.conf If the owner and group are not both "mongod", this is a finding. If the file permissions are more permissive than "600", this is a finding. $ stat /var/lib/mongo If the owner and group are not both "mongod", this is a finding. If the file permissions are more permissive than "755", this is a finding. $ ls -l /var/lib/mongo If the owner and group of any file or sub-directory is not "mongod", this is a finding. If the permission of any file in the main directory (/var/lib/mongo) or sub-directory of (/var/lib/mongo) is more permissive than "600", this is a finding. If the permission of any sub-directory of (/var/lib/mongo) is more permissive than "700", this is a finding.
Correct the permission to the files and/or directories that are in violation. MongoDB Configuration file (default location /etc/mongod.conf): $ chown mongod:mongod /etc/mongod.conf $ chmod 600 /etc/mongod.conf MongoDB datafiles and directories (default location '/var/lib/mongo'): $ chown -R mongod:mongod /var/lib/mongo $ chmod 755 /var/lib/mongo $ find /var/lib/mongo/* -type f | xargs chmod 600 $ find /var/lib/mongo/* -type d | xargs chmod 700
As a client program assembles a query in MongoDB, it builds a BSON object, not a string. Thus traditional SQL injection attacks are not a problem. However, MongoDB operations permit arbitrary JavaScript expressions to be run directly on the server. To check, run the following command from the MongoDB shell: > db.col.find({ $where: "return true;"} ) If the response does not return an error, this is a finding. If javascript has been correctly disabled, the correct error would indicate that the javascript global engine has been disabled. For example: MongoServerError: no globalScriptEngine in $where parsing}
Disable the javascriptEnabled option in the MongoDB configuration file (default location: /etc/mongod.conf) to include the following: security: javascriptEnabled: false If document validation is needed, it should be configured according to the documentation page at: https://www.mongodb.com/docs/v7.0/core/schema-validation/.
MongoDB operations permit arbitrary JavaScript expressions to be run directly on the server. If the following parameter is not present or not set as show below in the MongoDB configuration file (default location: /etc/mongod.conf), this is a finding. security: javascriptEnabled: false
Disable the "javascriptEnabled" option. Edit the MongoDB configuration file (default location: /etc/mongod.conf) to include the following: security: javascriptEnabled: false
Check custom application code to verify that error messages do not contain information beyond what is needed for troubleshooting the issue. If custom application error messages contain PII data, sensitive business data, or information useful for identifying the host system or database structure, this is a finding. For example, when attempting to log in using the MongoDB shell with incorrect client credentials, the user will receive a generic error message that the authentication failed regardless of whether the user exists. If a user is attempting to perform an operation using the MongoDB shell for which they do not have privileges, MongoDB will return a generic error message that the operation is not authorized. To prevent too much information being displayed in the MongoDB logfiles, run the following command: > db.getSiblingDB("admin").runCommand({getCmdLineOpts: 1}).parsed.security.redactClientLogData If the command does not return true, this is a finding.
Configure custom application code so as not to divulge sensitive information or information useful for system identification in custom application error messages. To configure MongoDB to redact client information from its log file, do the following: Edit the MongoDB Configuration file (default location: /etc/mongod.conf) Add the following option to the security section: security: redactClientLogData: true Restart the MongoDB server from the operating system: $ sudo systemctl restart mongod
A mongod or mongos running with "security.redactClientLogData:true" redacts any message accompanying a given log event before logging. This prevents the mongod or mongos from writing potentially sensitive data stored on the database to the diagnostic log. Metadata such as error or operation codes, line numbers, and source file names are still visible in the logs. To prevent too much information being displayed in the MongoDB logfiles, run the following command: > db.getSiblingDB("admin").runCommand({getCmdLineOpts: 1}).parsed.security.redactClientLogData If the command does not return true, this is a finding. The MongoDB command "getLog" will return data from the log file, which requires the "getLog" action type on the cluster resource. Ensure that application users are not authorized to execute this command. To validate this run the following command on the name of the application user to view actions its permitted to perform on the cluster resource: > db.runCommand({usersInfo: "<USER NAME>", showPrivileges: 1}).users[0].inheritedPrivileges.filter(privilege => privilege.resource.cluster) If "getLog" appears in the list of actions, this is a finding.
Edit the MongoDB configuration file (default location: /etc/mongod.conf) and add the following parameter "redactClientLogData" in the security section of that file. Example: security: redactClientLogData: true Restart the MongoDB service from the OS. $ sudo systemctl restart mongod Identify and remove all unnecessary roles and privileges from application users.
Review system documentation to obtain the organization's definition of circumstances requiring automatic session termination. If the documentation explicitly states that such termination is not required or is prohibited, this is not a finding. If the system owner, data owner, or organization requires additional assurance, this is a finding.
Determine the situations when a user-initiated database session must be terminated. Note: The user running the commands shown below must have privileges with listSessions, killAnySession and impersonate action on the cluster. In the MongoDB shell, as an authenticated user, run the following command to list all user sessions: > use config > db.system.sessions.aggregate( [ { $listSessions: { allUsers: true } } Reference: https://docs.mongodb.com/v7.0/reference/operator/aggregation/listSessions/ Example output: { "_id" : { "id" : UUID("b3b50641-54c6-4d6d-a96e-a2239fadce3c"), "uid" : BinData(0,"Y5mrDaxi8gv8RmdTsQ+1j7fmkr7JUsabhNmXAheU0fg=") }, "lastUse" : ISODate("2021-09-23T23:34:43.951Z"), "user" : { "name" : "jsmith@admin" } } From the output identify the names of users whose sessions should be terminated. Using the user for each session to be terminated, run the following command (still in MongoDB shell). > db.runCommand( { killAllSessionsByPattern: [ { users: [ { user: <user>, db: <dbname> }, ... ] }] } ) Example to terminate user "jsmith@admin" sessions from example output: > db.runCommand( { killAllSessionsByPattern: [ { users: [ { user: "jsmith", db: "admin" } ] }]} ) To terminate all user sessions running on the database, run the following command (still in MongoDB shell): > db.runCommand( { killAllSessionsByPattern: [ ] } ) Reference: https://docs.mongodb.com/v7.0/reference/command/killAllSessionsByPattern/
If security labeling is not required, this is not a finding. If security labeling is required then there must be an organizational or site specific documentation on what the security labeling policy is and guidance on how and where to apply it. Review the organization- or site-specific security labeling documentation to understand how documents in specific MongoDB collection(s) must be marked. This marking process should be applied as data is entered into the database. Upon review of the security labeling documents, the following checks will be required. 1. Check if the role "SLTagViewer" exists. If this role does not exist, this is a finding. Note: The role name "SLTagViewer" is a user-defined (custom) role and is organizational or site specific. The role name of "SLTagViewer" is used here as an example. Run the following commands: > use admin > db.getRole( "SLTagViewer", { showPrivileges: true } ) If the results returned from this command is "null", this is a finding. 2. Check that data is appropriately marked in the specific MongoDB collection(s) that require security labeling. This check will be specific to the security labeling policy and guidance. Log in to MongoDB with a user that has a Security Label Tag Viewer role ("SLTagViewer", which is a role that has been created and has access to read/view those database/collections that require security labels). Review the data in the MongoDB collections requiring security labels to ensure that the data is appropriately marked according to the security labeling documentation. For example, if documents in a MongoDB collection need to be marked as "TS", "S", "C" or "U" (or combination of) at the root level of the document and at each field level of the document, then the security labeling policy and guidance would indicate a document might look like the following and this would not be a finding ("sl" is the security label): { "_id": 1, "sl": [["TS"], ["S"]], "field1" : { "sl" : [ ["S"] ], "data" : "field1 value" }, "field2" : { "sl" : [ ["TS"] ], "data" : "field2 value" }, "field3" : { "sl" : [ ["S"] ], "data" : "field3 value" } } The following document would be a finding because at the field level, field2 is missing its security label of "sl": { "_id": 1, "sl": [["TS"], ["S"]], "field1" : { "sl" : [ ["S"] ], "data" : "field1 value" }, "field2" : { "data" : "field2 value" }, "field3" : { "sl" : [ ["S"] ], "data" : "field3 value" } } 3. Check that queries against that data in those collections use an appropriately constructed MongoDB $redact operation as part of the query pipeline to ensure that only the data appropriate for the query (that meets the security label requirements) is returned. Ensure that any query that targets the databases/collections that have security labeling have the appropriate MongoDB $redact operation applied. This is done through trusted middleware. This trusted middleware configuration is purpose built (custom) code and integrations and is organizational or site specific. Information on the basics of this can be found here: https://www.mongodb.com/docs/v7.0/reference/operator/aggregation/redact/ Any queries that target a MongoDB database/collection that has security labels and pass through the trusted middleware and does not have an appropriately constructed $redact operator that is part of the query aggregation pipeline is a finding. The following is an example of the $redact operator for the example document: > db.security_collection.aggregate( [{ $redact: { $cond: [{ $anyElementTrue: { $map: { input: "$sl", as: "setNeeded", in: { $setIsSubset: ["$$setNeeded", ["S"]] } } } }, "$$DESCEND", "$$PRUNE"] } } ] )
To implement security labeling, ensure the following: 1. Organizational or site specific documentation and guidance is available or developed. 2. Ensure security labels are applied to MongoDB collection(s) requiring them in accordance with the organization or site specific documentation. 3. Create a Security Label Tag Viewer role ("SLTagViewer") with "find" privileges on the specific database and collection that requires security labeling. In the example below, there are three databases and collections in those databases where security labels are required: > use admin > db.createRole( { role: "SLTagViewer", privileges: [ { resource: { db: "db1", collection: "coll1" }, actions: [ "find" ] }, { resource: { db: "db1", collection: "coll2" }, actions: [ "find" ] }, { resource: { db: "db1", collection: "coll3" }, actions: [ "find" ] }, { resource: { db: "db2", collection: "coll1" }, actions: [ "find" ] }, { resource: { db: "db2", collection: "coll5" }, actions: [ "find" ] }, { resource: { db: "db2", collection: "coll9" }, actions: [ "find" ] }, { resource: { db: "db3", collection: "coll81" }, actions: [ "find" ] } ], roles: [ ] }, { w: "majority" , wtimeout: 5000 } ) 4. Ensure that any query that targets the databases/collections that have security labeling have the appropriate MongoDB $redact operation applied. The $redact operator is applied through trusted middleware. This trusted middleware configuration is purpose built (custom) code and integrations and is organizational or site specific. Information on the basics of how this is constructed can be found here: https://www.mongodb.com/docs/v7.0/reference/operator/aggregation/redact/
Review the MongoDB Configuration file (default location: /etc/mongod.conf). If the file does not contain the following entry, this is a finding: security: authorization: enabled
Enable authentication for MongoDB by following the instructions here: https://www.mongodb.com/docs/v7.0/tutorial/enable-authentication/ Create an administrative user in MongoDB: use admin db.createUser( { user: "UserAdmin", pwd: passwordPrompt(), // or cleartext password roles: [ { role: "userAdminAnyDatabase", db: "admin" }, { role: "readWriteAnyDatabase", db: "admin" } ] } ) Enable authorization by adding the following entry to the MongoDB configuration file: security: authorization: enabled Restart the MongoDB service from the OS. $ sudo systemctl restart mongod The "UserAdmin" user created above can use the "createUser" and "createRole" MongoDB commands to add the required users and roles per organizational- or site-specific documentation. https://www.mongodb.com/docs/v7.0/reference/command/createUser/ https://www.mongodb.com/docs/v7.0/reference/command/createRole/
A organizational or site-specific document should exist and be reviewed to determine what built-in MongoDB roles and associated privileges may be considered authorized and what users are administrative users. For each database, run the following commands in MongoDB as an administrative user to determine what users and roles they are assigned: > use <database> > db.getUsers() For any nonadministrative user in a database, check if any roles are not compliant with the site-specific documentation for users. If any nonadministrative user in a database has a noncompliant role, this is a finding.
Ensure users are assigned only to authorized roles. To revoke a role from a user in a database, run the following commands: > use <database> > db.revokeRolesFromUser( "<username>", [ <roles> ], { <writeConcern> } ) https://www.mongodb.com/docs/v7.0/reference/method/db.revokeRolesFromUser/
Investigate whether there have been any incidents where the MongoDB server ran out of audit log space since the last time the space was allocated or other corrective measures were taken. If these conditions exist, this is a finding.
To specify auditLog, or a centralized system log (which is recommended), configure these in the mongod.conf configuration file: auditLog: destination: syslog Allocate sufficient space to the storage volume hosting the file identified in the MongoDB configuration "auditLog.path" to support audit file peak demand.
Verify that auditing is enabled in the mongodb configuration file (default location: /etc/mongod.conf) and view the "auditlog.path" to identify the storage volume. Verify that OS or other organization approved third-party monitoring software is installed. Verify that the required alert in the monitoring software to send an alert where storage volume holding the auditLog file utilization reaches 75 percent. If appropriate support staff are not notified immediately upon storage volume utilization reaching 75 percent, this is a finding.
View the mongodb configuration file (default location: /etc/mongod.conf) and view the "auditlog.path" to identify the storage volume. Install OS or other organization approved third-party monitoring software. Configure the required alert in the monitoring software to send an alert where storage volume holding the auditLog file utilization reaches 75 percent.
MongoDB database halts if it cannot write audit events to the audit log due to insufficient storage on the volume where the audit log is being written. Check the operating system or third-party logging software settings to determine whether a real-time alert will be sent to the appropriate personnel when the volume hosting the MongoDB audit log is nearing capacity. If real-time alerts are not set up to monitor the remaining storage capacity of the volume hosting the MongoDB audit logs, this is a finding.
Setup and configure real-time alerts by configuring OS or third-party software monitoring tools to notify appropriate personnel when the storage allocation on the volume hosting the MongoDB audit logs usage reaches a predefined site specific threshold.
If MongoDB supports only software development, experimentation and/or developer-level testing (that is, excluding production systems, integration testing, stress testing, and user acceptance testing), this is not a finding. MongoDB can control nonadministrative users' ability to create, alter, or replace logic modules by defining specific roles and permissions. While MongoDB does not directly support stored procedures, functions, triggers, and views in the way relational databases do, similar functionalities can be implemented using various features. A organizational- or site-specific document should exist and be reviewed to determine what built-in MongoDB roles and associated privileges may be considered authorized and what users are administrative users. For each database, run the following commands in MongoDB as an administrative user to determine what users and roles they are assigned: > use <database> > db.getUsers() For any nonadministrative user in a database, check if any roles are not compliant with the site-specific documentation for users. If any user in any database is found to have a role that is not allowed, this is a finding. MongoDB allows users to store JavaScript functions on the server. Javascript should be disabled for all users. Review the Mongodb configuration file (default location: /etc/mongod.conf) and ensure the following is set to disable JavaScript: security: javascriptEnabled: false If this is not set in the MongoDB configuration file, this is a finding.
Revoke unapproved roles from nonadministrative users as per the site-specific document by executing db.revokeRolesFromUser for each user and database: > use <database> > db.revokeRolesFromUser( "<username>", [ <roles> ], { <writeConcern> } ) https://www.mongodb.com/docs/v7.0/reference/method/db.revokeRolesFromUser/ Edit the MongoDB configuration file (default location: /etc/mongod.conf) to include the following: security: javascriptEnabled: false
To verify that authentication and Role-Based Access Controls (RBAC) is configured correctly and restrictions are being enforced, create a test user and a custom role, and then confirm expected operations: Once authenticated as a DBA administrator, use db.createUser() to create an additional user. The following operation adds a user "myTester" to the test database who has read-only access on the test database: > use test > db.createUser( { user: "myTester", pwd: <password>, roles: [ { role: "read", db: "test" } ] } ) Log out and then back in as the "test" database user. Issue the following to attempt to write to the test database with a read-only privilege: > use test > db.testCollection.insertOne( { x: 1 } ) This operation will fail with an error similar to the following: "MongoServerError":"not authorized on test to execute command"{ "insert":"testCollection", "documents":[ { "x":1, "_id":"ObjectId(""6500b96d1114d3a3ba7dda39"")" } ], "ordered":true, "lsid":{ "id":"UUID(""6cb3b9af-1ddc-446c-b0e0-bc9bf22807fa"")" }, "$db":"test" } If the operation does not fail, this is a finding.
Locate a machine that can access the MongoDB Security Checklist here: https://www.mongodb.com/docs/v7.0/administration/security-checklist/ Review the MongoDB Security Checklist. Follow the procedures to enable MongoDB access control here: https://www.mongodb.com/docs/v7.0/tutorial/enable-authentication/#enable-access-control
Review the network functions, ports, protocols, and services supported by the DBMS. If any protocol is prohibited by the PPSM guidance and is enabled, this is a finding.
Deploy a DBMS capable of disabling a network function, port, protocol, or service prohibited by the PPSM guidance. Disable each prohibited network function, port, protocol, or service. More information for MongoDB port management can be found at the following link: https://www.mongodb.com/docs/manual/reference/default-mongodb-port/
If MongoDB is deployed in an unclassified environment, this is not a finding. Run the following command as an administrative user: > db.getSiblingDB("admin").runCommand({getCmdLineOpts: 1}).parsed.net.tls.FIPSMode If the output is not "true", this is a finding.
Enable FIPS mode for MongoDB Enterprise. Edit the MongoDB database configuration file (default location: /etc/mongod.conf) to contain the following parameter setting: net: tls: FIPSMode: true Stop/start (restart) the mongod or mongos instance using this configuration and run the following command to verify the output is "true": > db.getSiblingDB("admin").runCommand({getCmdLineOpts: 1}).parsed.net.tls.FIPSMode The output of this command must be "true". Alternatively, run the following command to search the mongod logfile for "FIPS mode 140-2 activated": $ grep "FIPS 140-2 mode activated" /var/log/mongodb/mongod.log There should be a line similar to what is shown below: {"t":{"$date":"2024-05-21T19:17:49.262+00:00"},"s":"I", "c":"NETWORK", "id":23172, "ctx":"main","msg":"FIPS 140-2 mode activated"}
To run MongoDB in TLS mode, obtain a valid certificate singed by a single CA. Before starting the MongoDB database in TLS mode, verify the certificate used is issued by a valid DOD CA (openssl x509 -in <path_to_certificate_pem_file> -text | grep -i "issuer"). The certificates (pem files) used by MongoDB will be in the MongoDB configuration file net.tls section as shown below (default location: /etc/mongod.conf). Each of these must be inspected, when present, to make sure they comply with a DOD Issuer for the certificate. net: tls: CAFile: <PEM file> certificateKeyFile: <PEM file> clusterFile: <PEM file> clusterCAFile: <PEM file> CRLFile: <PEM file> When using MongoDBs native encryption at rest, the following must also be inspected in the security.kmip section of the MongoDB configuration file: security: kmip: clientCertificateFile: <PEM file> serverCAFile: <PEM file> net.tls.CAFile The .pem file that contains the root certificate chain from the CA. Specify the file name of the .pem file using relative or absolute paths. net.tls.certificateKeyFile The .pem file that contains both the TLS certificate and key. net.tls.clusterFile The .pem file that contains the x.509 certificate-key file for membership authentication for the cluster or replica set. If there is any issuer present in the certificates being used that is not a DOD approved certificate authority, this is a finding. net.tls.clusterCAFile The .pem file that contains the root certificate chain from the CA used to validate the certificate presented by a client establishing a connection. Specify the file name of the .pem file using relative or absolute paths. net.tls.clusterCAFile requires that net.tls.CAFile is set. net.tls.CRLFile The .pem file that contains the Certificate Revocation List. Specify the file name of the .pem file using relative or absolute paths. security.kmip.clientCertificateFile Path to the .pem file used to authenticate MongoDB to the KMIP server. The specified .pem file must contain both the TLS/SSL certificate and key. security.kmip.serverCAFile Path to CA File. Used for validating secure client connection to KMIP server.
Remove any certificate referenced that was not issued by an approved DOD certificate authority. Contact the organization's certificate issuer and request a new certificate that is issued by a valid DOD certificate authorities.
Review the documentation or specification for the organization-defined information. If any data is PII, classified, or is deemed by the organization the need to be encrypted at rest, verify the method of encryption is documented. If no documented mechanism is being used encrypt data at rest such as hardware encryption, volume encryption, filesystem encryption or the use of third-party products to enable encryption at rest, this is a finding. If the documented method to encrypt MongoDB data at rest is the native MongoDB encryption at rest, verify the MongoDB configuration file (default location: /etc/mongod.conf) contains the following options: security: kmip: keyIdentifier: <string> rotateMasterKey: <boolean> serverName: <string> port: <string> clientCertificateFile: <string> clientCertificatePassword: <string> clientCertificateSelector: <string> serverCAFile: <string> connectRetries: <int> connectTimeoutMS: <int> activateKeys: <boolean> keyStatePollingSeconds: <int> If these above options are not configured in the MongoDB security.kmip section in the MongoDB configuration file, this is a finding.
Configure encryption at rest through hardware encryption, volume encryption, filesystem encryption, or third-party products if not using MongoDBs native encryption at rest. When using MongoDBs native encryption at rest, configure MongoDB to use the Encrypted Storage Engine and a KMIP appliance as documented here: https://www.mongodb.com/docs/v7.0/core/security-encryption-at-rest/ https://www.mongodb.com/docs/v7.0/tutorial/configure-encryption/
If the data owner does not have a strict requirement for ensuring data integrity and confidentiality is maintained at every step of the data transfer and handling process, this is not a finding. If such a requirement is present, inspect the MongoDB configuration file (default location: /etc/mongod.conf) for the following entries: net: tls: mode: requireTLS certificateKeyFile: <PEM File> CAFile: <PEM File> allowInvalidCertificates: false allowConnectionsWithoutCertificates: false FIPSMode: true If net.tls.mode is not set to "requireTLS", this is a finding.
Stop the MongoDB instance if it is running. Obtain a certificate from a valid DOD certificate authority to be used for encrypted data transmission. Modify the MongoDB configuration file to include the following TLS configuration options: net: tls: mode: requireTLS certificateKeyFile: <PEM File> CAFile: <PEM File> allowInvalidCertificates: false allowConnectionsWithoutCertificates: false FIPSMode: true Set "net.tls.mode" to the "requireTLS". <PEM File> is the fullpathnames to the certificates used for the option. Start/stop (restart) all mongod or mongos instances using the MongoDB configuration file (default location: /etc/mongod.conf).
If the data owner does not have a strict requirement for ensuring data integrity and confidentiality is maintained at every step of the data transfer and handling process, this is not a finding. If such a requirement is present, inspect the MongoDB configuration file (default location: /etc/mongod.conf) for the following entries: net: tls: mode: requireTLS certificateKeyFile: <PEM File> CAFile: <PEM File> allowInvalidCertificates: false allowConnectionsWithoutCertificates: false FIPSMode: true If net.tls.mode is not set to "requireTLS", this is a finding.
Stop the MongoDB instance if it is running. Obtain a certificate from a valid DOD certificate authority to be used for encrypted data reception. Modify the MongoDB configuration file to include the following TLS configuration options: net: tls: mode: requireTLS certificateKeyFile: <PEM File> CAFile: <PEM File> allowInvalidCertificates: false allowConnectionsWithoutCertificates: false FIPSMode: true Set "net.tls.mode" to the "requireTLS". <PEM File> is the fullpathnames to the certificates used for the option. Start/stop (restart) all mongod or mongos instances using the MongoDB configuration file (default location: /etc/mongod.conf).
When an application requires specific fields to be validated at the collection level, MongoDB's schema validation ensures that there are no unintended schema changes or improper data types for those fields. Refer to the application's guidelines and documentation. If there is no requirement for collection-level schema validation for specific fields, this is not a finding. If the application's guidelines and documentation require collection-level schema validation for a specific collection on specific fields, follow these steps: 1. As a user with the "dbAdminAnyDatabase" role, run the following commands for each database that contains collections used by the application: use <database> db.getCollectionInfos() This returns an array of documents containing information about all collections within "<database>". 2. For each specific collection (identified by the "name:" field in the output) used by the application that requires a schema validation, check the "options" sub-document for that collection. 3. If the "options" sub-document for that specific collection does not contain a "validator" sub-document, this is a finding. Below shows an example output of a collection named "testCollectionWithValidator" (indicated by "name" field) with a "validator" in the "options" sub-document: [ { name: 'testCollectionWithValidator', type: 'collection', options: { validator: { '$jsonSchema': { bsonType: 'object', required: [ 'username', 'password' ], properties: { username: { bsonType: 'string', minLength: 3, description: 'must be a string and is required with a minimum length of 3 characters' }, password: { bsonType: 'string', minLength: 8, description: 'must be a string and is required with a minimum length of 8 characters' } } } }, validationLevel: 'strict', validationAction: 'error' }, info: { readOnly: false, uuid: UUID('cf0629c2-7355-4bf8-a44b-54b9f31e4845') }, idIndex: { v: 2, key: { _id: 1 }, name: '_id_' } } ] If the "options" sub-document contains a "validator", verify it against the application guidelines and documentation. Ensure the validator checks for the presence of all fields specified in the application guidelines and documentation needing a collection level validation and confirm that the correct data types and/or ranges are being validated. If any fields specified in the application guidelines or documentation are missing from the validator, or if present and the fields do not have the correct data types and/or ranges, this is a finding.
Document validation can be added at the time of creation of a new collection. Also, existing collections can be modified with document validation rules. Use the "validator" option to create or update a collection with the desired validation rules. Refer to Schema Validation documentation for details: https://www.mongodb.com/docs/v7.0/core/schema-validation/
Run the following command and observe the output. This command will determine if MongoDB has been installed with a package Manager (RedHat) and display what version is currently installed: > rpm -q mongodb-enterprise-server.x86_64 mongodb-enterprise-server-7.0.8-1.el8.x86_64 The output of the command above indicates that MongoDB Enterprise Server has been installed with a package manager. In the preceding output is an example showing that MongoDB Enterprise Server Version 7.0.8 is installed. The specific version will be dependent on the actual version installed. Upgrading MongoDB with the same package manager used for installation will overwrite or remove files as part of the upgrade process. If MongoDB was installed with a Package Manager (YUM/RPM for RedHat) then this is not a finding. Run the following command and observe the output. > rpm -q mongodb-enterprise-server.x86_64 package mongodb-enterprise-server.x86_64 is not installed The output of the command above indicates that MongoDB has not been installed via a package manager or may not have been installed at all. If MongoDB has not been installed with a Package Manger (YUM/RPM for RedHat), this is a finding.
It is recommended to use the official installation packages provided by MongoDB. In the event the software was installed manually and permissions need to be restricted, consider a clean reinstallation. Review this organizational or site-specific document to determine how and where MongoDB is to be installed on the system. Using this documentation, verify that MongoDB has been installed on the system prior to upgrading. To verify the version of MongoDB Enterprise Server, run the following command in the directory where the MongoDB executable binary has been placed according to the organizational or site-specific documentation. > cd <mongod binary directory> > ./mongod --version The output will show the version and architecture of the MongoDB Server binary similar to the following: mongod --version db version v7.0.8 Build Info: { "version": "7.0.8", "gitVersion": "c5d33e55ba38d98e2f48765ec4e55338d67a4a64", "openSSLVersion": "OpenSSL 1.1.1k FIPS 25 Mar 2021", "modules": [ "enterprise" ], "allocator": "tcmalloc", "environment": { "distmod": "rhel80", "distarch": "x86_64", "target_arch": "x86_64" } } Verify that the version desired (what the upgraded version should be) matches what is shown in the output. If the version is not what is expected, then remove the mongod binary from the system to prevent it from being used and consult the organizational or site-specific documents for further guidance. Run the following commands as an operating system administrator to remove the MongoDB Enterprise Server binary from the system: > cd <mongod binary directory> > rm ./mongod
Review the current version of MongoDB running on the system. Run the following command from the OS command line and review the "db version" listed in the output: $ mongod --version | grep "db version" Compare the version from the output to the supported version matrix here: https://www.mongodb.com/support-policy/lifecycles If the version output in the above command has reached its "End of Life Date" shown in the matrix, this is a finding.
Ensure a license agreement is still in effect and, if so, upgrade to a supported version of MongoDB. Each major release of MongoDB has upgrade instructions. Follow the upgrade path/procedures for the version and configuration (standalone, replica set, sharded) of MongoDB accordingly. If the license agreement with MongoDB has lapsed, contact MongoDB to license the use of a supported version.
MongoDB relies on the underlying operating system to allocate storage capacity for audit logs and as such, does not enforce arbitrary file size limits on audit logs. System administrators should confirm that the recommended centralized system logging has been enabled (e.g., syslog on Linux systems) in the /etc/mongod.conf configuration file. For example, on a Linux-based system using syslog which is mirrored to an off-server centralized location, confirm that the MongdoDB configuration file (default location: /etc/mongod.conf) contains a properly configured auditLog such as follows: auditLog: destination: syslog If the auditLog entry is missing, or the destination does not reflect the intended application location, this is a finding. Investigate whether there have been any incidents where MongoDB ran out of audit log space since the last time the space was allocated or other corrective measures were taken.
To specify auditLog, or a centralized system log (which is recommended), configure these in the mongod.conf configuration file: auditLog: destination: syslog Refer to documentation for additional configuration: https://www.mongodb.com/docs/v7.0/core/auditing/ Allocate sufficient space to the storage volume hosting the file identified in the MongoDB configuration "auditLog.path" to support audit file peak demand.
Review the MongoDB documentation and configuration to determine if the DBMS is configured in accordance with DOD security configuration and implementation guidance, including STIGs, NSA configuration guides, CTOs, and DTMs and IAVMs. If MongoDB is not configured in accordance with security configuration settings, this is a finding.
Configure the DBMS in accordance with DOD security configuration and implementation guidance, including STIGs, NSA configuration guides, CTOs, and DTMs and IAVMs. It is recommended that MongoDB Enterprise be installed and upgraded though the use of a package manager (YUM/RPM RedHat) where it meets the organizational or site-specific policy. https://www.mongodb.com/docs/v7.0/tutorial/install-mongodb-enterprise-on-red-hat/
Review the organizational or site-specific software update policy and verify that MongoDB has been updated consistent with the time frame specified by that policy. The current patch release versions of MongoDB 7.0.x can be found here: https://www.mongodb.com/docs/manual/release-notes/7.0/ This link will show the patch release versions with the date of release for all of MongoDB 7.0.x. If MongoDB has not been updated to the necessary major and minor release in accordance with the policy this is a finding.
Institute and adhere to the policies and procedures to ensure that MongoDB is updated consistent with the organizational or site-specific software update policy and time frame. Update MongoDB to the necessary major and minor release in accordance with the organizational or site-specific policy.
Mongo can limit the total number of connections. Verify that the MongoDB configuration file (default location: /etc/mongod.conf) contains the following: net: maxIncomingConnections: %int% If this parameter is not present, or the OS is not utilized to limit connections, this is a finding.
MongoDB can limit the total number of connections served by mongod process by setting the following in the MongoDB configuration file (default location: /etc/mongod.conf) net: maxIncomingConnections: %int% See the following documentation: https://docs.mongodb.com/v4.4/reference/configuration-options/ Products outside of MongoDB can be used to monitor database sessions and limit the maximum number of connections that can be made. Alternatively most UNIX-like operating systems, including Linux and macOS, provide ways to limit and control the usage of system resources such as threads, files, and network connections on a per-process and per-user basis. These ulimits prevent single users from using too many system resources. The following is the MongoDB documentation regarding these user limits: https://docs.mongodb.com/v4.4/reference/ulimit/