diff --git a/mongo-hardening.pkr.hcl b/mongo-hardening.pkr.hcl index 9835e07..4d3b02a 100644 --- a/mongo-hardening.pkr.hcl +++ b/mongo-hardening.pkr.hcl @@ -41,7 +41,7 @@ variable "scan" { type = map(string) default = { "report_dir" = "reports", - "inspec_profile" = "spec/inspec_wrapper", + "inspec_profile" = "spec/mongo-inspec-profile", "inspec_report_filename" = "inspec_results.json", "inspec_input_file" = "spec/inspec_wrapper/inputs.yml" } diff --git a/spec/ansible/roles/mongo-stig/tasks/cat1.yml b/spec/ansible/roles/mongo-stig/tasks/cat1.yml index fb10927..d83bfed 100644 --- a/spec/ansible/roles/mongo-stig/tasks/cat1.yml +++ b/spec/ansible/roles/mongo-stig/tasks/cat1.yml @@ -1,8 +1,9 @@ --- -- name: "HIGH | V-252139 | If passwords are used for authentication, MongoDB must transmit only encrypted representations of passwords." +- name: "HIGH | SV-252139 | If passwords are used for authentication, MongoDB must transmit only encrypted representations of passwords." + #change to SV blockinfile: path: "{{ mongod_config_path }}" - marker: "#Finding V-252139" + marker: "#Rule ID SV-252139" prepend_newline: true insertafter: "^net:" block: | #need the ID as a placeholder for the space @@ -19,9 +20,9 @@ tags: - cat1 - high - - V-252139 + - SV-252139 -# - name: "HIGH | V-252146 | MongoDB must use NIST FIPS 140-2 or 140-3 validated cryptographic modules for cryptographic operations." +# - name: "HIGH | SV-252146 | MongoDB must use NIST FIPS 140-2 or 140-3 validated cryptographic modules for cryptographic operations." # command: true # register: result # @@ -30,7 +31,7 @@ # tags: # - cat1 # - high -# - V-252146 +# - SV-252146 - name: Check if 'security:' exists and is not commented out shell: "grep -P '^security:' {{ mongod_config_path }} || true" @@ -38,10 +39,10 @@ changed_when: false ignore_errors: true -- name: "HIGH | V-252149 | MongoDB must integrate with an organization-level authentication/access mechanism providing account management and automation for all users, groups, roles, and any other principals. | Security block does not exist." +- name: "HIGH | SV-252149 | MongoDB must integrate with an organization-level authentication/access mechanism providing account management and automation for all users, groups, roles, and any other principals. | Security block does not exist." blockinfile: path: "{{ mongod_config_path }}" - marker: "#Finding V-252149" + marker: "#Rule ID SV-252149" prepend_newline: true insertafter: "^#security:" block: | @@ -54,12 +55,12 @@ tags: - cat1 - high - - V-252149 + - SV-252149 -- name: "HIGH | V-252149 | MongoDB must integrate with an organization-level authentication/access mechanism providing account management and automation for all users, groups, roles, and any other principals. | Security block exists." +- name: "HIGH | SV-252149 | MongoDB must integrate with an organization-level authentication/access mechanism providing account management and automation for all users, groups, roles, and any other principals. | Security block exists." blockinfile: path: "{{ mongod_config_path }}" - marker: "#Finding V-252149" + marker: "#Rule ID SV-252149" prepend_newline: true insertafter: "^security:" block: | @@ -72,9 +73,9 @@ tags: - cat1 - high - - V-252149 + - SV-252149 -- name: "HIGH | V-252150 | MongoDB must enforce approved authorizations for logical access to information and system resources in accordance with applicable access control policies." +- name: "HIGH | SV-252150 | MongoDB must enforce approved authorizations for logical access to information and system resources in accordance with applicable access control policies." community.mongodb.mongodb_shell: #works but unsure what output is db: "database" eval: "db.getRoles({rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })" @@ -84,9 +85,9 @@ tags: - cat1 - high - - V-252150 + - SV-252150 -# - name: "HIGH | V-252152 | MongoDB software installation account must be restricted to authorized users." +# - name: "HIGH | SV-252152 | MongoDB software installation account must be restricted to authorized users." # command: true # register: result # changed_when: no @@ -94,9 +95,9 @@ # tags: # - cat1 # - high -# - V-252152 +# - SV-252152 -# - name: "HIGH | V-252158 | If passwords are used for authentication, MongoDB must implement LDAP or Kerberos for authentication to enforce the DoD standards for password complexity and lifetime." +# - name: "HIGH | SV-252158 | If passwords are used for authentication, MongoDB must implement LDAP or Kerberos for authentication to enforce the DoD standards for password complexity and lifetime." # command: true # register: result # changed_when: no @@ -104,12 +105,12 @@ # tags: # - cat1 # - high -# - V-252158 +# - SV-252158 -- name: "HIGH | V-252159 | If passwords are used for authentication, MongoDB must store only hashed, salted representations of passwords." +- name: "HIGH | SV-252159 | If passwords are used for authentication, MongoDB must store only hashed, salted representations of passwords." blockinfile: path: "{{ mongod_config_path }}" - marker: "#Finding V-252159" + marker: "#Rule ID SV-252159" prepend_newline: true insertafter: "EOF" block: | @@ -122,10 +123,10 @@ tags: - cat1 - high - - V-252159 + - SV-252159 -# - name: "HIGH | V-252159 | If passwords are used for authentication, MongoDB must store only hashed, salted representations of passwords." -# #the command for part two of this finding no longer exists in recent versions of mongo +# - name: "HIGH | SV-252159 | If passwords are used for authentication, MongoDB must store only hashed, salted representations of passwords." +# #the command for part two of this Rule ID no longer exists in recent versions of mongo # command: true # register: result # changed_when: no @@ -133,9 +134,9 @@ # tags: # - cat1 # - high -# - V-252159 +# - SV-252159 -# - name: "HIGH | V-252160 | MongoDB must enforce authorized access to all PKI private keys stored/utilized by MongoDB." +# - name: "HIGH | SV-252160 | MongoDB must enforce authorized access to all PKI private keys stored/utilized by MongoDB." # command: true # register: result # changed_when: no @@ -143,10 +144,10 @@ # tags: # - cat1 # - high -# - V-252160 +# - SV-252160 -# - name: "HIGH | V-252162 | MongoDB must obscure feedback of authentication information during the authentication process to protect the information from possible exploitation/use by unauthorized individuals." +# - name: "HIGH | SV-252162 | MongoDB must obscure feedback of authentication information during the authentication process to protect the information from possible exploitation/use by unauthorized individuals." # command: true # register: result # changed_when: no @@ -154,9 +155,9 @@ # tags: # - cat1 # - high -# - V-252162 +# - SV-252162 -# - name: "HIGH | V-252165 | MongoDB must protect the confidentiality and integrity of all information at rest." +# - name: "HIGH | SV-252165 | MongoDB must protect the confidentiality and integrity of all information at rest." # command: true # register: result # changed_when: no @@ -164,9 +165,9 @@ # tags: # - cat1 # - high -# - V-252165 +# - SV-252165 -# - name: "HIGH | V-252184 | MongoDB products must be a version supported by the vendor." +# - name: "HIGH | SV-252184 | MongoDB products must be a version supported by the vendor." # command: true # register: result # changed_when: no @@ -174,7 +175,7 @@ # tags: # - cat1 # - high -# - V-252184 +# - SV-252184 - name: Print the contents of mongod.conf command: cat "{{ mongod_config_path }}" diff --git a/spec/ansible/roles/mongo-stig/tasks/cat2.yml b/spec/ansible/roles/mongo-stig/tasks/cat2.yml index cc4d9bb..a91a39a 100644 --- a/spec/ansible/roles/mongo-stig/tasks/cat2.yml +++ b/spec/ansible/roles/mongo-stig/tasks/cat2.yml @@ -1,8 +1,8 @@ # --- -- name: "MEDIUM | V-252134 | MongoDB must provide audit record generation for DoD-defined auditable events within all DBMS/database components." +- name: "MEDIUM | SV-252134 | MongoDB must provide audit record generation for DoD-defined auditable events within all DBMS/database components." blockinfile: path: "{{ mongod_config_path }}" - marker: "#Finding V-242134" + marker: "#Rule ID SV-242134" prepend_newline: true insertafter: "^#auditLog:" block: | @@ -16,9 +16,9 @@ tags: - cat2 - medium - - V-252134 + - SV-252134 -# - name: "MEDIUM | V-252135 | The audit information produced by MongoDB must be protected from unauthorized access." +# - name: "MEDIUM | SV-252135 | The audit information produced by MongoDB must be protected from unauthorized access." # command: true # register: result # @@ -27,9 +27,9 @@ # tags: # - cat2 # - medium -# - V-252135 +# - SV-252135 -# - name: "MEDIUM | V-252136 | MongoDB must protect its audit features from unauthorized access." +# - name: "MEDIUM | SV-252136 | MongoDB must protect its audit features from unauthorized access." # command: true # register: result # @@ -38,9 +38,9 @@ # tags: # - cat2 # - medium -# - V-252136 +# - SV-252136 -# - name: "MEDIUM | V-252137 | Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled." +# - name: "MEDIUM | SV-252137 | Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled." # #this control is to remove stuff # command: true # register: result @@ -49,9 +49,9 @@ # tags: # - cat2 # - medium -# - V-252137 +# - SV-252137 -# - name: "MEDIUM | V-252138 | Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled." +# - name: "MEDIUM | SV-252138 | Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled." # #this control is to remove stuff # command: true # register: result @@ -60,9 +60,9 @@ # tags: # - cat2 # - medium -# - V-252138 +# - SV-252138 -# - name: "MEDIUM | V-252140 | MongoDB must uniquely identify and authenticate non-organizational users (or processes acting on behalf of non-organizational users)." +# - name: "MEDIUM | SV-252140 | MongoDB must uniquely identify and authenticate non-organizational users (or processes acting on behalf of non-organizational users)." # command: true # register: result # changed_when: no @@ -70,13 +70,13 @@ # tags: # - cat2 # - medium -# - V-252140 +# - SV-252140 -- name: "MEDIUM | V-252141 | MongoDB must fail to a secure state if system initialization fails, shutdown fails, or aborts fail." +- name: "MEDIUM | SV-252141 | MongoDB must fail to a secure state if system initialization fails, shutdown fails, or aborts fail." #need to add check text blockinfile: path: "{{ mongod_config_path }}" - marker: "#Finding V-252141" + marker: "#Rule ID SV-252141" prepend_newline: true insertafter: "EOF" block: | @@ -89,9 +89,9 @@ tags: - cat2 - medium - - V-252141 + - SV-252141 -# - name: "MEDIUM | V-252142 | MongoDB must prevent unauthorized and unintended information transfer via shared system resources." +# - name: "MEDIUM | SV-252142 | MongoDB must prevent unauthorized and unintended information transfer via shared system resources." # command: true # register: result # changed_when: no @@ -99,7 +99,7 @@ # tags: # - cat2 # - medium -# - V-252142 +# - SV-252142 - name: Check if 'security:' exists and is not commented out shell: "grep -P '^security:' {{ mongod_config_path }} || true" @@ -107,10 +107,10 @@ changed_when: false ignore_errors: true -- name: "MEDIUM | V-252143 | MongoDB and associated applications must reserve the use of dynamic code execution for situations that require it. | Security block does not exist." +- name: "MEDIUM | SV-252143 | MongoDB and associated applications must reserve the use of dynamic code execution for situations that require it. | Security block does not exist." blockinfile: path: "{{ mongod_config_path }}" - marker: "#Finding V-252143" + marker: "#Rule ID SV-252143" prepend_newline: true insertafter: "^#security:" block: | @@ -123,12 +123,12 @@ tags: - cat2 - medium - - V-252143 + - SV-252143 -- name: "MEDIUM | V-252143 | MongoDB and associated applications must reserve the use of dynamic code execution for situations that require it. | Security block exists." +- name: "MEDIUM | SV-252143 | MongoDB and associated applications must reserve the use of dynamic code execution for situations that require it. | Security block exists." blockinfile: path: "{{ mongod_config_path }}" - marker: "#Finding V-252143" + marker: "#Rule ID SV-252143" prepend_newline: true insertafter: "^security:" block: | @@ -141,9 +141,9 @@ tags: - cat2 - medium - - V-252143 + - SV-252143 -# - name: "MEDIUM | V-252144 | MongoDB must associate organization-defined types of security labels having organization-defined security label values with information in storage and transmission." +# - name: "MEDIUM | SV-252144 | MongoDB must associate organization-defined types of security labels having organization-defined security label values with information in storage and transmission." # command: true # register: result # changed_when: no @@ -151,9 +151,9 @@ # tags: # - cat2 # - medium -# - V-252144 +# - SV-252144 -# - name: "MEDIUM | V-252145 | MongoDB must enforce discretionary access control policies, as defined by the data owner, over defined subjects and objects." +# - name: "MEDIUM | SV-252145 | MongoDB must enforce discretionary access control policies, as defined by the data owner, over defined subjects and objects." # command: true # register: result # changed_when: no @@ -161,9 +161,9 @@ # tags: # - cat2 # - medium -# - V-252145 +# - SV-252145 -# - name: "MEDIUM | V-252147 | MongoDB must implement cryptographic mechanisms to prevent unauthorized modification of organization-defined information at rest (to include, at a minimum, PII and classified information) on organization-defined information system components." +# - name: "MEDIUM | SV-252147 | MongoDB must implement cryptographic mechanisms to prevent unauthorized modification of organization-defined information at rest (to include, at a minimum, PII and classified information) on organization-defined information system components." # mongo enterprise only # command: true # register: result @@ -172,9 +172,9 @@ # tags: # - cat2 # - medium -# - V-252147 +# - SV-252147 -# - name: "MEDIUM | V-252148 | MongoDB must limit the total number of concurrent connections to the database." +# - name: "MEDIUM | SV-252148 | MongoDB must limit the total number of concurrent connections to the database." # command: true # register: result # changed_when: no @@ -182,9 +182,9 @@ # tags: # - cat2 # - medium -# - V-252148 +# - SV-252148 -# - name: "MEDIUM | V-252151 | MongoDB must limit privileges to change software modules, to include stored procedures, functions and triggers, and links to software external to MongoDB." +# - name: "MEDIUM | SV-252151 | MongoDB must limit privileges to change software modules, to include stored procedures, functions and triggers, and links to software external to MongoDB." # command: true # register: result # changed_when: no @@ -192,9 +192,9 @@ # tags: # - cat2 # - medium -# - V-252151 +# - SV-252151 -# - name: "MEDIUM | V-252153 | Database software, including DBMS configuration files, must be stored in dedicated directories, or DASD pools, separate from the host OS and other applications." +# - name: "MEDIUM | SV-252153 | Database software, including DBMS configuration files, must be stored in dedicated directories, or DASD pools, separate from the host OS and other applications." # command: true # register: result # changed_when: no @@ -202,9 +202,9 @@ # tags: # - cat2 # - medium -# - V-252153 +# - SV-252153 -# - name: "MEDIUM | V-252154 | Database objects (including but not limited to tables, indexes, storage, stored procedures, functions, triggers, links to software external to MongoDB, etc.) must be owned by database/DBMS principals authorized for ownership." +# - name: "MEDIUM | SV-252154 | Database objects (including but not limited to tables, indexes, storage, stored procedures, functions, triggers, links to software external to MongoDB, etc.) must be owned by database/DBMS principals authorized for ownership." # command: true # register: results # changed_when: no @@ -212,9 +212,9 @@ # tags: # - cat2 # - medium -# - V-252154 +# - SV-252154 -# - name: "MEDIUM | V-252155 | The role(s)/group(s) used to modify database structure (including but not necessarily limited to tables, indexes, storage, etc.) and logic modules (stored procedures, functions, triggers, links to software external to MongoDB, etc.) must be restricted to authorized users." +# - name: "MEDIUM | SV-252155 | The role(s)/group(s) used to modify database structure (including but not necessarily limited to tables, indexes, storage, etc.) and logic modules (stored procedures, functions, triggers, links to software external to MongoDB, etc.) must be restricted to authorized users." # command: true # register: result # changed_when: no @@ -222,9 +222,9 @@ # tags: # - cat2 # - medium -# - V-252155 +# - SV-252155 -# - name: "MEDIUM | V-252156 | Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled." +# - name: "MEDIUM | SV-252156 | Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled." # command: true # register: result # changed_when: no @@ -232,9 +232,9 @@ # tags: # - cat2 # - medium -# - V-252156 +# - SV-252156 -# - name: "MEDIUM | V-252157 | MongoDB must uniquely identify and authenticate organizational users (or processes acting on behalf of organizational users)." +# - name: "MEDIUM | SV-252157 | MongoDB must uniquely identify and authenticate organizational users (or processes acting on behalf of organizational users)." # command: true # register: result # changed_when: no @@ -242,9 +242,9 @@ # tags: # - cat2 # - medium -# - V-252157 +# - SV-252157 -# - name: "MEDIUM | V-252161 | MongoDB must map the PKI-authenticated identity to an associated user account." +# - name: "MEDIUM | SV-252161 | MongoDB must map the PKI-authenticated identity to an associated user account." # command: true # register: result # changed_when: no @@ -252,9 +252,9 @@ # tags: # - cat2 # - medium -# - V-252161 +# - SV-252161 -# - name: "MEDIUM | V-252163 | MongoDB must uniquely identify and authenticate non-organizational users (or processes acting on behalf of non-organizational users)." +# - name: "MEDIUM | SV-252163 | MongoDB must uniquely identify and authenticate non-organizational users (or processes acting on behalf of non-organizational users)." # command: true # register: result # changed_when: no @@ -262,9 +262,9 @@ # tags: # - cat2 # - medium -# - V-252163 +# - SV-252163 -# - name: "MEDIUM | V-252164 | MongoDB must maintain the authenticity of communications sessions by guarding against man-in-the-middle attacks that guess at Session ID values." +# - name: "MEDIUM | SV-252164 | MongoDB must maintain the authenticity of communications sessions by guarding against man-in-the-middle attacks that guess at Session ID values." # command: true # register: result # changed_when: no @@ -272,9 +272,9 @@ # tags: # - cat2 # - medium -# - V-252164 +# - SV-252164 -# - name: "MEDIUM | V-252166 | Database contents must be protected from unauthorized and unintended information transfer by enforcement of a data-transfer policy." +# - name: "MEDIUM | SV-252166 | Database contents must be protected from unauthorized and unintended information transfer by enforcement of a data-transfer policy." # command: true # register: result # changed_when: no @@ -282,9 +282,9 @@ # tags: # - cat2 # - medium -# - V-252166 +# - SV-252166 -# - name: "MEDIUM | V-252167 | MongoDB must check the validity of all data inputs except those specifically identified by the organization." +# - name: "MEDIUM | SV-252167 | MongoDB must check the validity of all data inputs except those specifically identified by the organization." # command: true # register: result # changed_when: no @@ -292,9 +292,9 @@ # tags: # - cat2 # - medium -# - V-252167 +# - SV-252167 -# - name: "MEDIUM | V-252168 | MongoDB must provide non-privileged users with error messages that provide information necessary for corrective actions without revealing information that could be exploited by adversaries." +# - name: "MEDIUM | SV-252168 | MongoDB must provide non-privileged users with error messages that provide information necessary for corrective actions without revealing information that could be exploited by adversaries." # command: true # register: result # changed_when: no @@ -302,9 +302,9 @@ # tags: # - cat2 # - medium -# - V-252168 +# - SV-252168 -# - name: "MEDIUM | V-252169 | MongoDB must reveal detailed error messages only to the ISSO, ISSM, SA, and DBA." +# - name: "MEDIUM | SV-252169 | MongoDB must reveal detailed error messages only to the ISSO, ISSM, SA, and DBA." # command: true # register: result # changed_when: no @@ -312,9 +312,9 @@ # tags: # - cat2 # - medium -# - V-252169 +# - SV-252169 -# - name: "MEDIUM | V-252170 | MongoDB must automatically terminate a user session after organization-defined conditions or trigger events requiring session disconnect." +# - name: "MEDIUM | SV-252170 | MongoDB must automatically terminate a user session after organization-defined conditions or trigger events requiring session disconnect." # command: true # register: result # changed_when: no @@ -322,9 +322,9 @@ # tags: # - cat2 # - medium -# - V-252170 +# - SV-252170 -# - name: "MEDIUM | V-252171 | MongoDB must utilize centralized management of the content captured in audit records generated by all components of MongoDB." +# - name: "MEDIUM | SV-252171 | MongoDB must utilize centralized management of the content captured in audit records generated by all components of MongoDB." # command: true # register: result # changed_when: no @@ -332,9 +332,9 @@ # tags: # - cat2 # - medium -# - V-252171 +# - SV-252171 -# - name: "MEDIUM | V-252172 | MongoDB must allocate audit record storage capacity in accordance with site audit record storage requirements." +# - name: "MEDIUM | SV-252172 | MongoDB must allocate audit record storage capacity in accordance with site audit record storage requirements." # command: true # register: result # changed_when: no @@ -342,9 +342,9 @@ # tags: # - cat2 # - medium -# - V-252172 +# - SV-252172 -# - name: "MEDIUM | V-252173 | MongoDB must provide a warning to appropriate support staff when allocated audit record storage volume reaches 75 percent of maximum audit record storage capacity." +# - name: "MEDIUM | SV-252173 | MongoDB must provide a warning to appropriate support staff when allocated audit record storage volume reaches 75 percent of maximum audit record storage capacity." # command: true # register: result # changed_when: no @@ -352,9 +352,9 @@ # tags: # - cat2 # - medium -# - V-252173 +# - SV-252173 -# - name: "MEDIUM | V-252174 | MongoDB must prohibit user installation of logic modules (stored procedures, functions, triggers, views, etc.) without explicit privileged status." +# - name: "MEDIUM | SV-252174 | MongoDB must prohibit user installation of logic modules (stored procedures, functions, triggers, views, etc.) without explicit privileged status." # command: true # register: result # changed_when: no @@ -362,9 +362,9 @@ # tags: # - cat2 # - medium -# - V-252174 +# - SV-252174 -# - name: "MEDIUM | V-252175 | MongoDB must enforce access restrictions associated with changes to the configuration of MongoDB or database(s)." +# - name: "MEDIUM | SV-252175 | MongoDB must enforce access restrictions associated with changes to the configuration of MongoDB or database(s)." # command: true # register: result # changed_when: no @@ -372,9 +372,9 @@ # tags: # - cat2 # - medium -# - V-252175 +# - SV-252175 -# - name: "MEDIUM | V-252176 | MongoDB must require users to reauthenticate when organization-defined circumstances or situations require reauthentication." +# - name: "MEDIUM | SV-252176 | MongoDB must require users to reauthenticate when organization-defined circumstances or situations require reauthentication." # command: true # register: result # changed_when: no @@ -382,9 +382,9 @@ # tags: # - cat2 # - medium -# - V-252176 +# - SV-252176 -# - name: "MEDIUM | V-252177 | MongoDB must prohibit the use of cached authenticators after an organization-defined time period." +# - name: "MEDIUM | SV-252177 | MongoDB must prohibit the use of cached authenticators after an organization-defined time period." # command: true # register: result # changed_when: no @@ -392,9 +392,9 @@ # tags: # - cat2 # - medium -# - V-252177 +# - SV-252177 -# - name: "MEDIUM | V-252178 | MongoDB must only accept end entity certificates issued by DoD PKI or DoD-approved PKI Certification Authorities (CAs) for the establishment of all encrypted sessions." +# - name: "MEDIUM | SV-252178 | MongoDB must only accept end entity certificates issued by DoD PKI or DoD-approved PKI Certification Authorities (CAs) for the establishment of all encrypted sessions." # command: true # register: result # changed_when: no @@ -402,9 +402,9 @@ # tags: # - cat2 # - medium -# - V-252178 +# - SV-252178 -# - name: "MEDIUM | V-252179 | MongoDB must maintain the confidentiality and integrity of information during preparation for transmission." +# - name: "MEDIUM | SV-252179 | MongoDB must maintain the confidentiality and integrity of information during preparation for transmission." # command: true # register: result # changed_when: no @@ -412,9 +412,9 @@ # tags: # - cat2 # - medium -# - V-252179 +# - SV-252179 -# - name: "MEDIUM | V-252180 | MongoDB must maintain the confidentiality and integrity of information during reception." +# - name: "MEDIUM | SV-252180 | MongoDB must maintain the confidentiality and integrity of information during reception." # command: true # register: result # changed_when: no @@ -422,9 +422,9 @@ # tags: # - cat2 # - medium -# - V-252180 +# - SV-252180 -# - name: "MEDIUM | V-252181 | When invalid inputs are received, MongoDB must behave in a predictable and documented manner that reflects organizational and system objectives." +# - name: "MEDIUM | SV-252181 | When invalid inputs are received, MongoDB must behave in a predictable and documented manner that reflects organizational and system objectives." # command: true # register: result # changed_when: no @@ -432,9 +432,9 @@ # tags: # - cat2 # - medium -# - V-252181 +# - SV-252181 -# - name: "MEDIUM | V-252182 | When updates are applied to MongoDB software, any software components that have been replaced or made unnecessary must be removed." +# - name: "MEDIUM | SV-252182 | When updates are applied to MongoDB software, any software components that have been replaced or made unnecessary must be removed." # command: true # register: result # changed_when: no @@ -442,9 +442,9 @@ # tags: # - cat2 # - medium -# - V-252182 +# - SV-252182 -# - name: "MEDIUM | V-252183 | Security-relevant software updates to MongoDB must be installed within the time period directed by an authoritative source (e.g., IAVM, CTOs, DTMs, and STIGs)." +# - name: "MEDIUM | SV-252183 | Security-relevant software updates to MongoDB must be installed within the time period directed by an authoritative source (e.g., IAVM, CTOs, DTMs, and STIGs)." # command: true # register: result # changed_when: no @@ -452,9 +452,9 @@ # tags: # - cat2 # - medium -# - V-252183 +# - SV-252183 -# - name: "MEDIUM | V-252185 | MongoDB must be configured in accordance with the security configuration settings based on DoD security configuration and implementation guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs." +# - name: "MEDIUM | SV-252185 | MongoDB must be configured in accordance with the security configuration settings based on DoD security configuration and implementation guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs." # command: true # register: result # changed_when: no @@ -462,7 +462,7 @@ # tags: # - cat2 # - medium -# - V-252185 +# - SV-252185 - name: Print the contents of mongod.conf command: cat "{{ mongod_config_path }}" diff --git a/spec/inspec_wrapper/controls/wrapper.rb b/spec/inspec_wrapper/controls/wrapper.rb deleted file mode 100644 index 0b142e1..0000000 --- a/spec/inspec_wrapper/controls/wrapper.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Use 'include_controls' to pull in dependencies defined in inspec.yml -# You can also write overrides to dependency controls in this file -# See https://docs.chef.io/inspec/profiles/#profile-dependencies - -control 'foobar' do - title 'Foobar' - desc 'This is a test control' - describe file('/tmp') do - it { should be_directory } - end -end \ No newline at end of file diff --git a/spec/inspec_wrapper/inputs.yml b/spec/inspec_wrapper/inputs.yml deleted file mode 100644 index 5a8deb9..0000000 --- a/spec/inspec_wrapper/inputs.yml +++ /dev/null @@ -1,3 +0,0 @@ -# Add overrides to the default variables in inspec.yml here. ---- -foo: "bar" \ No newline at end of file diff --git a/spec/inspec_wrapper/inspec.yml b/spec/inspec_wrapper/inspec.yml deleted file mode 100644 index cbb36b1..0000000 --- a/spec/inspec_wrapper/inspec.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: inspec-wrapper -title: Wrapper Profile for Hardening Pipeline Validation -version: 0.0.1 - -# See https://saf.mitre.org/#/validate for more STIG profiles -# depends: -# - name: rhel8 -# git: https://github.com/mitre/redhat-enterprise-linux-8-stig-baseline.git \ No newline at end of file diff --git a/spec/inspec_wrapper/using_this_profile.md b/spec/inspec_wrapper/using_this_profile.md deleted file mode 100644 index 4a11466..0000000 --- a/spec/inspec_wrapper/using_this_profile.md +++ /dev/null @@ -1,3 +0,0 @@ -# InSpec Profile - -This is a "wrapper" InSpec profile, which is intended to be used to pull in other pre-existing InSpec profiles that are applicable to your hardened target. See the `dependencies` attribute in `inspec.yml`. diff --git a/spec/mongo-inspec-profile/controls/SV-252134.rb b/spec/mongo-inspec-profile/controls/SV-252134.rb new file mode 100644 index 0000000..31f2fb2 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252134.rb @@ -0,0 +1,88 @@ +control 'SV-252134' do + title 'MongoDB must provide audit record generation for DoD-defined auditable events within all DBMS/database components.' + desc 'MongoDB must provide audit record generation capability for DoD-defined auditable events within all DBMS/database components. + +' + desc 'check', %q(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" ] } }') + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55590r855499_chk' + tag severity: 'medium' + tag gid: 'V-252134' + tag rid: 'SV-252134r855500_rule' + tag stig_id: 'MD4X-00-000100' + tag gtitle: 'SRG-APP-000089-DB-000064' + tag fix_id: 'F-55540r813783_fix' + tag satisfies: ['SRG-APP-000089-DB-000064', 'SRG-APP-000080-DB-000063', 'SRG-APP-000090-DB-000065', 'SRG-APP-000091-DB-000066', 'SRG-APP-000091-DB-000325', 'SRG-APP-000092-DB-000208', 'SRG-APP-000095-DB-000039', 'SRG-APP-000096-DB-000040', 'SRG-APP-000097-DB-000041', 'SRG-APP-000098-DB-000042', 'SRG-APP-000099-DB-000043', 'SRG-APP-000100-DB-000201', 'SRG-APP-000101-DB-000044', 'SRG-APP-000109-DB-000049', 'SRG-APP-000356-DB-000315', 'SRG-APP-000360-DB-000320', 'SRG-APP-000381-DB-000361', 'SRG-APP-000492-DB-000332', 'SRG-APP-000492-DB-000333', 'SRG-APP-000494-DB-000344', 'SRG-APP-000494-DB-000345', 'SRG-APP-000495-DB-000326', 'SRG-APP-000495-DB-000327', 'SRG-APP-000495-DB-000328', 'SRG-APP-000495-DB-000329', 'SRG-APP-000496-DB-000334', 'SRG-APP-000496-DB-000335', 'SRG-APP-000498-DB-000346', 'SRG-APP-000498-DB-000347', 'SRG-APP-000499-DB-000330', 'SRG-APP-000499-DB-000331', 'SRG-APP-000501-DB-000336', 'SRG-APP-000501-DB-000337', 'SRG-APP-000502-DB-000348', 'SRG-APP-000502-DB-000349', 'SRG-APP-000503-DB-000350', 'SRG-APP-000503-DB-000351', 'SRG-APP-000504-DB-000354', 'SRG-APP-000504-DB-000355', 'SRG-APP-000505-DB-000352', 'SRG-APP-000506-DB-000353', 'SRG-APP-000507-DB-000356', 'SRG-APP-000507-DB-000357', 'SRG-APP-000508-DB-000358', 'SRG-APP-000515-DB-000318'] + tag 'documentable' + tag cci: ['CCI-000130', 'CCI-000131', 'CCI-000132', 'CCI-000133', 'CCI-000134', 'CCI-000135', 'CCI-000140', 'CCI-000166', 'CCI-000171', 'CCI-000172', 'CCI-001464', 'CCI-001487', 'CCI-001814', 'CCI-001844', 'CCI-001851', 'CCI-001858'] + tag nist: ['AU-3 a', 'AU-3 b', 'AU-3 c', 'AU-3 d', 'AU-3 e', 'AU-3 (1)', 'AU-5 b', 'AU-10', 'AU-12 b', 'AU-12 c', 'AU-14 (1)', 'AU-3 f', 'CM-5 (1)', 'AU-3 (2)', 'AU-4 (1)', 'AU-5 (2)'] + + describe yaml('/etc/mongod.conf.orig') do + its(['net','tls','mode']){should eq "requireTLS"} + its(['net','tls','certificateKeyFile']){should eq "/etc/ssl/mongodb.pem"} + its(['net','tls','CAFile']){should eq "/etc/ssl/caToValidateClientCertificates.pem"} + its(['net','tls','allowInvalidCertificates']){should eq false} + its(['net','tls','allowConnectionsWithoutCertificates']){should eq false} + end + +end diff --git a/spec/mongo-inspec-profile/controls/SV-252135.rb b/spec/mongo-inspec-profile/controls/SV-252135.rb new file mode 100644 index 0000000..561e556 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252135.rb @@ -0,0 +1,103 @@ +control 'SV-252135' do + title 'The audit information produced by MongoDB must be protected from unauthorized access.' + desc 'If audit data were to become compromised, then competent forensic analysis and discovery of the true source of potentially malicious system activity is difficult, if not impossible, to achieve. In addition, access to audit records provides information an attacker could potentially use to his or her advantage. + +To ensure the veracity of audit data, the information system and/or the application must protect audit information from any and all unauthorized access. This includes read, write, copy, etc. + +This requirement can be achieved through multiple methods which will depend upon system architecture and design. Some commonly employed methods include ensuring log files enjoy the proper file system permissions utilizing file system protections and limiting log data location. + +Additionally, applications with user interfaces to audit records should not allow for the unfettered manipulation of or access to those records via the application. If the application provides access to the audit data, the application becomes accountable for ensuring that audit information is protected from unauthorized access. + +Audit information includes all information (e.g., audit records, audit settings, and audit reports) needed to successfully audit information system activity. + +' + desc 'check', "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: -" + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55591r813785_chk' + tag severity: 'medium' + tag gid: 'V-252135' + tag rid: 'SV-252135r813787_rule' + tag stig_id: 'MD4X-00-000200' + tag gtitle: 'SRG-APP-000118-DB-000059' + tag fix_id: 'F-55541r813786_fix' + tag satisfies: ['SRG-APP-000118-DB-000059', 'SRG-APP-000119-DB-000060', 'SRG-APP-000120-DB-000061'] + tag 'documentable' + tag cci: ['CCI-000162', 'CCI-000163', 'CCI-000164'] + tag nist: ['AU-9 a', 'AU-9 a', 'AU-9 a'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252136.rb b/spec/mongo-inspec-profile/controls/SV-252136.rb new file mode 100644 index 0000000..3ff2c55 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252136.rb @@ -0,0 +1,76 @@ +control 'SV-252136' do + title 'MongoDB must protect its audit features from unauthorized access.' + desc 'Protecting audit data also includes identifying and protecting the tools used to view and manipulate log data. + +Depending upon the log format and application, system and application log tools may provide the only means to manipulate and manage application and system log data. It is, therefore, imperative that access to audit tools be controlled and protected from unauthorized access. + +Applications providing tools to interface with audit data will leverage user permissions and roles identifying the user accessing the tools and the corresponding rights the user enjoys in order make access decisions regarding the access to audit tools. + +Audit tools include, but are not limited to, OS-provided audit tools, vendor-provided audit tools, and open source audit tools needed to successfully view and manipulate audit information system activity and records. + +If an attacker were to gain access to audit tools, they could analyze audit logs for system weaknesses or weaknesses in the auditing itself. An attacker could also manipulate logs to hide evidence of malicious activity. + +' + desc 'check', '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.' + desc 'fix', '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: -' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55592r813788_chk' + tag severity: 'medium' + tag gid: 'V-252136' + tag rid: 'SV-252136r813790_rule' + tag stig_id: 'MD4X-00-000300' + tag gtitle: 'SRG-APP-000121-DB-000202' + tag fix_id: 'F-55542r813789_fix' + tag satisfies: ['SRG-APP-000121-DB-000202', 'SRG-APP-000122-DB-000203', 'SRG-APP-000123-DB-000204'] + tag 'documentable' + tag cci: ['CCI-001493', 'CCI-001494', 'CCI-001495'] + tag nist: ['AU-9 a', 'AU-9', 'AU-9'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252137.rb b/spec/mongo-inspec-profile/controls/SV-252137.rb new file mode 100644 index 0000000..0efd645 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252137.rb @@ -0,0 +1,39 @@ +control 'SV-252137' do + title 'Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled.' + desc 'Information systems are capable of providing a wide variety of functions and services. Some of the functions and services, provided by default, may not be necessary to support essential organizational operations (e.g., key missions, functions). + +It is detrimental for software products to provide, or install by default, functionality exceeding requirements or mission objectives. + +DBMSs must adhere to the principles of least functionality by providing only essential capabilities. + +Unused, unnecessary DBMS components increase the attack vector for MongoDB by introducing additional targets for attack. By minimizing the services and applications installed on the system, the number of potential vulnerabilities is reduced. Components of the system that are unused and cannot be uninstalled must be disabled. The techniques available for disabling components will vary by DBMS product, OS, and the nature of the component and may include DBMS configuration settings, OS service settings, OS file access security, and DBMS user/role permissions.' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55593r813791_chk' + tag severity: 'medium' + tag gid: 'V-252137' + tag rid: 'SV-252137r813793_rule' + tag stig_id: 'MD4X-00-000400' + tag gtitle: 'SRG-APP-000141-DB-000092' + tag fix_id: 'F-55543r813792_fix' + tag 'documentable' + tag cci: ['CCI-000381'] + tag nist: ['CM-7 a'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252138.rb b/spec/mongo-inspec-profile/controls/SV-252138.rb new file mode 100644 index 0000000..6d57849 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252138.rb @@ -0,0 +1,49 @@ +control 'SV-252138' do + title 'Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled.' + desc 'Information systems are capable of providing a wide variety of functions and services. Some of the functions and services, provided by default, may not be necessary to support essential organizational operations (e.g., key missions, functions). + +It is detrimental for software products to provide, or install by default, functionality exceeding requirements or mission objectives. + +DBMSs must adhere to the principles of least functionality by providing only essential capabilities. + +Unused, unnecessary DBMS components increase the attack vector for MongoDB by introducing additional targets for attack. By minimizing the services and applications installed on the system, the number of potential vulnerabilities is reduced. Components of the system that are unused and cannot be uninstalled must be disabled. The techniques available for disabling components will vary by DBMS product, OS, and the nature of the component and may include DBMS configuration settings, OS service settings, OS file access security, and DBMS user/role permissions.' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55594r816977_chk' + tag severity: 'medium' + tag gid: 'V-252138' + tag rid: 'SV-252138r816978_rule' + tag stig_id: 'MD4X-00-000500' + tag gtitle: 'SRG-APP-000142-DB-000094' + tag fix_id: 'F-55544r813795_fix' + tag 'documentable' + tag cci: ['CCI-000382'] + tag nist: ['CM-7 b'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252139.rb b/spec/mongo-inspec-profile/controls/SV-252139.rb new file mode 100644 index 0000000..7dbaaeb --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252139.rb @@ -0,0 +1,58 @@ +control 'SV-252139' do + title 'If passwords are used for authentication, MongoDB must transmit only encrypted representations of passwords.' + desc 'The DoD standard for authentication is DoD-approved PKI certificates. + +Authentication based on User ID and Password may be used only when it is not possible to employ a PKI certificate, and requires AO approval. + +In such cases, passwords need to be protected at all times, and encryption is the standard method for protecting passwords during transmission. + +DBMS passwords sent in clear text format across the network are vulnerable to discovery by unauthorized users. Disclosure of passwords may easily lead to unauthorized access to the database. + +' + desc 'check', '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.' + desc 'fix', '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/' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55595r813797_chk' + tag severity: 'high' + tag gid: 'V-252139' + tag rid: 'SV-252139r863317_rule' + tag stig_id: 'MD4X-00-000600' + tag gtitle: 'SRG-APP-000172-DB-000075' + tag fix_id: 'F-55545r863316_fix' + tag satisfies: ['SRG-APP-000172-DB-000075', 'SRG-APP-000175-DB-000067'] + tag 'documentable' + tag cci: ['CCI-000197', 'CCI-000185'] + tag nist: ['IA-5 (1) (c)', 'IA-5 (2) (b) (1)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252140.rb b/spec/mongo-inspec-profile/controls/SV-252140.rb new file mode 100644 index 0000000..65d73d8 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252140.rb @@ -0,0 +1,67 @@ +control 'SV-252140' do + title 'MongoDB must uniquely identify and authenticate non-organizational users (or processes acting on behalf of non-organizational users).' + desc 'Non-organizational users include all information system users other than organizational users, which include organizational employees or individuals the organization deems to have equivalent status of employees (e.g., contractors, guest researchers, individuals from allied nations). + +Non-organizational users must be uniquely identified and authenticated for all accesses other than those accesses explicitly identified and documented by the organization when related to the use of anonymous access, such as accessing a web server. + +Accordingly, a risk assessment is used in determining the authentication needs of the organization. + +Scalability, practicality, and security are simultaneously considered in balancing the need to ensure ease of use for access to federal information and information systems with the need to protect and adequately mitigate risk to organizational operations, organizational assets, individuals, other organizations, and the Nation.' + desc 'check', "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." + desc 'fix', "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 } )" + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55596r813800_chk' + tag severity: 'medium' + tag gid: 'V-252140' + tag rid: 'SV-252140r813802_rule' + tag stig_id: 'MD4X-00-000700' + tag gtitle: 'SRG-APP-000211-DB-000122' + tag fix_id: 'F-55546r813801_fix' + tag 'documentable' + tag cci: ['CCI-001082'] + tag nist: ['SC-2'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252141.rb b/spec/mongo-inspec-profile/controls/SV-252141.rb new file mode 100644 index 0000000..810f09c --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252141.rb @@ -0,0 +1,49 @@ +control 'SV-252141' do + title 'MongoDB must fail to a secure state if system initialization fails, shutdown fails, or aborts fail.' + desc 'Failure to a known state can address safety or security in accordance with the mission/business needs of the organization. + +Failure to a known secure state helps prevent a loss of confidentiality, integrity, or availability in the event of a failure of the information system or a component of the system. + +Failure to a known safe state helps prevent systems from failing to a state that may cause loss of data or unauthorized access to system resources. Systems that fail suddenly and with no incorporated failure state planning may leave the hosting system available but with a reduced security protection capability. Preserving information system state data also facilitates system restart and return to the operational mode of the organization with less disruption of mission/business processes. + +Databases must fail to a known consistent state. Transactions must be successfully completed or rolled back. + +In general, security mechanisms should be designed so that a failure will follow the same execution path as disallowing the operation. For example, application security methods, such as isAuthorized(), isAuthenticated(), and validate(), should all return false if there is an exception during processing. If security controls can throw exceptions, they must be very clear about exactly what that condition means. + +Abort refers to stopping a program or function before it has finished naturally. The term abort refers to both requested and unexpected terminations. + +' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55597r813803_chk' + tag severity: 'medium' + tag gid: 'V-252141' + tag rid: 'SV-252141r813805_rule' + tag stig_id: 'MD4X-00-000800' + tag gtitle: 'SRG-APP-000225-DB-000153' + tag fix_id: 'F-55547r813804_fix' + tag satisfies: ['SRG-APP-000225-DB-000153', 'SRG-APP-000226-DB-000147'] + tag 'documentable' + tag cci: ['CCI-001190', 'CCI-001665'] + tag nist: ['SC-24', 'SC-24'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252142.rb b/spec/mongo-inspec-profile/controls/SV-252142.rb new file mode 100644 index 0000000..a084bff --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252142.rb @@ -0,0 +1,58 @@ +control 'SV-252142' do + title 'MongoDB must prevent unauthorized and unintended information transfer via shared system resources.' + desc 'The purpose of this control is to prevent information, including encrypted representations of information, produced by the actions of a prior user/role (or the actions of a process acting on behalf of a prior user/role) from being available to any current user/role (or current process) that obtains access to a shared system resource (e.g., registers, main memory, secondary storage) after the resource has been released back to the information system. Control of information in shared resources is also referred to as object reuse. + +' + desc 'check', '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.' + desc 'fix', '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' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55598r817008_chk' + tag severity: 'medium' + tag gid: 'V-252142' + tag rid: 'SV-252142r817009_rule' + tag stig_id: 'MD4X-00-000900' + tag gtitle: 'SRG-APP-000243-DB-000373' + tag fix_id: 'F-55548r813807_fix' + tag satisfies: ['SRG-APP-000243-DB-000373', 'SRG-APP-000243-DB-000374'] + tag 'documentable' + tag cci: ['CCI-001090'] + tag nist: ['SC-4'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252143.rb b/spec/mongo-inspec-profile/controls/SV-252143.rb new file mode 100644 index 0000000..79b1e4c --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252143.rb @@ -0,0 +1,35 @@ +control 'SV-252143' do + title 'MongoDB and associated applications must reserve the use of dynamic code execution for situations that require it.' + desc 'With respect to database management systems, one class of threat is known as SQL Injection, or more generally, code injection. It takes advantage of the dynamic execution capabilities of various programming languages, including dialects of SQL. In such cases, the attacker deduces the manner in which SQL statements are being processed, either from inside knowledge or by observing system behavior in response to invalid inputs. When the attacker identifies scenarios where SQL queries are being assembled by application code (which may be within the database or separate from it) and executed dynamically, the attacker is then able to craft input strings that subvert the intent of the query. Potentially, the attacker can gain unauthorized access to data, including security settings, and severely corrupt or destroy the database. + +The principal protection against code injection is not to use dynamic execution except where it provides necessary functionality that cannot be utilized otherwise. Use strongly typed data items rather than general-purpose strings as input parameters to task-specific, pre-compiled stored procedures and functions (and triggers). + +This calls for inspection of application source code, which will require collaboration with the application developers. It is recognized that in many cases, the database administrator (DBA) is organizationally separate from the application developers, and may have limited, if any, access to source code. Nevertheless, protections of this type are so important to the secure operation of databases that they must not be ignored. At a minimum, the DBA must attempt to obtain assurances from the development organization that this issue has been addressed, and must document what has been discovered. + +' + desc 'check', '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' + desc 'fix', 'Disable the javascriptEnabled option. + +Edit the %MongoDB configuration file% (default location: /etc/mongod.conf) to include the following: + +security: + javascriptEnabled: false' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55599r813809_chk' + tag severity: 'medium' + tag gid: 'V-252143' + tag rid: 'SV-252143r813811_rule' + tag stig_id: 'MD4X-00-001000' + tag gtitle: 'SRG-APP-000251-DB-000391' + tag fix_id: 'F-55549r813810_fix' + tag satisfies: ['SRG-APP-000251-DB-000391', 'SRG-APP-000251-DB-000392'] + tag 'documentable' + tag cci: ['CCI-001310'] + tag nist: ['SI-10'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252144.rb b/spec/mongo-inspec-profile/controls/SV-252144.rb new file mode 100644 index 0000000..9bbf536 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252144.rb @@ -0,0 +1,125 @@ +control 'SV-252144' do + title 'MongoDB must associate organization-defined types of security labels having organization-defined security label values with information in storage and transmission.' + desc 'Without the association of security labels to information, there is no basis for MongoDB to make security-related access-control decisions. + +Security labels are abstractions representing the basic properties or characteristics of an entity (e.g., subjects and objects) with respect to safeguarding information. + +These labels are typically associated with internal data structures (e.g., tables, rows) within the database and are used to enable the implementation of access control and flow control policies, reflect special dissemination, handling, or distribution instructions, or support other aspects of the information security policy. + +One example includes marking data as classified or CUI. These security labels may be assigned manually or during data processing, but, either way, it is imperative these assignments are maintained while the data is in storage. If the security labels are lost when the data is stored, there is the risk of a data compromise. + +The mechanism used to support security labeling may be a feature of MongoDB product, a third-party product, or custom application code. + +' + desc 'check', '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"] + } +} +] +)' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55600r855501_chk' + tag severity: 'medium' + tag gid: 'V-252144' + tag rid: 'SV-252144r855503_rule' + tag stig_id: 'MD4X-00-001100' + tag gtitle: 'SRG-APP-000311-DB-000308' + tag fix_id: 'F-55550r855502_fix' + tag satisfies: ['SRG-APP-000311-DB-000308', 'SRG-APP-000313-DB-000309', 'SRG-APP-000314-DB-000310'] + tag 'documentable' + tag cci: ['CCI-002262', 'CCI-002263', 'CCI-002264'] + tag nist: ['AC-16 a', 'AC-16 a', 'AC-16 a'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252145.rb b/spec/mongo-inspec-profile/controls/SV-252145.rb new file mode 100644 index 0000000..5a0b98f --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252145.rb @@ -0,0 +1,57 @@ +control 'SV-252145' do + title 'MongoDB must enforce discretionary access control policies, as defined by the data owner, over defined subjects and objects.' + desc 'Discretionary Access Control (DAC) is based on the notion that individual users are "owners" of objects and therefore have discretion over who should be authorized to access the object and in which mode (e.g., read or write). Ownership is usually acquired as a consequence of creating the object or via specified ownership assignment. DAC allows the owner to determine who will have access to objects they control. An example of DAC includes user-controlled table permissions. + +When discretionary access control policies are implemented, subjects are not constrained with regard to what actions they can take with information for which they have already been granted access. Thus, subjects that have been granted access to information are not prevented from passing (i.e., the subjects have the discretion to pass) the information to other subjects or objects. + +A subject that is constrained in its operation by Mandatory Access Control policies is still able to operate under the less rigorous constraints of this requirement. Thus, while Mandatory Access Control imposes constraints preventing a subject from passing information to another subject operating at a different sensitivity level, this requirement permits the subject to pass the information to any subject at the same sensitivity level. + +The policy is bound by the information system boundary. Once the information is passed outside of the control of the information system, additional means may be required to ensure the constraints remain in effect. While the older, more traditional definitions of discretionary access control require identity-based access control, that limitation is not required for this use of discretionary access control. + +' + desc 'check', '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' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55601r813815_chk' + tag severity: 'medium' + tag gid: 'V-252145' + tag rid: 'SV-252145r855504_rule' + tag stig_id: 'MD4X-00-001200' + tag gtitle: 'SRG-APP-000328-DB-000301' + tag fix_id: 'F-55551r813816_fix' + tag satisfies: ['SRG-APP-000328-DB-000301', 'SRG-APP-000340-DB-000304'] + tag 'documentable' + tag cci: ['CCI-002165', 'CCI-002235'] + tag nist: ['AC-3 (4)', 'AC-6 (10)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252146.rb b/spec/mongo-inspec-profile/controls/SV-252146.rb new file mode 100644 index 0000000..8cab6a0 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252146.rb @@ -0,0 +1,56 @@ +control 'SV-252146' do + title 'MongoDB must use NIST FIPS 140-2 or 140-3 validated cryptographic modules for cryptographic operations.' + desc 'The use of weak or not validated cryptographic algorithms undermines the purposes of utilizing encryption and digital signatures to protect data. Weak algorithms can be easily broken and not validated cryptographic modules may not implement algorithms correctly. Unapproved cryptographic modules or algorithms should not be relied on for authentication, confidentiality, or integrity. Weak cryptography could allow an attacker to gain access to and modify data stored in the database as well as the administration settings of MongoDB. + +Applications, including DBMSs, utilizing cryptography are required to use approved NIST FIPS 140-2 or 140-3 validated cryptographic modules that meet the requirements of applicable federal laws, Executive Orders, directives, policies, regulations, standards, and guidance. + +NSA Type-X (where X=1, 2, 3, 4) products are NSA-certified, hardware-based encryption modules. + +The standard for validating cryptographic modules will transition to the NIST FIPS 140-3 publication. + +FIPS 140-2 modules can remain active for up to five years after validation or until September 21, 2026, when the FIPS 140-2 validations will be moved to the historical list. Even on the historical list, CMVP supports the purchase and use of these modules for existing systems. While Federal Agencies decide when they move to FIPS 140-3 only modules, purchasers are reminded that for several years there may be a limited selection of FIPS 140-3 modules from which to choose. CMVP recommends purchasers consider all modules that appear on the Validated Modules Search Page: +https://csrc.nist.gov/projects/cryptographic-module-validation-program/validated-modules + +More information on the FIPS 140-3 transition can be found here: +https://csrc.nist.gov/Projects/fips-140-3-transition-effort/ + +' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55602r813818_chk' + tag severity: 'high' + tag gid: 'V-252146' + tag rid: 'SV-252146r863331_rule' + tag stig_id: 'MD4X-00-001300' + tag gtitle: 'SRG-APP-000179-DB-000114' + tag fix_id: 'F-55552r863330_fix' + tag satisfies: ['SRG-APP-000179-DB-000114', 'SRG-APP-000416-DB-000380', 'SRG-APP-000514-DB-000381', 'SRG-APP-000514-DB-000382', 'SRG-APP-000514-\nDB-000383'] + tag 'documentable' + tag cci: ['CCI-002450', 'CCI-000803'] + tag nist: ['SC-13 b', 'IA-7'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252147.rb b/spec/mongo-inspec-profile/controls/SV-252147.rb new file mode 100644 index 0000000..6264759 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252147.rb @@ -0,0 +1,45 @@ +control 'SV-252147' do + title 'MongoDB must implement cryptographic mechanisms to prevent unauthorized modification of organization-defined information at rest (to include, at a minimum, PII and classified information) on organization-defined information system components.' + desc 'DBMSs handling data requiring "data at rest" protections must employ cryptographic mechanisms to prevent unauthorized disclosure and modification of the information at rest. These cryptographic mechanisms may be native to MongoDB or implemented via additional software or operating system/file system settings, as appropriate to the situation. + +Selection of a cryptographic mechanism is based on the need to protect the integrity of organizational information. The strength of the mechanism is commensurate with the security category and/or classification of the information. Organizations have the flexibility to either encrypt all information on storage devices (i.e., full disk encryption) or encrypt specific data structures (e.g., files, records, or fields). + +The decision whether and what to encrypt rests with the data owner and is also influenced by the physical measures taken to secure the equipment and media on which the information resides. + +' + desc 'check', '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.' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55603r813821_chk' + tag severity: 'medium' + tag gid: 'V-252147' + tag rid: 'SV-252147r855506_rule' + tag stig_id: 'MD4X-00-001400' + tag gtitle: 'SRG-APP-000428-DB-000386' + tag fix_id: 'F-55553r813822_fix' + tag satisfies: ['SRG-APP-000428-DB-000386', 'SRG-APP-000429-DB-000387'] + tag 'documentable' + tag cci: ['CCI-002475', 'CCI-002476'] + tag nist: ['SC-28 (1)', 'SC-28 (1)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252148.rb b/spec/mongo-inspec-profile/controls/SV-252148.rb new file mode 100644 index 0000000..bfe1149 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252148.rb @@ -0,0 +1,39 @@ +control 'SV-252148' do + title 'MongoDB must limit the total number of concurrent connections to the database.' + desc 'MongoDB must limit the total number of concurrent connections to the database.' + desc 'check', '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.' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55604r813824_chk' + tag severity: 'medium' + tag gid: 'V-252148' + tag rid: 'SV-252148r813826_rule' + tag stig_id: 'MD4X-00-001550' + tag gtitle: 'SRG-APP-000001-DB-000031' + tag fix_id: 'F-55554r813825_fix' + tag 'documentable' + tag cci: ['CCI-000054'] + tag nist: ['AC-10'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252149.rb b/spec/mongo-inspec-profile/controls/SV-252149.rb new file mode 100644 index 0000000..434db89 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252149.rb @@ -0,0 +1,50 @@ +control 'SV-252149' do + title 'MongoDB must integrate with an organization-level authentication/access mechanism providing account management and automation for all users, groups, roles, and any other principals.' + desc 'MongoDB must integrate with an organization-level authentication/access mechanism providing account management and automation for all users, groups, roles, and any other principals.' + desc 'check', '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.' + desc 'fix', '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' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55605r813827_chk' + tag severity: 'high' + tag gid: 'V-252149' + tag rid: 'SV-252149r863318_rule' + tag stig_id: 'MD4X-00-001600' + tag gtitle: 'SRG-APP-000023-DB-000001' + tag fix_id: 'F-55555r813828_fix' + tag 'documentable' + tag cci: ['CCI-000015'] + tag nist: ['AC-2 (1)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252150.rb b/spec/mongo-inspec-profile/controls/SV-252150.rb new file mode 100644 index 0000000..7010a68 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252150.rb @@ -0,0 +1,41 @@ +control 'SV-252150' do + title 'MongoDB must enforce approved authorizations for logical access to information and system resources in accordance with applicable access control policies.' + desc 'MongoDB must enforce approved authorizations for logical access to information and system resources in accordance with applicable access control policies.' + desc 'check', '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 + } +)' + desc 'fix', '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/' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55606r813830_chk' + tag severity: 'high' + tag gid: 'V-252150' + tag rid: 'SV-252150r863319_rule' + tag stig_id: 'MD4X-00-001700' + tag gtitle: 'SRG-APP-000033-DB-000084' + tag fix_id: 'F-55556r813831_fix' + tag 'documentable' + tag cci: ['CCI-000213'] + tag nist: ['AC-3'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252151.rb b/spec/mongo-inspec-profile/controls/SV-252151.rb new file mode 100644 index 0000000..8e6477c --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252151.rb @@ -0,0 +1,30 @@ +control 'SV-252151' do + title 'MongoDB must limit privileges to change software modules, to include stored procedures, functions and triggers, and links to software external to MongoDB.' + desc 'If the system were to allow any user to make changes to software libraries, then those changes might be implemented without undergoing the appropriate testing and approvals that are part of a robust change management process. + +Accordingly, only qualified and authorized individuals must be allowed to obtain access to information system components for purposes of initiating changes, including upgrades and modifications. + +Unmanaged changes that occur to the database software libraries or configuration can lead to unauthorized or compromised installations.' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55607r813833_chk' + tag severity: 'medium' + tag gid: 'V-252151' + tag rid: 'SV-252151r813835_rule' + tag stig_id: 'MD4X-00-002000' + tag gtitle: 'SRG-APP-000133-DB-000179' + tag fix_id: 'F-55557r813834_fix' + tag 'documentable' + tag cci: ['CCI-001499'] + tag nist: ['CM-5 (6)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252152.rb b/spec/mongo-inspec-profile/controls/SV-252152.rb new file mode 100644 index 0000000..11248a9 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252152.rb @@ -0,0 +1,26 @@ +control 'SV-252152' do + title 'MongoDB software installation account must be restricted to authorized users.' + desc 'When dealing with change control issues, it should be noted any changes to the hardware, software, and/or firmware components of the information system and/or application can have significant effects on the overall security of the system. + +If the system were to allow any user to make changes to software libraries, then those changes might be implemented without undergoing the appropriate testing and approvals that are part of a robust change management process. + +Accordingly, only qualified and authorized individuals must be allowed access to information system components for purposes of initiating changes, including upgrades and modifications. + +DBA and other privileged administrative or application owner accounts are granted privileges that allow actions that can have a great impact on database security and operation. It is especially important to grant privileged access to only those persons who are qualified and authorized to use them.' + desc 'check', '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.' + desc 'fix', 'Develop, document, and implement procedures to restrict and track use of the DBMS software installation account.' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55608r813836_chk' + tag severity: 'high' + tag gid: 'V-252152' + tag rid: 'SV-252152r863320_rule' + tag stig_id: 'MD4X-00-002100' + tag gtitle: 'SRG-APP-000133-DB-000198' + tag fix_id: 'F-55558r813837_fix' + tag 'documentable' + tag cci: ['CCI-001499'] + tag nist: ['CM-5 (6)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252153.rb b/spec/mongo-inspec-profile/controls/SV-252153.rb new file mode 100644 index 0000000..bf43bce --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252153.rb @@ -0,0 +1,45 @@ +control 'SV-252153' do + title 'Database software, including DBMS configuration files, must be stored in dedicated directories, or DASD pools, separate from the host OS and other applications.' + desc "When dealing with change control issues, it should be noted any changes to the hardware, software, and/or firmware components of the information system and/or application can potentially have significant effects on the overall security of the system. + +Multiple applications can provide a cumulative negative effect. A vulnerability and subsequent exploit to one application can lead to an exploit of other applications sharing the same security context. For example, an exploit to a web server process that leads to unauthorized administrative access to host system directories can most likely lead to a compromise of all applications hosted by the same system. Database software not installed using dedicated directories both threatens and is threatened by other hosted applications. Access controls defined for one application may by default provide access to the other application's database objects or directories. Any method that provides any level of separation of security context assists in the protection between applications." + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55609r813839_chk' + tag severity: 'medium' + tag gid: 'V-252153' + tag rid: 'SV-252153r813841_rule' + tag stig_id: 'MD4X-00-002200' + tag gtitle: 'SRG-APP-000133-DB-000199' + tag fix_id: 'F-55559r813840_fix' + tag 'documentable' + tag cci: ['CCI-001499'] + tag nist: ['CM-5 (6)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252154.rb b/spec/mongo-inspec-profile/controls/SV-252154.rb new file mode 100644 index 0000000..a543e58 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252154.rb @@ -0,0 +1,34 @@ +control 'SV-252154' do + title 'Database objects (including but not limited to tables, indexes, storage, stored procedures, functions, triggers, links to software external to MongoDB, etc.) must be owned by database/DBMS principals authorized for ownership.' + desc "Within the database, object ownership implies full privileges to the owned object, including the privilege to assign access to the owned objects to other subjects. Database functions and procedures can be coded using definer's rights. This allows anyone who utilizes the object to perform the actions if they were the owner. If not properly managed, this can lead to privileged actions being taken by unauthorized individuals. + +Conversely, if critical tables or other objects rely on unauthorized owner accounts, these objects may be lost when an account is removed." + desc 'check', '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.' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55610r813842_chk' + tag severity: 'medium' + tag gid: 'V-252154' + tag rid: 'SV-252154r813844_rule' + tag stig_id: 'MD4X-00-002300' + tag gtitle: 'SRG-APP-000133-DB-000200' + tag fix_id: 'F-55560r813843_fix' + tag 'documentable' + tag cci: ['CCI-001499'] + tag nist: ['CM-5 (6)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252155.rb b/spec/mongo-inspec-profile/controls/SV-252155.rb new file mode 100644 index 0000000..8b65f9b --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252155.rb @@ -0,0 +1,46 @@ +control 'SV-252155' do + title 'The role(s)/group(s) used to modify database structure (including but not necessarily limited to tables, indexes, storage, etc.) and logic modules (stored procedures, functions, triggers, links to software external to MongoDB, etc.) must be restricted to authorized users.' + desc 'If MongoDB were to allow any user to make changes to database structure or logic, then those changes might be implemented without undergoing the appropriate testing and approvals that are part of a robust change management process. + +Accordingly, only qualified and authorized individuals must be allowed to obtain access to information system components for purposes of initiating changes, including upgrades and modifications. + +Unmanaged changes that occur to the database software libraries or configuration can lead to unauthorized or compromised installations.' + desc 'check', '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.' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55611r813845_chk' + tag severity: 'medium' + tag gid: 'V-252155' + tag rid: 'SV-252155r813938_rule' + tag stig_id: 'MD4X-00-002400' + tag gtitle: 'SRG-APP-000133-DB-000362' + tag fix_id: 'F-55561r813846_fix' + tag 'documentable' + tag cci: ['CCI-001499'] + tag nist: ['CM-5 (6)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252156.rb b/spec/mongo-inspec-profile/controls/SV-252156.rb new file mode 100644 index 0000000..ac6bde8 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252156.rb @@ -0,0 +1,41 @@ +control 'SV-252156' do + title 'Unused database components that are integrated in MongoDB and cannot be uninstalled must be disabled.' + desc 'Information systems are capable of providing a wide variety of functions and services. Some of the functions and services, provided by default, may not be necessary to support essential organizational operations (e.g., key missions, functions). + +It is detrimental for software products to provide, or install by default, functionality exceeding requirements or mission objectives. + +DBMSs must adhere to the principles of least functionality by providing only essential capabilities. + +Unused, unnecessary DBMS components increase the attack vector for MongoDB by introducing additional targets for attack. By minimizing the services and applications installed on the system, the number of potential vulnerabilities is reduced. Components of the system that are unused and cannot be uninstalled must be disabled. The techniques available for disabling components will vary by DBMS product, OS, and the nature of the component and may include DBMS configuration settings, OS service settings, OS file access security, and DBMS user/role permissions.' + desc 'check', '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.' + desc 'fix', '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' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55612r813848_chk' + tag severity: 'medium' + tag gid: 'V-252156' + tag rid: 'SV-252156r813850_rule' + tag stig_id: 'MD4X-00-002600' + tag gtitle: 'SRG-APP-000141-DB-000091' + tag fix_id: 'F-55562r813849_fix' + tag 'documentable' + tag cci: ['CCI-000381'] + tag nist: ['CM-7 a'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252157.rb b/spec/mongo-inspec-profile/controls/SV-252157.rb new file mode 100644 index 0000000..25d0f49 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252157.rb @@ -0,0 +1,49 @@ +control 'SV-252157' do + title 'MongoDB must uniquely identify and authenticate organizational users (or processes acting on behalf of organizational users).' + desc 'To assure accountability and prevent unauthenticated access, organizational users must be identified and authenticated to prevent potential misuse and compromise of the system. + +Organizational users include organizational employees or individuals the organization deems to have equivalent status of employees (e.g., contractors). Organizational users (and any processes acting on behalf of users) must be uniquely identified and authenticated for all accesses, except the following: + +(i) Accesses explicitly identified and documented by the organization. Organizations document specific user actions that can be performed on the information system without identification or authentication; and +(ii) Accesses that occur through authorized use of group authenticators without individual authentication. Organizations may require unique identification of individuals using shared accounts, for detailed accountability of individual activity.' + desc 'check', '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.' + desc 'fix', '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%.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55613r813851_chk' + tag severity: 'medium' + tag gid: 'V-252157' + tag rid: 'SV-252157r813853_rule' + tag stig_id: 'MD4X-00-002800' + tag gtitle: 'SRG-APP-000148-DB-000103' + tag fix_id: 'F-55563r813852_fix' + tag 'documentable' + tag cci: ['CCI-000764'] + tag nist: ['IA-2'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252158.rb b/spec/mongo-inspec-profile/controls/SV-252158.rb new file mode 100644 index 0000000..acbd2f4 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252158.rb @@ -0,0 +1,36 @@ +control 'SV-252158' do + title 'If passwords are used for authentication, MongoDB must implement LDAP or Kerberos for authentication to enforce the DoD standards for password complexity and lifetime.' + desc 'OS/enterprise authentication and identification must be used (SRG-APP-000023-DB-000001). Native DBMS authentication may be used only when circumstances make it unavoidable, and must be documented and AO-approved. + +The DoD standard for authentication is DoD-approved PKI certificates. Authentication based on User ID and Password may be used only when it is not possible to employ a PKI certificate, and requires AO approval. + +In such cases, the DoD standards for password complexity and lifetime must be implemented. DBMS products that can inherit the rules for these from the operating system or access control program (e.g., Microsoft Active Directory) must be configured to do so. For other DBMSs, the rules must be enforced using available configuration parameters or custom code. + +For MongoDB, password complexity and lifetime requirements must be enforced by an external authentication source such as LDAP, Active Directory, or Kerberos.' + desc 'check', '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.' + desc 'fix', '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/' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55614r813854_chk' + tag severity: 'high' + tag gid: 'V-252158' + tag rid: 'SV-252158r863321_rule' + tag stig_id: 'MD4X-00-002950' + tag gtitle: 'SRG-APP-000164-DB-000401' + tag fix_id: 'F-55564r813855_fix' + tag 'documentable' + tag cci: ['CCI-000192'] + tag nist: ['IA-5 (1) (a)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252159.rb b/spec/mongo-inspec-profile/controls/SV-252159.rb new file mode 100644 index 0000000..5ddf4c4 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252159.rb @@ -0,0 +1,65 @@ +control 'SV-252159' do + title 'If passwords are used for authentication, MongoDB must store only hashed, salted representations of passwords.' + desc 'The DoD standard for authentication is DoD-approved PKI certificates. + +Authentication based on User ID and Password may be used only when it is not possible to employ a PKI certificate, and requires AO approval. + +In such cases, database passwords stored in clear text, using reversible encryption, or using unsalted hashes would be vulnerable to unauthorized disclosure. Database passwords must always be in the form of one-way, salted hashes when stored internally or externally to MongoDB.' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55615r863322_chk' + tag severity: 'high' + tag gid: 'V-252159' + tag rid: 'SV-252159r863324_rule' + tag stig_id: 'MD4X-00-003000' + tag gtitle: 'SRG-APP-000171-DB-000074' + tag fix_id: 'F-55565r863323_fix' + tag 'documentable' + tag cci: ['CCI-000196'] + tag nist: ['IA-5 (1) (c)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252160.rb b/spec/mongo-inspec-profile/controls/SV-252160.rb new file mode 100644 index 0000000..9fd975c --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252160.rb @@ -0,0 +1,48 @@ +control 'SV-252160' do + title 'MongoDB must enforce authorized access to all PKI private keys stored/utilized by MongoDB.' + desc "The DoD standard for authentication is DoD-approved PKI certificates. PKI certificate-based authentication is performed by requiring the certificate holder to cryptographically prove possession of the corresponding private key. + +If the private key is stolen, an attacker can use the private key(s) to impersonate the certificate holder. In cases where MongoDB-stored private keys are used to authenticate MongoDB to the system's clients, loss of the corresponding private keys would allow an attacker to successfully perform undetected man in the middle attacks against MongoDB system and its clients. + +Both the holder of a digital certificate and the issuing authority must take careful measures to protect the corresponding private key. Private keys should always be generated and protected in FIPS 140-2 or 140-3 validated cryptographic modules. + +All access to the private key(s) of MongoDB must be restricted to authorized and authenticated users. If unauthorized users have access to one or more of MongoDB's private keys, an attacker could gain access to the key(s) and use them to impersonate the database on the network or otherwise perform unauthorized actions." + desc 'check', '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.' + desc 'fix', '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' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55616r813860_chk' + tag severity: 'high' + tag gid: 'V-252160' + tag rid: 'SV-252160r863325_rule' + tag stig_id: 'MD4X-00-003100' + tag gtitle: 'SRG-APP-000176-DB-000068' + tag fix_id: 'F-55566r813861_fix' + tag 'documentable' + tag cci: ['CCI-000186'] + tag nist: ['IA-5 (2) (a) (1)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252161.rb b/spec/mongo-inspec-profile/controls/SV-252161.rb new file mode 100644 index 0000000..1794b9b --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252161.rb @@ -0,0 +1,89 @@ +control 'SV-252161' do + title 'MongoDB must map the PKI-authenticated identity to an associated user account.' + desc 'The DoD standard for authentication is DoD-approved PKI certificates. Once a PKI certificate has been validated, it must be mapped to a DBMS user account for the authenticated identity to be meaningful to MongoDB and useful for authorization decisions.' + desc 'check', '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.' + desc 'fix', '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%)' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55617r813863_chk' + tag severity: 'medium' + tag gid: 'V-252161' + tag rid: 'SV-252161r813865_rule' + tag stig_id: 'MD4X-00-003200' + tag gtitle: 'SRG-APP-000177-DB-000069' + tag fix_id: 'F-55567r813864_fix' + tag 'documentable' + tag cci: ['CCI-000187'] + tag nist: ['IA-5 (2) (a) (2)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252162.rb b/spec/mongo-inspec-profile/controls/SV-252162.rb new file mode 100644 index 0000000..3664890 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252162.rb @@ -0,0 +1,40 @@ +control 'SV-252162' do + title 'MongoDB must obscure feedback of authentication information during the authentication process to protect the information from possible exploitation/use by unauthorized individuals.' + desc 'The DoD standard for authentication is DoD-approved PKI certificates. + +Normally, with PKI authentication, the interaction with the user for authentication will be handled by a software component separate from MongoDB, such as ActivIdentity ActivClient. However, in cases where MongoDB controls the interaction, this requirement applies. + +To prevent the compromise of authentication information such as passwords and PINs during the authentication process, the feedback from the system must not provide any information that would allow an unauthorized user to compromise the authentication mechanism. + +Obfuscation of user-provided authentication secrets when typed into the system is a method used in addressing this risk. + +Displaying asterisks when a user types in a password or a smart card PIN is an example of obscuring feedback of authentication secrets. + +This calls for review of applications, which will require collaboration with the application developers. It is recognized that in many cases, the database administrator (DBA) is organizationally separate from the application developers, and may have limited, if any, access to source code. Nevertheless, protections of this type are so important to the secure operation of databases that they must not be ignored. At a minimum, the DBA must attempt to obtain assurances from the development organization that this issue has been addressed, and must document what has been discovered.' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55618r813866_chk' + tag severity: 'high' + tag gid: 'V-252162' + tag rid: 'SV-252162r863326_rule' + tag stig_id: 'MD4X-00-003300' + tag gtitle: 'SRG-APP-000178-DB-000083' + tag fix_id: 'F-55568r813867_fix' + tag 'documentable' + tag cci: ['CCI-000206'] + tag nist: ['IA-6'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252163.rb b/spec/mongo-inspec-profile/controls/SV-252163.rb new file mode 100644 index 0000000..ec6de3d --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252163.rb @@ -0,0 +1,65 @@ +control 'SV-252163' do + title 'MongoDB must uniquely identify and authenticate non-organizational users (or processes acting on behalf of non-organizational users).' + desc 'Non-organizational users include all information system users other than organizational users, which include organizational employees or individuals the organization deems to have equivalent status of employees (e.g., contractors, guest researchers, individuals from allied nations). + +Non-organizational users must be uniquely identified and authenticated for all accesses other than those accesses explicitly identified and documented by the organization when related to the use of anonymous access, such as accessing a web server. + +Accordingly, a risk assessment is used in determining the authentication needs of the organization. + +Scalability, practicality, and security are simultaneously considered in balancing the need to ensure ease of use for access to federal information and information systems with the need to protect and adequately mitigate risk to organizational operations, organizational assets, individuals, other organizations, and the Nation.' + desc 'check', %q(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.) + desc 'fix', "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." + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55619r817010_chk' + tag severity: 'medium' + tag gid: 'V-252163' + tag rid: 'SV-252163r817011_rule' + tag stig_id: 'MD4X-00-003400' + tag gtitle: 'SRG-APP-000180-DB-000115' + tag fix_id: 'F-55569r813870_fix' + tag 'documentable' + tag cci: ['CCI-000804'] + tag nist: ['IA-8'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252164.rb b/spec/mongo-inspec-profile/controls/SV-252164.rb new file mode 100644 index 0000000..8af7f76 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252164.rb @@ -0,0 +1,39 @@ +control 'SV-252164' do + title 'MongoDB must maintain the authenticity of communications sessions by guarding against man-in-the-middle attacks that guess at Session ID values.' + desc 'One class of man-in-the-middle, or session hijacking, attack involves the adversary guessing at valid session identifiers based on patterns in identifiers already known. + +The preferred technique for thwarting guesses at Session IDs is the generation of unique session identifiers using a FIPS 140-2 or 140-3 approved random number generator. + +However, it is recognized that available DBMS products do not all implement the preferred technique yet may have other protections against session hijacking. Therefore, other techniques are acceptable, provided they are demonstrated to be effective.' + desc 'check', '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.' + desc 'fix', '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/.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55620r863327_chk' + tag severity: 'medium' + tag gid: 'V-252164' + tag rid: 'SV-252164r863328_rule' + tag stig_id: 'MD4X-00-003700' + tag gtitle: 'SRG-APP-000224-DB-000384' + tag fix_id: 'F-55570r813873_fix' + tag 'documentable' + tag cci: ['CCI-001188'] + tag nist: ['SC-23 (3)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252165.rb b/spec/mongo-inspec-profile/controls/SV-252165.rb new file mode 100644 index 0000000..07a4725 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252165.rb @@ -0,0 +1,46 @@ +control 'SV-252165' do + title 'MongoDB must protect the confidentiality and integrity of all information at rest.' + desc 'This control is intended to address the confidentiality and integrity of information at rest in non-mobile devices and covers user information and system information. Information at rest refers to the state of information when it is located on a secondary storage device (e.g., disk drive, tape drive) within an organizational information system. Applications and application users generate information throughout the course of their application use. + +User data generated, as well as application-specific configuration data, needs to be protected. Organizations may choose to employ different mechanisms to achieve confidentiality and integrity protections, as appropriate. + +If the confidentiality and integrity of application data is not protected, the data will be open to compromise and unauthorized modification.' + desc 'check', '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.' + desc 'fix', '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/' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55621r813875_chk' + tag severity: 'high' + tag gid: 'V-252165' + tag rid: 'SV-252165r863329_rule' + tag stig_id: 'MD4X-00-003800' + tag gtitle: 'SRG-APP-000231-DB-000154' + tag fix_id: 'F-55571r813876_fix' + tag 'documentable' + tag cci: ['CCI-001199'] + tag nist: ['SC-28'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252166.rb b/spec/mongo-inspec-profile/controls/SV-252166.rb new file mode 100644 index 0000000..02102c8 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252166.rb @@ -0,0 +1,28 @@ +control 'SV-252166' do + title 'Database contents must be protected from unauthorized and unintended information transfer by enforcement of a data-transfer policy.' + desc 'Applications, including DBMSs, must prevent unauthorized and unintended information transfer via shared system resources. + +Data used for the development and testing of applications often involves copying data from production. It is important that specific procedures exist for this process, to include the conditions under which such transfer may take place, where the copies may reside, and the rules for ensuring sensitive data are not exposed. + +Copies of sensitive data must not be misplaced or left in a temporary location without the proper controls.' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55622r813878_chk' + tag severity: 'medium' + tag gid: 'V-252166' + tag rid: 'SV-252166r813880_rule' + tag stig_id: 'MD4X-00-004000' + tag gtitle: 'SRG-APP-000243-DB-000128' + tag fix_id: 'F-55572r813879_fix' + tag 'documentable' + tag cci: ['CCI-001090'] + tag nist: ['SC-4'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252167.rb b/spec/mongo-inspec-profile/controls/SV-252167.rb new file mode 100644 index 0000000..c7bf443 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252167.rb @@ -0,0 +1,45 @@ +control 'SV-252167' do + title 'MongoDB must check the validity of all data inputs except those specifically identified by the organization.' + desc "Invalid user input occurs when a user inserts data or characters into an application's data entry fields and the application is unprepared to process that data. This results in unanticipated application behavior, potentially leading to an application or information system compromise. Invalid user input is one of the primary methods employed when attempting to compromise an application. + +With respect to database management systems, one class of threat is known as SQL Injection, or more generally, code injection. It takes advantage of the dynamic execution capabilities of various programming languages, including dialects of SQL. Potentially, the attacker can gain unauthorized access to data, including security settings, and severely corrupt or destroy the database. + +Even when no such hijacking takes place, invalid input that gets recorded in the database, whether accidental or malicious, reduces the reliability and usability of the system. Available protections include data types, referential constraints, uniqueness constraints, range checking, and application-specific logic. Application-specific logic can be implemented within the database in stored procedures and triggers, where appropriate. + +This calls for inspection of application source code, which will require collaboration with the application developers. It is recognized that in many cases, the database administrator (DBA) is organizationally separate from the application developers, and may have limited, if any, access to source code. Nevertheless, protections of this type are so important to the secure operation of databases that they must not be ignored. At a minimum, the DBA must attempt to obtain assurances from the development organization that this issue has been addressed, and must document what has been discovered." + desc 'check', '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" +}' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55623r813881_chk' + tag severity: 'medium' + tag gid: 'V-252167' + tag rid: 'SV-252167r813883_rule' + tag stig_id: 'MD4X-00-004100' + tag gtitle: 'SRG-APP-000251-DB-000160' + tag fix_id: 'F-55573r813882_fix' + tag 'documentable' + tag cci: ['CCI-001310'] + tag nist: ['SI-10'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252168.rb b/spec/mongo-inspec-profile/controls/SV-252168.rb new file mode 100644 index 0000000..4472b42 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252168.rb @@ -0,0 +1,49 @@ +control 'SV-252168' do + title 'MongoDB must provide non-privileged users with error messages that provide information necessary for corrective actions without revealing information that could be exploited by adversaries.' + desc 'Any DBMS or associated application providing too much information in error messages on the screen or printout risks compromising the data and security of the system. The structure and content of error messages need to be carefully considered by the organization and development team. + +Databases can inadvertently provide a wealth of information to an attacker through improperly handled error messages. In addition to sensitive business or personal information, database errors can provide host names, IP addresses, user names, and other system information not required for troubleshooting but very useful to someone targeting the system. + +Carefully consider the structure/content of error messages. The extent to which information systems are able to identify and handle error conditions is guided by organizational policy and operational requirements. Information that could be exploited by adversaries includes, for example, logon attempts with passwords entered by mistake as the username, mission/business information that can be derived from (if not stated explicitly by) information recorded, and personal information, such as account numbers, social security numbers, and credit card numbers. + +This calls for inspection of application source code, which will require collaboration with the application developers. It is recognized that in many cases, the database administrator (DBA) is organizationally separate from the application developers, and may have limited, if any, access to source code. Nevertheless, protections of this type are so important to the secure operation of databases that they must not be ignored. At a minimum, the DBA must attempt to obtain assurances from the development organization that this issue has been addressed, and must document what has been discovered.' + desc 'check', '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.' + desc 'fix', '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' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55624r813884_chk' + tag severity: 'medium' + tag gid: 'V-252168' + tag rid: 'SV-252168r813886_rule' + tag stig_id: 'MD4X-00-004200' + tag gtitle: 'SRG-APP-000266-DB-000162' + tag fix_id: 'F-55574r813885_fix' + tag 'documentable' + tag cci: ['CCI-001312'] + tag nist: ['SI-11 a'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252169.rb b/spec/mongo-inspec-profile/controls/SV-252169.rb new file mode 100644 index 0000000..5c9faa7 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252169.rb @@ -0,0 +1,50 @@ +control 'SV-252169' do + title 'MongoDB must reveal detailed error messages only to the ISSO, ISSM, SA, and DBA.' + desc %q(If MongoDB provides too much information in error logs and administrative messages to the screen, this could lead to compromise. The structure and content of error messages need to be carefully considered by the organization and development team. The extent to which the information system is able to identify and handle error conditions is guided by organizational policy and operational requirements. + +Some default DBMS error messages can contain information that could aid an attacker in, among other things, identifying the database type, host address, or state of the database. Custom errors may contain sensitive customer information. + +It is important that detailed error messages be visible only to those who are authorized to view them; that general users receive only generalized acknowledgment that errors have occurred; and that these generalized messages appear only when relevant to the user's task. For example, a message along the lines of, "An error has occurred. Unable to save your changes. If this problem persists, contact your help desk" would be relevant. A message such as "Warning: your transaction generated a large number of page splits" would likely not be relevant. + +Administrative users authorized to review detailed error messages typically are the ISSO, ISSM, SA, and DBA. Other individuals or roles may be specified according to organization-specific needs, with appropriate approval. + +This calls for inspection of application source code, which will require collaboration with the application developers. It is recognized that in many cases, the database administrator (DBA) is organizationally separate from the application developers, and may have limited, if any, access to source code. Nevertheless, protections of this type are so important to the secure operation of databases that they must not be ignored. At a minimum, the DBA must attempt to obtain assurances from the development organization that this issue has been addressed, and must document what has been discovered.) + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55625r813887_chk' + tag severity: 'medium' + tag gid: 'V-252169' + tag rid: 'SV-252169r813889_rule' + tag stig_id: 'MD4X-00-004300' + tag gtitle: 'SRG-APP-000267-DB-000163' + tag fix_id: 'F-55575r813888_fix' + tag 'documentable' + tag cci: ['CCI-001314'] + tag nist: ['SI-11 b'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252170.rb b/spec/mongo-inspec-profile/controls/SV-252170.rb new file mode 100644 index 0000000..41bd487 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252170.rb @@ -0,0 +1,54 @@ +control 'SV-252170' do + title 'MongoDB must automatically terminate a user session after organization-defined conditions or trigger events requiring session disconnect.' + desc "This addresses the termination of user-initiated logical sessions in contrast to the termination of network connections that are associated with communications sessions (i.e., network disconnect). A logical session (for local, network, and remote access) is initiated whenever a user (or process acting on behalf of a user) accesses an organizational information system. Such user sessions can be terminated (and thus terminate user access) without terminating network sessions. + +Session termination ends all processes associated with a user's logical session except those batch processes/jobs that are specifically created by the user (i.e., session owner) to continue after the session is terminated. + +Conditions or trigger events requiring automatic session termination can include, for example, organization-defined periods of user inactivity, targeted responses to certain types of incidents, and time-of-day restrictions on information system use. + +This capability is typically reserved for specific cases where the system owner, data owner, or organization requires additional assurance." + desc 'check', "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." + desc 'fix', '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: , db: }, ... ] }] } ) + +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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55626r813890_chk' + tag severity: 'medium' + tag gid: 'V-252170' + tag rid: 'SV-252170r855507_rule' + tag stig_id: 'MD4X-00-004400' + tag gtitle: 'SRG-APP-000295-DB-000305' + tag fix_id: 'F-55576r813891_fix' + tag 'documentable' + tag cci: ['CCI-002361'] + tag nist: ['AC-12'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252171.rb b/spec/mongo-inspec-profile/controls/SV-252171.rb new file mode 100644 index 0000000..81cc988 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252171.rb @@ -0,0 +1,66 @@ +control 'SV-252171' do + title 'MongoDB must utilize centralized management of the content captured in audit records generated by all components of MongoDB.' + desc 'Without the ability to centrally manage the content captured in the audit records, identification, troubleshooting, and correlation of suspicious behavior would be difficult and could lead to a delayed or incomplete analysis of an ongoing attack. + +The content captured in audit records must be managed from a central location (necessitating automation). Centralized management of audit records and logs provides for efficiency in maintenance and management of records, as well as the backup and archiving of those records. + +MongoDB may write audit records to database tables, to files in the file system, to other kinds of local repository, or directly to a centralized log management system. Whatever the method used, it must be compatible with off-loading the records to the centralized system.' + desc 'check', '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.' + desc 'fix', %q(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.) + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55627r813893_chk' + tag severity: 'medium' + tag gid: 'V-252171' + tag rid: 'SV-252171r855508_rule' + tag stig_id: 'MD4X-00-004800' + tag gtitle: 'SRG-APP-000356-DB-000314' + tag fix_id: 'F-55577r813894_fix' + tag 'documentable' + tag cci: ['CCI-001844'] + tag nist: ['AU-3 (2)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252172.rb b/spec/mongo-inspec-profile/controls/SV-252172.rb new file mode 100644 index 0000000..a98ed97 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252172.rb @@ -0,0 +1,42 @@ +control 'SV-252172' do + title 'MongoDB must allocate audit record storage capacity in accordance with site audit record storage requirements.' + desc "In order to ensure sufficient storage capacity for the audit logs, MongoDB must be able to allocate audit record storage capacity. Although another requirement (SRG-APP-000515-DB-000318) mandates that audit data be off-loaded to a centralized log management system, it remains necessary to provide space on the database server to serve as a buffer against outages and capacity limits of the off-loading mechanism. + +The task of allocating audit record storage capacity is usually performed during initial installation of MongoDB and is closely associated with the DBA and system administrator roles. The DBA or system administrator will usually coordinate the allocation of physical drive space with the application owner/installer and the application will prompt the installer to provide the capacity information, the physical location of the disk, or both. + +In determining the capacity requirements, consider such factors as: total number of users; expected number of concurrent users during busy periods; number and type of events being monitored; types and amounts of data being captured; the frequency/speed with which audit records are off-loaded to the central log management system; and any limitations that exist on MongoDB's ability to reuse the space formerly occupied by off-loaded records." + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55628r813896_chk' + tag severity: 'medium' + tag gid: 'V-252172' + tag rid: 'SV-252172r855509_rule' + tag stig_id: 'MD4X-00-004900' + tag gtitle: 'SRG-APP-000357-DB-000316' + tag fix_id: 'F-55578r813897_fix' + tag 'documentable' + tag cci: ['CCI-001849'] + tag nist: ['AU-4'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252173.rb b/spec/mongo-inspec-profile/controls/SV-252173.rb new file mode 100644 index 0000000..a7a285e --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252173.rb @@ -0,0 +1,34 @@ +control 'SV-252173' do + title 'MongoDB must provide a warning to appropriate support staff when allocated audit record storage volume reaches 75 percent of maximum audit record storage capacity.' + desc 'Organizations are required to use a central log management system; so, under normal conditions, the audit space allocated to MongoDB on its own server will not be an issue. However, space will still be required on MongoDB server for audit records in transit, and, under abnormal conditions, this could fill up. Since a requirement exists to halt processing upon audit failure, a service outage would result. + +If support personnel are not notified immediately upon storage volume utilization reaching 75 percent, they are unable to plan for storage capacity expansion. + +The appropriate support staff include, at a minimum, the ISSO and the DBA/SA.' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55629r813899_chk' + tag severity: 'medium' + tag gid: 'V-252173' + tag rid: 'SV-252173r855510_rule' + tag stig_id: 'MD4X-00-005000' + tag gtitle: 'SRG-APP-000359-DB-000319' + tag fix_id: 'F-55579r813900_fix' + tag 'documentable' + tag cci: ['CCI-001855'] + tag nist: ['AU-5 (1)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252174.rb b/spec/mongo-inspec-profile/controls/SV-252174.rb new file mode 100644 index 0000000..2be7928 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252174.rb @@ -0,0 +1,66 @@ +control 'SV-252174' do + title 'MongoDB must prohibit user installation of logic modules (stored procedures, functions, triggers, views, etc.) without explicit privileged status.' + desc 'Allowing regular users to install software, without explicit privileges, creates the risk that untested or potentially malicious software will be installed on the system. Explicit privileges (escalated or administrative privileges) provide the regular user with explicit capabilities and control that exceed the rights of a regular user. + +DBMS functionality and the nature and requirements of databases will vary; so while users are not permitted to install unapproved software, there may be instances where the organization allows the user to install approved software packages such as from an approved software repository. The requirements for production servers will be more restrictive than those used for development and research. + +MongoDB must enforce software installation by users based upon what types of software installations are permitted (e.g., updates and security patches to existing software) and what types of installations are prohibited (e.g., software whose pedigree with regard to being potentially malicious is unknown or suspect) by the organization). + +In the case of a database management system, this requirement covers stored procedures, functions, triggers, views, etc.' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55630r855511_chk' + tag severity: 'medium' + tag gid: 'V-252174' + tag rid: 'SV-252174r855512_rule' + tag stig_id: 'MD4X-00-005300' + tag gtitle: 'SRG-APP-000378-DB-000365' + tag fix_id: 'F-55580r813903_fix' + tag 'documentable' + tag cci: ['CCI-001812'] + tag nist: ['CM-11 (2)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252175.rb b/spec/mongo-inspec-profile/controls/SV-252175.rb new file mode 100644 index 0000000..9d566ee --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252175.rb @@ -0,0 +1,77 @@ +control 'SV-252175' do + title 'MongoDB must enforce access restrictions associated with changes to the configuration of MongoDB or database(s).' + desc 'Failure to provide logical access restrictions associated with changes to configuration may have significant effects on the overall security of the system. + +When dealing with access restrictions pertaining to change control, it should be noted that any changes to the hardware, software, and/or firmware components of the information system can potentially have significant effects on the overall security of the system. + +Accordingly, only qualified and authorized individuals should be allowed to obtain access to system components for the purposes of initiating changes, including upgrades and modifications.' + desc 'check', '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.' + desc 'fix', "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/" + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55631r855513_chk' + tag severity: 'medium' + tag gid: 'V-252175' + tag rid: 'SV-252175r855515_rule' + tag stig_id: 'MD4X-00-005400' + tag gtitle: 'SRG-APP-000380-DB-000360' + tag fix_id: 'F-55581r855514_fix' + tag 'documentable' + tag cci: ['CCI-001813'] + tag nist: ['CM-5 (1) (a)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252176.rb b/spec/mongo-inspec-profile/controls/SV-252176.rb new file mode 100644 index 0000000..3db0829 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252176.rb @@ -0,0 +1,115 @@ +control 'SV-252176' do + title 'MongoDB must require users to reauthenticate when organization-defined circumstances or situations require reauthentication.' + desc 'The DoD standard for authentication of an interactive user is the presentation of a Common Access Card (CAC) or other physical token bearing a valid, current, DoD-issued Public Key Infrastructure (PKI) certificate, coupled with a Personal Identification Number (PIN) to be entered by the user at the beginning of each session and whenever reauthentication is required. + +Without reauthentication, users may access resources or perform tasks for which they do not have authorization. + +When applications provide the capability to change security roles or escalate the functional capability of the application, it is critical the user reauthenticate. + +In addition to the reauthentication requirements associated with session locks, organizations may require reauthentication of individuals and/or devices in other situations, including (but not limited to) the following circumstances: + +(i) When authenticators change; +(ii) When roles change; +(iii) When security categories of information systems change; +(iv) When the execution of privileged functions occurs; +(v) After a fixed period of time; or +(vi) Periodically. + +Within the DoD, the minimum circumstances requiring reauthentication are privilege escalation and role changes.' + desc 'check', %q(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.) + desc 'fix', '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' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55632r855516_chk' + tag severity: 'medium' + tag gid: 'V-252176' + tag rid: 'SV-252176r855517_rule' + tag stig_id: 'MD4X-00-005600' + tag gtitle: 'SRG-APP-000389-DB-000372' + tag fix_id: 'F-55582r813909_fix' + tag 'documentable' + tag cci: ['CCI-002038'] + tag nist: ['IA-11'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252177.rb b/spec/mongo-inspec-profile/controls/SV-252177.rb new file mode 100644 index 0000000..b4e424f --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252177.rb @@ -0,0 +1,24 @@ +control 'SV-252177' do + title 'MongoDB must prohibit the use of cached authenticators after an organization-defined time period.' + desc 'If cached authentication information is out-of-date, the validity of the authentication information may be questionable.' + desc 'check', '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.' + desc 'fix', "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/)." + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55633r813911_chk' + tag severity: 'medium' + tag gid: 'V-252177' + tag rid: 'SV-252177r855518_rule' + tag stig_id: 'MD4X-00-005700' + tag gtitle: 'SRG-APP-000400-DB-000367' + tag fix_id: 'F-55583r813912_fix' + tag 'documentable' + tag cci: ['CCI-002007'] + tag nist: ['IA-5 (13)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252178.rb b/spec/mongo-inspec-profile/controls/SV-252178.rb new file mode 100644 index 0000000..e43e690 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252178.rb @@ -0,0 +1,26 @@ +control 'SV-252178' do + title 'MongoDB must only accept end entity certificates issued by DoD PKI or DoD-approved PKI Certification Authorities (CAs) for the establishment of all encrypted sessions.' + desc 'Only DoD-approved external PKIs have been evaluated to ensure that they have security controls and identity vetting procedures in place which are sufficient for DoD systems to rely on the identity asserted in the certificate. PKIs lacking sufficient security controls and identity vetting procedures risk being compromised and issuing certificates that enable adversaries to impersonate legitimate users. + +The authoritative list of DoD-approved PKIs is published at https://cyber.mil/pki-pke/. + +This requirement focuses on communications protection for MongoDB session rather than for the network packet.' + desc 'check', '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.' + desc 'fix', "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." + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55634r813914_chk' + tag severity: 'medium' + tag gid: 'V-252178' + tag rid: 'SV-252178r855519_rule' + tag stig_id: 'MD4X-00-005800' + tag gtitle: 'SRG-APP-000427-DB-000385' + tag fix_id: 'F-55584r817014_fix' + tag 'documentable' + tag cci: ['CCI-002470'] + tag nist: ['SC-23 (5)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252179.rb b/spec/mongo-inspec-profile/controls/SV-252179.rb new file mode 100644 index 0000000..ffd9a54 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252179.rb @@ -0,0 +1,55 @@ +control 'SV-252179' do + title 'MongoDB must maintain the confidentiality and integrity of information during preparation for transmission.' + desc 'Information can be either unintentionally or maliciously disclosed or modified during preparation for transmission, including, for example, during aggregation, at protocol transformation points, and during packing/unpacking. These unauthorized disclosures or modifications compromise the confidentiality or integrity of the information. + +Use of this requirement will be limited to situations where the data owner has a strict requirement for ensuring data integrity and confidentiality is maintained at every step of the data transfer and handling process. + +When transmitting data, MongoDB, associated applications, and infrastructure must leverage transmission protection mechanisms.' + desc 'check', '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.' + desc 'fix', '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).' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55635r813917_chk' + tag severity: 'medium' + tag gid: 'V-252179' + tag rid: 'SV-252179r855520_rule' + tag stig_id: 'MD4X-00-006000' + tag gtitle: 'SRG-APP-000441-DB-000378' + tag fix_id: 'F-55585r813918_fix' + tag 'documentable' + tag cci: ['CCI-002420'] + tag nist: ['SC-8 (2)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252180.rb b/spec/mongo-inspec-profile/controls/SV-252180.rb new file mode 100644 index 0000000..331b8e1 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252180.rb @@ -0,0 +1,50 @@ +control 'SV-252180' do + title 'MongoDB must maintain the confidentiality and integrity of information during reception.' + desc 'Information can be either unintentionally or maliciously disclosed or modified during reception, including, for example, during aggregation, at protocol transformation points, and during packing/unpacking. These unauthorized disclosures or modifications compromise the confidentiality or integrity of the information. + +This requirement applies only to those applications that are either distributed or can allow access to data nonlocally. Use of this requirement will be limited to situations where the data owner has a strict requirement for ensuring data integrity and confidentiality is maintained at every step of the data transfer and handling process. + +When receiving data, MongoDB, associated applications, and infrastructure must leverage protection mechanisms.' + desc 'check', '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.' + desc 'fix', '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).' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55636r813920_chk' + tag severity: 'medium' + tag gid: 'V-252180' + tag rid: 'SV-252180r855521_rule' + tag stig_id: 'MD4X-00-006100' + tag gtitle: 'SRG-APP-000442-DB-000379' + tag fix_id: 'F-55586r813921_fix' + tag 'documentable' + tag cci: ['CCI-002422'] + tag nist: ['SC-8 (2)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252181.rb b/spec/mongo-inspec-profile/controls/SV-252181.rb new file mode 100644 index 0000000..da1c66c --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252181.rb @@ -0,0 +1,64 @@ +control 'SV-252181' do + title 'When invalid inputs are received, MongoDB must behave in a predictable and documented manner that reflects organizational and system objectives.' + desc 'A common vulnerability is unplanned behavior when invalid inputs are received. This requirement guards against adverse or unintended system behavior caused by invalid inputs, where information system responses to the invalid input may be disruptive or cause the system to fail into an unsafe state. + +The behavior will be derived from the organizational and system requirements and includes, but is not limited to, notification of the appropriate personnel, creating an audit record, and rejecting invalid input. + +This calls for inspection of application source code, which will require collaboration with the application developers. It is recognized that in many cases, the database administrator (DBA) is organizationally separate from the application developers, and may have limited, if any, access to source code. Nevertheless, protections of this type are so important to the secure operation of databases that they must not be ignored. At a minimum, the DBA must attempt to obtain assurances from the development organization that this issue has been addressed, and must document what has been discovered.' + desc 'check', '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" + } + } +]' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55637r855522_chk' + tag severity: 'medium' + tag gid: 'V-252181' + tag rid: 'SV-252181r855523_rule' + tag stig_id: 'MD4X-00-006200' + tag gtitle: 'SRG-APP-000447-DB-000393' + tag fix_id: 'F-55587r813924_fix' + tag 'documentable' + tag cci: ['CCI-002754'] + tag nist: ['SI-10 (3)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252182.rb b/spec/mongo-inspec-profile/controls/SV-252182.rb new file mode 100644 index 0000000..afe63fc --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252182.rb @@ -0,0 +1,77 @@ +control 'SV-252182' do + title 'When updates are applied to MongoDB software, any software components that have been replaced or made unnecessary must be removed.' + desc "Previous versions of DBMS components that are not removed from the information system after updates have been installed may be exploited by adversaries. + +Some DBMSs' installation tools may remove older versions of software automatically from the information system. In other cases, manual review and removal will be required. In planning installations and upgrades, organizations must include steps (automated, manual, or both) to identify and remove the outdated modules. + +A transition period may be necessary when both the old and the new software are required. This should be taken into account in the planning." + desc 'check', '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.' + desc 'fix', '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' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55638r813926_chk' + tag severity: 'medium' + tag gid: 'V-252182' + tag rid: 'SV-252182r855524_rule' + tag stig_id: 'MD4X-00-006300' + tag gtitle: 'SRG-APP-000454-DB-000389' + tag fix_id: 'F-55588r813927_fix' + tag 'documentable' + tag cci: ['CCI-002617'] + tag nist: ['SI-2 (6)'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252183.rb b/spec/mongo-inspec-profile/controls/SV-252183.rb new file mode 100644 index 0000000..f498ab5 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252183.rb @@ -0,0 +1,34 @@ +control 'SV-252183' do + title 'Security-relevant software updates to MongoDB must be installed within the time period directed by an authoritative source (e.g., IAVM, CTOs, DTMs, and STIGs).' + desc 'Security flaws with software applications, including database management systems, are discovered daily. Vendors are constantly updating and patching their products to address newly discovered security vulnerabilities. Organizations (including any contractor to the organization) are required to promptly install security-relevant software updates (e.g., patches, service packs, and hot fixes). Flaws discovered during security assessments, continuous monitoring, incident response activities, or information system error handling must also be addressed expeditiously. + +Organization-defined time periods for updating security-relevant software may vary based on a variety of factors including, for example, the security category of the information system or the criticality of the update (i.e., severity of the vulnerability related to the discovered flaw). + +This requirement will apply to software patch management solutions that are used to install patches across the enclave and also to applications themselves that are not part of that patch management solution. For example, many browsers today provide the capability to install their own patch software. Patch criticality, as well as system criticality, will vary. Therefore, the tactical situations regarding the patch management process will also vary. This means that the time period utilized must be a configurable parameter. Time frames for application of security-relevant software updates may be dependent upon the Information Assurance Vulnerability Management (IAVM) process. + +The application will be configured to check for and install security-relevant software updates within an identified time period from the availability of the update. The specific time period will be defined by an authoritative source (e.g., IAVM, CTOs, DTMs, and STIGs).' + desc 'check', '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.' + desc 'fix', '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.' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55639r855525_chk' + tag severity: 'medium' + tag gid: 'V-252183' + tag rid: 'SV-252183r855526_rule' + tag stig_id: 'MD4X-00-006400' + tag gtitle: 'SRG-APP-000456-DB-000390' + tag fix_id: 'F-55589r813930_fix' + tag 'documentable' + tag cci: ['CCI-002605'] + tag nist: ['SI-2 c'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252184.rb b/spec/mongo-inspec-profile/controls/SV-252184.rb new file mode 100644 index 0000000..d907a49 --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252184.rb @@ -0,0 +1,34 @@ +control 'SV-252184' do + title 'MongoDB products must be a version supported by the vendor.' + desc 'Unsupported commercial and database systems should not be used because fixes to newly identified bugs will not be implemented by the vendor. The lack of support can result in potential vulnerabilities. + +Systems at unsupported servicing levels or releases will not receive security updates for new vulnerabilities, which leaves them subject to exploitation. + +When maintenance updates and patches are no longer available, the database software is no longer considered supported and should be upgraded or decommissioned.' + desc 'check', 'Review the system documentation and interview the database administrator. + +Identify all database software components. Review the version and release information. + +To determine the current running MongoDB server version, run the following command from the Mongo Shell: + +db.version() + +Access the MongoDB website (https://www.mongodb.com/support-policy/lifecycles) or use other means to verify if the currently running MongoDB server version is still supported. + +If the DBMS or any of the software components are not supported by MongoDB, this is a finding.' + desc 'fix', 'Remove or decommission all unsupported software products. + +Upgrade unsupported DBMS or unsupported components to a supported version of the product.' + impact 0.7 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55640r813932_chk' + tag severity: 'high' + tag gid: 'V-252184' + tag rid: 'SV-252184r863332_rule' + tag stig_id: 'MD4X-00-006500' + tag gtitle: 'SRG-APP-000456-DB-000400' + tag fix_id: 'F-55590r813933_fix' + tag 'documentable' + tag cci: ['CCI-002605'] + tag nist: ['SI-2 c'] +end diff --git a/spec/mongo-inspec-profile/controls/SV-252185.rb b/spec/mongo-inspec-profile/controls/SV-252185.rb new file mode 100644 index 0000000..af429fe --- /dev/null +++ b/spec/mongo-inspec-profile/controls/SV-252185.rb @@ -0,0 +1,25 @@ +control 'SV-252185' do + title 'MongoDB must be configured in accordance with the security configuration settings based on DoD security configuration and implementation guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.' + desc 'Configuring MongoDB to implement organization-wide security implementation guides and security checklists ensures compliance with federal standards and establishes a common security baseline across DoD that reflects the most restrictive security posture consistent with operational requirements. + +In addition to this SRG, sources of guidance on security and information assurance exist. These include NSA configuration guides, CTOs, DTMs, and IAVMs. MongoDB must be configured in compliance with guidance from all such relevant sources.' + desc 'check', '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.' + desc 'fix', '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/' + impact 0.5 + ref 'DPMS Target MongoDB Enterprise Advanced 4.x' + tag check_id: 'C-55641r813935_chk' + tag severity: 'medium' + tag gid: 'V-252185' + tag rid: 'SV-252185r816999_rule' + tag stig_id: 'MD4X-00-006600' + tag gtitle: 'SRG-APP-000516-DB-000363' + tag fix_id: 'F-55591r816998_fix' + tag 'documentable' + tag cci: ['CCI-000366'] + tag nist: ['CM-6 b'] +end diff --git a/spec/mongo-inspec-profile/inspec.lock b/spec/mongo-inspec-profile/inspec.lock new file mode 100644 index 0000000..e687b9b --- /dev/null +++ b/spec/mongo-inspec-profile/inspec.lock @@ -0,0 +1,3 @@ +--- +lockfile_version: 1 +depends: [] diff --git a/spec/mongo-inspec-profile/inspec.yml b/spec/mongo-inspec-profile/inspec.yml new file mode 100644 index 0000000..9d30d5b --- /dev/null +++ b/spec/mongo-inspec-profile/inspec.yml @@ -0,0 +1,12 @@ +name: MongoDB_Enterprise_Advanced_4-x_STIG +title: null +maintainer: null +copyright: null +copyright_email: null +license: null +summary: null +description: null +version: 1.0.0 +supports: [] +depends: [] +inspec_version: null