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
Check the MongoDB configuration file (default location: /etc/mongod.conf) for appropriate audit configuration keys. Examples shown below: auditLog: destination: file format: BSON path: /var/log/mongodb/audit/auditLog.bson -OR- auditLog: destination: syslog If an auditLog key is not present, this is a finding. If the MongoDB configuration file does not contain a setParameter option with auditAuthorizationSuccess: true, this is a finding. Example: setParameter: auditAuthorizationSuccess: true If the auditLog key is present and contains a filter subkey without an associated filter, 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, then the filter being applied will need to be modified to comply. Example filter shown below only audits createCollection and dropCollection: auditLog: destination: file format: BSON path: /var/log/mongodb/audit/auditLog.bson filter: '{ atype: { $in: [ "createCollection", "dropCollection" ] } }'
If the auditLog setting was not present in the %MongoDB configuration file% (default location: /etc/mongod.conf) edit this file and add a configured auditLog setting: auditLog: destination: file format: BSON path: /var/log/mongodb/audit/auditLog.bson Note: The "/var/log/mongodb/audit" directory will need to be created/present or the database will not start. Alternately, the audit logs can be written to syslog with the following setting: auditLog: destination: syslog This setting will record the following operations: schema (DDL), replica set and sharded cluster and authentication and authorization. To capture all operations in the audit, enable the audit system to log authorization successes by adding the following line to the /etc/mongod.conf file: setParameter: auditAuthorizationSuccess: true Stop/start (restart) the mongod or mongos instance using this configuration. 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 or remove the filter parameter to enable auditing all events. Documentation on configuring filters can be found here: https://docs.mongodb.com/v4.4/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: /var/log/mongodb/audit/auditLog.bson -OR- auditLog: destination: syslog 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 output: 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. If the key name auditLog.destination is set to either syslog or console, then this requirement is not applicable as there is no physical directory that MongoDB can secure. Site security requirements and operating system security requirements will need to be reviewed to ensure appropriate settings for syslog and console destinations. To correct finding where a physical auditLog directory exists (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 660, 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 660 %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 The output of the command: stat /etc/mongod.conf should look similar to the following for a correctly owned and permissioned %MongoDB configuration file% (default /etc/mongod.conf): stat /etc/mongod.conf File:/etc/mongod.conf Size: 1034 Blocks: 8 IO Block: 4096 regular file Device: 802h/2050d Inode: 16340 Links: 1 Access: (0660/-rw-rw----) Uid: ( 997/ mongod) Gid: ( 996/ mongod) Context: system_u:object_r:etc_t:s0 Access: 2020-03-16 14:15:17.777000000 -0400 Modify: 2020-03-16 12:50:45.567000000 -0400 Change: 2020-03-16 14:27:32.451000000 -0400 Birth: -
In the MongoDB database configuration file (default location: /etc/mongod.conf), review for the following option: net: http: enabled: true JSONPEnabled: true RESTInterfaceEnabled: true If the configuration file contains any combination of http settings under the net: option, this is a finding.
MongoDB 3.6 removed the following deprecated HTTP interface and REST API to MongoDB. net.http.enabled net.http.JSONPEnabled net.http.port net.http.RESTInterfaceEnabled In the MongoDB database configuration file (default location: /etc/mongod.conf), remove the entire http option (and any sub-options) under the net: settings from the configuration file.
Inspect the MongoDB database configuration file (default location: /etc/mongod.conf) for any net.http options similar in construct to the following: net: http: option 1: value option 2: value Example: It may appear similar to the following (having one or more options): net: http: enabled: true port: port number JSONPEnabled: true RESTInterfaceEnabled: true If the configuration file contains any "http:" options under "net:", this is a finding.
MongoDB 3.6 removed the following deprecated HTTP interface and REST API to MongoDB and should not be used. net.http.enabled net.http.JSONPEnabled net.http.port net.http.RESTInterfaceEnabled In the MongoDB database configuration file (default location: /etc/mongod.conf), remove all http: options underneath net: from the configuration file.
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/mongodb.pem CAFile: /etc/ssl/caToValidateClientCertificates.pem 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/mongodb.pem CAFile: /etc/ssl/caToValidateClientCertificates.pem allowInvalidCertificates: false allowConnectionsWithoutCertificates: false Stop/start (restart) the mongod or mongos instance using this configuration. More information for configuring TLS/SSL for MongoDB can be found here: https://docs.mongodb.com/v4.4/tutorial/configure-ssl/
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 roles' privileges: For each database, identify the privileges granted by a role: use database db.getRole( %rolename%, { 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, run the following: db.revokeRolesFromUser( %username%, [ roles ], { writeConcern } ) To grant a role to a user run the following: db.grantRolesToUser( %username%, [ roles ], { writeConcern } )
Journaling is enabled by default. With journaling enabled, if mongod stops unexpectedly, the program can recover everything written to the journal. MongoDB will re-apply the write operations on restart and maintain a consistent state. To validate the mongod configuration, run the following command: db.getSiblingDB("admin").runCommand({getCmdLineOpts: 1}).parsed.storage.journal If it returns { enabled : false } or no output, this is a finding.
Modify the mongod startup command-line options by removing the --nojournal option. Edit the MongoDB database configuration file (default location: /etc/mongod.conf) to ensure the option storage.journal.enabled is present and set to true as show below: storage: journal: enabled: true Stop/start (restart) any or all mongod or mongos processes.
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
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
If security labeling is not required, this is not a finding. If security labeling is required, then there must be organizational or site-specific documentation on what the security labeling policy is and guidance on how and where to apply it. Review the organizational 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) and review the data in the MongoDB collections that require 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 be 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 how this is can be constructed can be found here: https://docs.mongodb.com/v4.4/reference/operator/aggregation/redact/ Any queries that target a MongoDB database/collection that has security labels and that pass through the trusted middleware and does not have an appropriately constructed $redact operator which is part of the query aggregation pipeline are 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"] } } ] )
If security labeling is required then ensure the following: 1. Organizational or site-specific documentation and guidance is available or developed. 2. Ensure that security labels are or have been applied to those 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. The example below shows 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 can be constructed can be found here: https://docs.mongodb.com/v4.4/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://docs.mongodb.com/v4.4/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" }, "readWriteAnyDatabase" ] } ) Enable authorization by adding the following entry to the %MongoDB configuration file%: security: authorization: enabled Restart the MongoDB service from the OS. sudo service mongod restart The createUser and createRole MongoDB commands will be used to add the required users and roles per organizational or site-specific documentation. https://docs.mongodb.com/v4.4/reference/command/createUser/ https://docs.mongodb.com/v4.4/reference/command/createRole/
Run the following command from the MongoDB shell: db.getSiblingDB("admin").runCommand({getCmdLineOpts: 1}).parsed.net.tls.FIPSMode If the MongoDB server is running with FIPS mode, this command will return true. Any other output is a finding. Verify that FIPS has been enabled at the OS level. Refer to the appropriate OS STIG documentation.
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 true Alternatively, run the following command to search the mongod logfile for FIPS 140-2 mode activated: grep "FIPS 140-2 mode activated" /var/log/mongodb/mongod.log For the operating system finding, refer to the appropriate operating system documentation for the procedure to install, configure, and test FIPS mode.
Review the system documentation to determine whether the organization has defined the information at rest that is to be protected from modification, which must include, at a minimum, PII and classified information. If no information is identified as requiring such protection, this is not a finding. If any data is PII, classified or is deemed by the organization the need to be encrypted at rest, verify the MongoDB configuration file (default location: /etc/mongod.conf) contain the following options: security: enableEncryption: true kmip: serverName: %KMIP Server HostName% port: %KMIP server port% ServerCAFile: %CA PEM file% clientCertificateFile: %client PEM file% If these above options are not part of the MongoDB configuration file, this is a finding. Items in the above are specific to the KMIP appliance and need to be set according to the KMIP appliance configuration.
Configure MongoDB to use the Encrypted Storage Engine and a KMIP appliance as documented here: https://docs.mongodb.com/v4.4/core/security-encryption-at-rest/ https://docs.mongodb.com/v4.4/tutorial/configure-encryption/
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/
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.
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://docs.mongodb.com/v4.4/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 deployment. Configuration information for LDAP for MongoDB can be found here: https://docs.mongodb.com/v4.4/core/security-ldap-external/ https://docs.mongodb.com/v4.4/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. If the actual permissions do not match the documented requirements, this is a finding. Run MongoDB command to view roles and privileges in a particular database: use database db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true } )
Use createRole(), updateRole(), dropRole(), grantRole() statements to add and remove permissions on MongoDB serverl securables, bringing them into line with the documented requirements. MongoDB commands for role management can be found here: https://docs.mongodb.com/v4.4/reference/method/js-role-management/
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. If monitoring does not occur or is not complete, this is a finding.
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.
Review procedures for controlling, granting access to, and tracking use of the DBMS software installation account. If access or use of this account is not restricted to the minimum number of personnel required or if unauthorized access to the account has been granted, this is a finding.
Develop, document, and implement procedures to restrict and track use of the DBMS software installation account.
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) /var/lib/mongo/diagnostic.data /var/lib/mongo/_tmp /var/lib/mongo/journal /var/log/mongodb (the mongod process log directory) /var/log/mongodb/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 sub-directories. 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, move or delete that data from the MongoDB-created directories.
Run the following command to get the roles from a MongoDB database. For each database in MongoDB: use database db.getUsers() If the output shows a role of "dbOwner", this is a finding.
For each user where the role of dbOwner is found verify whether or not the user is authorized for this role on the resources listed. This information will be found in the organizational or site-specific documentation. If a user if found not authorized to have the role dbOwner the remove that role from the user with the db.revokeRolesFromUser() command https://docs.mongodb.com/v4.4/reference/command/revokeRolesFromUser/
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://docs.mongodb.com/v4.4/reference/method/js-role-management/
In the MongoDB database configuration file (default location: /etc/mongod.conf), review the following parameters: net: http: enabled: true JSONPEnabled: true RESTInterfaceEnabled: true If any of the booleans are true or enabled, this is a finding.
In the MongoDB database configuration file (default location: /etc/mongod.conf), ensure the following parameters either: Does not exist in the file OR Are set to false as shown below: http: enabled: false JSONPEnabled: false RESTInterfaceEnabled: 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: use database db.dropUser(%username%, {w: "majority", wtimeout: 5000}) If the %MongoDB configuration file% (default location: /etc/mongod.conf) does not contain security: authorization: enabled Edit the %MongoDB configuration file%, add these parameters, stop/start (restart) any mongod or mongos process using this %MongoDB configuration file%.
If MongoDB is using Native LDAP authentication where the LDAP server is configured to enforce password complexity and lifetime, this is not a finding. If MongoDB is using Kerberos authentication where Kerberos is configured to enforce password complexity and lifetime, this is not a finding. If MongoDB is not configured for SCRAM-SHA1, MONGODB-CR, or LDAP authentication, this is a finding.
Password complexity and lifetime must be enforced by an external authentication source such as LDAP, Active Directory, or Kerberos. Information on configuring MongoDB for one of these authentication mechanisms be found here: LDAP/Active Directory: https://docs.mongodb.com/v4.4/tutorial/authenticate-nativeldap-activedirectory/ Kerberos: https://docs.mongodb.com/v4.4/tutorial/control-access-to-mongodb-with-kerberos-authentication/
MongoDB supports several authentication mechanisms, some of which store credentials on the MongoDB server. If these mechanisms are in use, MongoDBs authSchemaVersion in the admin.system.version collection must be set to 5. 1. Validate that authenticationMechansisms 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, this 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. If authenticationMechanisms is not defined in the %MongoDB configuration file% (default location: /etc/mongod.conf), define one of more authenticationMechanisms, from the subset below: SCRAM-SHA-1 SCRAM-SHA-256 MONGODB-X509 GSSAPI PLAIN which the MongoDB server process must accept. Example: setParameter: authenticationMechanisms: SCRAM-SHA-1,SCRAM-SHA-256 2. If authSchemaVersion is less than 5. Run the following command: db.adminCommand({authSchemaUpgrade: 1}) In the unlikely event that an error is encountered, safely rerun the authSchemaUpgrade command.
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/caToValidateClientCertificates.pem Verify ownership, group ownership, and permissions for the MongoDB config file (default: /etc/mongod.conf), the PEMKeyFile (default /etc/ssl/mongodb.pem), and the CAFile (default /etc/ssl/caToValidateClientCertificates.pem). For each file, run following command and review its output: ls -al filepath example output: -rw------- 1 mongod mongod 566 Apr 26 20:20 filepath If the user owner is not mongod, this is a finding. If the group owner is not mongod, this is a finding. If the file is more permissive than 600, this is a finding.
To set proper ownership, group ownership, and permissions, run these commands: chown mongod:mongod /etc/ssl/mongodb.pem chmod 600 /etc/ssl/mongodb.pem chown mongod:mongod /etc/ssl/caToValidateClientCertificates.pem chmod 600 /etc/ssl/caToValidateClientCertificates.pem
If using LDAP for authentication, this is not applicable. Each unique x.509 client certificate corresponds to a single MongoDB user; meaning it cannot use a single-client certificate to authenticate more than one MongoDB user. Log in 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 certs 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 it cannot use a single-client certificate to 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. See 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, 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 AO approval has been obtained. If it is not documented, this is a finding. Request evidence that all users of MongoDB command-line tools are trained in the use of the -p 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, 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.
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, one may create user-defined roles. Check a user's role to ensure correct privileges for the function: Prereq: To view a user's roles, you 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 roles' privileges: Prereq: To view a user's roles, you 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. Prereq: 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.
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 Stop/start (restart) and mongod or mongos using the %MongoDB configuration file%. Further documentation is here: https://docs.mongodb.com/v4.4/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. Next, 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. Finally, 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://docs.mongodb.com/v4.4/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.
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, e.g.: Error: error: { "ok" : 0, "errmsg" : "no globalScriptEngine in $where parsing", "code" : 2, "codeName" : "BadValue" }
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://docs.mongodb.com/v4.4/core/schema-validation/
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 login 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 or not. 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 identify the level of 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 service mongod restart
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 identify the level of 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 is an administrative command that will return the most recent 1024 logged mongod events. 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 see actions its permitted to perform on the cluster resource: db.runCommand({usersInfo: %username%, 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: security: redactClientLogData: true Stop/start (restart) any mongod or mongos using the %MongoDB configuration file%. Identify and remove any administrative 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/v4.4/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/v4.4/reference/command/killAllSessionsByPattern/
Administrators can implement collection-level access control through user-defined roles. By creating a role with privileges that are scoped to a specific collection in a particular database, administrators can provision users with roles that grant privileges on a collection level. For example, a user defined role can contain the following privileges: Once enabled, the auditing system can record the following operations: schema changes (DDL), replica set and sharded cluster, authentication and authorization, and CRUD operations (requires auditAuthorizationSuccess set to true). For details on audited actions, see MongoDB documentation on the complete configuration of Audit Event Actions, Details, and Results, and Configuring Audit Filters. To ensure auditing is enabled, confirm the auditLog section in the /etc/mongod.conf configuration file exists and has been set. For example, to enable syslog centralized logging of audit events, in the MongoDB configuration file (by default: /etc/mongod.conf) verify the destination type is set as: auditLog: destination: file format: BSON path: /var/log/mongodb/audit/auditLog.bson -OR- auditLog: destination: syslog If this is not present, is empty, or commented, this is a finding. Review the system documentation for a description of how audit records are off-loaded and how local audit log space is managed. If the DBMS audit records are not written directly to or systematically transferred to a centralized log management system, this is a finding.
If audit operations filters are not configured in the MongoDB configuration file (default location: /etc/mongod.conf), configure them according to application requirements, but at a minimum, ensure destination and filter are set in a mongod.conf YAML auditLog configuration setting. For example, to audit all database operations involving creating or dropping a collection, the %MongoDB configuration file% (by default /etc/mongod.conf) auditLog section would read as follows: auditLog: destination: file format: BSON path: /var/log/mongodb/audit/auditLog.bson filter: '{ atype: { $in: [ "createCollection", "dropCollection" ] } }' See mongodb documentation for details of audit operations and event configuration. https://docs.mongodb.com/v4.4/core/auditing/ https://docs.mongodb.com/v4.4/tutorial/configure-audit-filters/ Configure and/or deploy software tools to ensure that DBMS audit records are written directly to or systematically transferred to a centralized log management system.
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 MongoDB 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. If there have been incidents where MongoDB ran out of audit log space, this is a finding.
If an auditLog has not been specified, or a centralized system log (which is recommended) has not been enabled, configure these in the mongod.conf configuration file: auditLog: destination: syslog See documentation for additional configuration: https://docs.mongodb.com/v4.4/tutorial/configure-auditing/ 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. This is only applicable where the auditLog.destination is set to file. Verify that MongoDB Ops Manager or other organization approved 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 MongoDB Ops Manager or other organization-approved 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.
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 only supports views and Change Streams (similar to triggers). Stored procedures and functions that are commonly found in relational databases are not supported by MongoDB. Connect to MongoDB and authenticate as a user that has Database Administrator privileges. Check each user of the database to verify that only authorized administrative users are granted the following privileges: createCollection and changeStream Run the following command to get a list of all the databases in the system: show dbs For each database in the system, identify any non-administrative users 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. Organizational or site-specific documentation should identify which administrative and non-administrative users exist. For each role that a non-administrative user has in the database find the privileges each role has: db.getRole(rolename, { showPrivileges: true }) If any non-administrative user has a role that where the resource has the action of createCollections or changeStream this is a finding.
Document and obtain approval for any non-administrative users to have roles that contain createCollections or changeSteam actions on resources. For any non-administrative user that does not have approval, revoke these specific privileges from that non-administrative users role. Run the following commands in each database and for each non-administrative user that does not have approval to use the createCollections or changeStream actions on MongoDB resources: use database db.revokePrivilegesFromRole( rolename, [ { resource: { resource }, actions: [ action, ... ] }, ... ], { writeConcern } ) In the above command the action will be either createCollections or changeStream. There may be several resources in a role that contain these privileges and the removal process will require running the following command for each one.
To verify that access 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, then log 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.insert( { x: 1 } ) This operation will fail with a WriteResult error: WriteCommandError({ "ok" : 0, "errmsg" : "not authorized on test to execute command { insert: \"###\", ordered: \"###\", lsid: { id: \"###\" }, $db: \"###\" }", "code" : 13, "codeName" : "Unauthorized" }) If the operation does not fail, this is a finding.
Verify that authentication has been enabled in the %MongoDB configuration file%: https://docs.mongodb.com/v4.4/reference/configuration-options/. If authorization is enabled, review the following to list existing user permissions. https://docs.mongodb.com/v4.4/reference/privilege-actions/ Connect to MongoDB. For each database (show dbs), 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 method below: db.revokeRolesFromUser( %username%, [ roles ], { writeConcern } ) https://docs.mongodb.com/v4.4/reference/method/db.revokeRolesFromUser/ To grant a role to a user, use the method below: db.grantRolesToUser( %username%, [ roles ], { writeConcern } ) https://docs.mongodb.com/v4.4/reference/method/db.grantRolesToUser/
MongoDB Enterprise supports PKI x.509 certificate bearer authentication. The duration of a user's logical session is application-specific, but is verified on initial network session connection. Additional user authentication controls can be enabled on a client basis (including Windows OS-level CAC + PIN flow; see operating system documentation for specific configuration). By specifying both the database and the collection in the resource document for a privilege, administrator can limit the privilege actions just to a specific collection in a specific database. Each privilege action in a role can be scoped to a different collection. When a new privilege is applied to an object, such as a particular collection or a database, authorization to access that object is verified at run-time (i.e., in real time). To check that authorization is being enforced, see the documentation for Collection-Level Access Control and custom user roles (https://docs.mongodb.com/v4.4/core/collection-level-access-control/) and create a new role with the following permissions, e.g.: use admin db.createRole( { role: "myTestRole", privileges: [ { resource: { db: "products", collection: "inventory" }, actions: [ "find", "update", "insert" ] }, { resource: { db: "products", collection: "orders" }, actions: [ "find" ] } ], roles: [ ] }, { w: "majority" , wtimeout: 5000 } ) Assign that privilege to one or more users. use products db.createUser({user: "myRoleTestUser", pwd: "password1", roles: ["myTestRole"]}) Log in as "myRoleTestUser" user and attempt find(), insert() and delete() operations on a test inventory and orders collection. The following commands will succeed: use products db.inventory.insert({a: 1}) db.inventory.find() db.inventory.update({a:1}, {$set: {"updated": true}}) Example output of the above commands: use products switched to db products db.inventory.find() db.inventory.insert({a: 1}) WriteResult({ "nInserted" : 1 }) db.inventory.update({a:1}, {$set: {"updated": true}}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 }) Of the following ONLY the find() will succeed: use products switched to db products use products db.orders.find() db.orders.insert({a: 1}) db.orders.update({a:1}, {$set: {"updated": true}}) Example output: db.orders.find() db.orders.insert({a: 1}) WriteCommandError({ "ok" : 0, "errmsg" : "not authorized on products to execute command { insert: \"###\", ordered: \"###\", lsid: { id: \"###\" }, $db: \"###\" }", "code" : 13, "codeName" : "Unauthorized" }) db.orders.update({a:1}, {$set: {"updated": true}}) WriteCommandError({ "ok" : 0, "errmsg" : "not authorized on products to execute command { update: \"###\", ordered: \"###\", lsid: { id: \"###\" }, $db: \"###\" }", "code" : 13, "codeName" : "Unauthorized" }) In the last example above, if either or both insert() or update() succeed, this is a finding. Note that this check is by necessity application-specific.
Determine the organization-defined circumstances or situations that require reauthentication and ensure that the mongod and mongos processes are stopped/started (restart), and ensure that the mongod configuration file has security.authentication: true set. In the case of database- and collection-level scoped user privileges, see MongoDB documentation for guidance on application specific configuration for user privileges in order to restrict access as required: https://docs.mongodb.com/v4.4/tutorial/manage-users-and-roles/#create-a-role-to-manage-current-operations https://docs.mongodb.com/v4.4/core/collection-level-access-control/#privileges-and-scope
If MongoDB is configured to authenticate using SASL and LDAP check the saslauthd command line options in the system boot script that starts saslauthd (the location will be dependent on the specific Linux operating system and boot script layout and naming conventions). If the "-t" option is not set for the "saslauthd" process in the system boot script, this is a finding.
With MongoDB configured using SASL LDAP authentication and on certain Linux distributions, saslauthd starts with the caching of authentication credentials enabled. Until restarted or until the cache expires, saslauthd will not contact the LDAP server to re-authenticate users in its authentication cache. This allows saslauthd to successfully authenticate users in its cache, even in the LDAP server is down or if the cached users' credentials are revoked. To set the expiration time (in seconds) for the authentication cache, see the -t option of saslauthd (https://www.systutorials.com/docs/linux/man/8-saslauthd/).
To run MongoDB in TLS mode, obtain a valid certificate singed by a single certificate authority. Before starting the MongoDB database in TLS mode, verify that certificate used is issued by a valid DoD certificate authority (openssl x509 -in path_to_certificate_pem_file -text | grep -i issuer). If there is any issuer present in the certificate that is not a DoD approved certificate authority, this is a finding.
Remove any certificate 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 authority.
Review the system information/specification for information indicating a strict requirement for data integrity and confidentiality when data is being prepared to be transmitted. If such information is absent therein, this is not a finding. If such information is present, inspect the MongoDB configuration file (default location: /etc/mongod.conf) for the following entries: net: tls: mode: requireTLS certificateKeyFile: /etc/ssl/mongodb.pem CAFile: /etc/ssl/caToValidateClientCertificates.pem 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% with TLS configuration options such as: net: tls: mode: requireTLS certificateKeyFile: /etc/ssl/mongodb.pem CAFile: /etc/ssl/caToValidateClientCertificates.pem allowInvalidCertificates: false allowConnectionsWithoutCertificates: false FIPSMode: true Set net.tls.mode to the requireTLS. Set net.tls.certificateKeyFile to the full path of the certificate (.pem) file. 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 information is present, inspect the MongoDB configuration file (default location: /etc/mongod.conf) for the following entries: net: tls: mode: requireTLS certificateKeyFile: /etc/ssl/mongodb.pem CAFile: /etc/ssl/caToValidateClientCertificates.pem allowInvalidCertificates: false allowConnectionsWithoutCertificates: false FIPSMode: true If net.tls.mode is not set to requireTLS, this is a finding.
Obtain a certificate from a valid DoD certificate authority to be used for encrypted data transmission. Modify the %MongoDB configuration file% with TLS configuration options such as: net: tls: mode: requireTLS certificateKeyFile: /etc/ssl/mongodb.pem CAFile: /etc/ssl/caToValidateClientCertificates.pem allowInvalidCertificates: false allowConnectionsWithoutCertificates: false FIPSMode: true Ensue net.tls.mode is set to requireTLS. Start/stop (restart) all mongod or mongos instances using the %MongoDB configuration file% (default location: /etc/mongod.conf).
This is application-specific, but see Schema Validation documentation here: https://docs.mongodb.com/v4.4/core/schema-validation/ As an example, as a user with the dbAdminAnyDatabase role, execute the following on the database of interest: use database db.getCollectionInfos() Where database is the name of the database on which validator rules are to be inspected. This returns an array of documents containing all collections information within the database. For all collections information received, check if the options sub-document contains a validator. If the options sub-document does not contain a validator, this is a finding. Example below shows a finding: [ { "name" : "inventory", "type" : "collection", "options" : { }, "info" : { "readOnly" : false, "uuid" : UUID("b2c86d4d-48bf-4394-9743-620e6d68b87f") }, "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "products.inventory" } } ]
Document validation can be added at the time of creation of a new collection. Existing collections can also be modified with document validation rules. Use the validator option to create or update a collection with the desired validation rules. See Schema Validation documentation for details: https://docs.mongodb.com/v4.4/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-4.4.8-1.el7.x86_64 The output of the command above indicates that MongoDB Enterprise Server has been installed with a package manager. The preceding output is an example showing that MongoDB Enterprise Server Version 4.4.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), 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 Manager (YUM/RPM for RedHat), this is a finding.
If there is a finding, then MongoDB has not been installed via a package manager and may have been installed manually or not at all. If MongoDB has not been installed via a package manager, verify that an organizational or site-specific document outlining the installation and upgrade procedures for software exists. 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 v4.4.8 Build Info: { "version": "4.4.8", "gitVersion": "83b8bb8b6b325d8d8d3dfd2ad9f744bdad7d6ca0", "openSSLVersion": "OpenSSL 1.0.1e-fips 11 Feb 2013", "modules": [ "enterprise" ], "allocator": "tcmalloc", "environment": { "distmod": "rhel70", "distarch": "x86_64", "target_arch": "x86_64" } } Verify that the version desired (what the upgraded version should be) matches what is shown the in output. For example, if updated from MongoDB Enterprise Server v4.4.8 to v4.4.9, the output after the update would be similar to the above but the db version would reflect v4.4.9. 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 organizational or site-specific software update policy and verify that MongoDB has been updated consistent with the time frame specified by the policy. The current major version of MongoDB can be found here: https://docs.mongodb.com/v4.4/release-notes/ This link will show the major version of MongoDB. To find the minor version within that release select the appropriate sublink. For example, to see the latest 4.4 minor releases in MongoDB, select the Release Notes for 4.4. This will show all minor releases and their notes. For example: 4.4.9, 4.4.8, 4.4.6, 4.4.5, etc. 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.
To determine the current running MongoDB server version, run the following command from the Mongo Shell: db.version() MongoDB 4.x is no longer supported by the vendor. If the system is running MongoDB 4.x, this is a finding.
Remove or decommission all unsupported software products. Upgrade unsupported DBMS or unsupported components to a supported version of the product.
Assessing the system against the STIG configurations and guidance of the current document is the check for this requirement. If the MongoDB is not configured in accordance with the security configuration settings of this document, this is a finding.
Configure MongoDB in accordance with security configuration settings and guidance of this STIG document to meet the configurations required by the STIG, NSA configuration guidelines, CTOs, 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://docs.mongodb.com/v4.4/tutorial/install-mongodb-enterprise-on-red-hat/