From c94d0ab66544cc9403df58c4cca0ef0b32a909a1 Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Fri, 14 May 2021 14:16:48 -0400 Subject: [PATCH 01/32] Injection changes to start a PR Signed-off-by: Rony Xavier --- Review.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Review.md b/Review.md index f553fa5..0d328e0 100644 --- a/Review.md +++ b/Review.md @@ -23,4 +23,5 @@ Another tip is to cat all the controls into a single file so you don't have to open every individaul file and try to keep track of where you are and which one is next. + *** A completion date is entered in a row when all non-enhancement issues are resolved for that review row. From 283abbf23f7e71c34eb380004f44609b1700b1f0 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Tue, 18 May 2021 14:35:38 -0400 Subject: [PATCH 02/32] updating controls to fix broken logic, also adding missing inputs Signed-off-by: HackerShark --- controls/V-81849.rb | 24 +++++++++++------------- inspec.yml | 9 +++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/controls/V-81849.rb b/controls/V-81849.rb index 2b3d53d..bca2a7c 100644 --- a/controls/V-81849.rb +++ b/controls/V-81849.rb @@ -101,18 +101,16 @@ tag "documentable": false tag "severity_override_guidance": false - if file(input('mongod_auditlog')).exist? - mongodb_auditlog_dir = command("dirname #{input('mongod_auditlog')}").stdout.strip - describe file(mongodb_auditlog_dir) do - it { should_not be_more_permissive_than('0700') } - its('owner') { should be_in input('mongodb_service_account') } - its('group') { should be_in input('mongodb_service_group') } - end - else - describe file('/var/log') do - it { should_not be_more_permissive_than('0755') } - its('owner') { should eq 'root' } - its('group') { should eq 'root' } - end + mongodb_auditlog_dir = yaml(input('mongod_conf'))['auditLog', 'path'] + + describe file(mongodb_auditlog_dir) do + it { should exist } + end + + describe file(mongodb_auditlog_dir) do + it { should_not be_more_permissive_than('0700') } + its('owner') { should be_in input('mongodb_service_account') } + its('group') { should be_in input('mongodb_service_group') } end + end diff --git a/inspec.yml b/inspec.yml index 42e94f3..bf23300 100644 --- a/inspec.yml +++ b/inspec.yml @@ -155,3 +155,12 @@ inputs: type: array value: ['[ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "readAnyDatabase", "db" : "admin" }, { "role" : "readWrite", "db" : "config" } ] }'] + - name: mongodb_service_account + description: Mongodb Service Account + type: array + value: ["mongodb", "mongod"] + + - name: mongodb_service_group + description: Mongodb Service Group + type: array + value: ["mongodb", "mongod"] From de54c312a3c709ed43cf25fbb5e2bd3f20b7dda2 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Tue, 18 May 2021 14:49:52 -0400 Subject: [PATCH 03/32] cleaning up code to be a bit more efficient Signed-off-by: HackerShark --- controls/V-81861.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/controls/V-81861.rb b/controls/V-81861.rb index 1112acd..059f24b 100644 --- a/controls/V-81861.rb +++ b/controls/V-81861.rb @@ -57,30 +57,30 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_conf_file = input('mongod_conf') + mongo_conf_file = input('mongod_conf').to_s describe.one do - describe yaml(mongo_conf_file.to_s) do + describe yaml(mongo_conf_file) do its(%w{net http enabled}) { should cmp 'false' } end - describe yaml(mongo_conf_file.to_s) do + describe yaml(mongo_conf_file) do its(%w{net http enabled}) { should be_nil } end end describe.one do - describe yaml(mongo_conf_file.to_s) do + describe yaml(mongo_conf_file) do its(%w{net http JSONPEnabled}) { should cmp 'false' } end - describe yaml(mongo_conf_file.to_s) do + describe yaml(mongo_conf_file) do its(%w{net http JSONPEnabled}) { should be_nil } end end describe.one do - describe yaml(mongo_conf_file.to_s) do + describe yaml(mongo_conf_file) do its(%w{net http RESTInterfaceEnabled}) { should cmp 'false' } end - describe yaml(mongo_conf_file.to_s) do + describe yaml(mongo_conf_file) do its(%w{net http RESTInterfaceEnabled}) { should be_nil } end end From ebcf6ff83f643c87fc22802a4ebdb113e1a22b42 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Wed, 19 May 2021 18:10:50 -0400 Subject: [PATCH 04/32] Adding additional fixes, removing unused inputs from inputs.yml and inspec.yml Signed-off-by: HackerShark --- controls/V-81849.rb | 6 ++++-- controls/V-81851.rb | 7 +++++-- controls/V-81855.rb | 9 +++------ inputs.yml | 3 --- inspec.yml | 18 ------------------ 5 files changed, 12 insertions(+), 31 deletions(-) diff --git a/controls/V-81849.rb b/controls/V-81849.rb index bca2a7c..0ee7d56 100644 --- a/controls/V-81849.rb +++ b/controls/V-81849.rb @@ -102,6 +102,8 @@ tag "severity_override_guidance": false mongodb_auditlog_dir = yaml(input('mongod_conf'))['auditLog', 'path'] + mongodb_service_account = input('mongodb_service_account') + mongodb_service_group = input('mongodb_service_group') describe file(mongodb_auditlog_dir) do it { should exist } @@ -109,8 +111,8 @@ describe file(mongodb_auditlog_dir) do it { should_not be_more_permissive_than('0700') } - its('owner') { should be_in input('mongodb_service_account') } - its('group') { should be_in input('mongodb_service_group') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } end end diff --git a/controls/V-81851.rb b/controls/V-81851.rb index 7a2bb91..abe9e21 100644 --- a/controls/V-81851.rb +++ b/controls/V-81851.rb @@ -67,10 +67,13 @@ tag "nist": ["AU-9"] tag "documentable": false tag "severity_override_guidance": false + + mongodb_service_account = input('mongodb_service_account') + mongodb_service_group = input('mongodb_service_group') describe file(input('mongod_conf')) do it { should_not be_more_permissive_than('0700') } - its('owner') { should be_in input('mongodb_service_account') } - its('group') { should be_in input('mongodb_service_group') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } end end diff --git a/controls/V-81855.rb b/controls/V-81855.rb index 82bf311..e49eb52 100644 --- a/controls/V-81855.rb +++ b/controls/V-81855.rb @@ -47,12 +47,9 @@ tag "documentable": false tag "severity_override_guidance": false - if input('is_docker') == 'true' - describe "The MongoDB is installed within a Docker container so it is - separate from the host OS, therefore this is not a finding." do - subject { virtualization.system } - it {should cmp 'docker'} - end + if virtualization.system.eql?('docker') + impact 0.0 + desc 'caveat', 'This is Not Applicable since the MongoDB is installed within a Docker container so it is separate from the host OS' else describe "This test requires a Manual Review: Ensure all database software, including DBMS configuration files, is stored in dedicated directories, or diff --git a/inputs.yml b/inputs.yml index 56fa9e5..629ca17 100644 --- a/inputs.yml +++ b/inputs.yml @@ -1,11 +1,8 @@ mongod_conf: '/etc/mongod.conf' mongo_data_dir: '/var/lib/mongo' -mongod_pem: '/etc/ssl/mongodb.pem' -mongod_cafile: '/etc/ssl/mongodbca.pem' mongod_client_pem: '/etc/ssl/client.pem' -mongod_auditlog: '/var/lib/mongo/auditLog.bson' saslauthd: '/etc/sysconfig/saslauthd' mongod_hostname: 'MONGODB' diff --git a/inspec.yml b/inspec.yml index bf23300..9cb3138 100644 --- a/inspec.yml +++ b/inspec.yml @@ -21,30 +21,12 @@ inputs: value: '/var/lib/mongo' required: true - - name: mongod_pem - description: 'MongoDB Server PEM File' - type: string - value: '/etc/ssl/mongodb.pem' - required: true - - - name: mongod_cafile - description: 'MongoDB CA File' - type: string - value: '/etc/ssl/mongodbca.pem' - required: true - - name: mongod_client_pem description: 'MongoDB Client PEM File' type: string value: '/etc/ssl/client.pem' required: true - - name: mongod_auditlog - description: 'MongoDB Audit Log File' - type: string - value: '/var/lib/mongo/auditLog.bson' - required: true - - name: saslauthd description: 'MongoDB SASLAUTHD File' type: string From 609d7b078030baa6f22417b5039d634c26187593 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Wed, 19 May 2021 18:15:28 -0400 Subject: [PATCH 05/32] Updating control to fix problematic logic Signed-off-by: HackerShark --- controls/V-81871.rb | 48 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/controls/V-81871.rb b/controls/V-81871.rb index 0d0c2eb..2b3bc94 100644 --- a/controls/V-81871.rb +++ b/controls/V-81871.rb @@ -58,32 +58,30 @@ tag "nist": ["IA-5 (2) (b)"] tag "documentable": false tag "severity_override_guidance": false + + mongod_pem = yaml(input('mongod_conf'))['net', 'ssl', 'PEMKeyFile'] + mongod_cafile = yaml(input('mongod_conf'))['net', 'ssl', 'CAFile'] + mongodb_service_account = input('mongodb_service_account') + mongodb_service_group = input('mongodb_service_group') - if file(input('mongod_pem')).exist? - describe file(input('mongod_pem')) do - it { should_not be_more_permissive_than('0600') } - its('owner') { should be_in input('mongodb_service_account') } - its('group') { should be_in input('mongodb_service_group') } - end - else - describe 'This control must be reviewed manually because the pem file is not found - at the location specified.' do - skip 'This control must be reviewed manually because the pem file is not found - at the location specified.' - end - end + describe file(mongod_pem) do + it { should exist } + end + + describe file(mongod_pem) do + it { should_not be_more_permissive_than('0600') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } + end + + describe file(mongod_cafile) do + it { should exist } + end - if file(input('mongod_cafile')).exist? - describe file(input('mongod_cafile')) do - it { should_not be_more_permissive_than('0600') } - its('owner') { should be_in input('mongodb_service_account') } - its('group') { should be_in input('mongodb_service_group') } - end - else - describe 'This control must be reviewed manually because the CA file is not found - at the location specified.' do - skip 'This control must be reviewed manually because the CA file is not found - at the location specified.' - end + describe file(mongod_cafile) do + it { should_not be_more_permissive_than('0600') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } end + end \ No newline at end of file From 46268f00b8d5d476e80d3ec8fac32f2a2d44fe51 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Thu, 20 May 2021 09:36:16 -0400 Subject: [PATCH 06/32] V-81859 improved logic flow Signed-off-by: HackerShark --- controls/V-81859.rb | 43 ++++++++++++++----------------------------- inputs.yml | 10 +--------- inspec.yml | 16 ++-------------- 3 files changed, 17 insertions(+), 52 deletions(-) diff --git a/controls/V-81859.rb b/controls/V-81859.rb index ddea44c..50084dc 100644 --- a/controls/V-81859.rb +++ b/controls/V-81859.rb @@ -46,36 +46,21 @@ tag "nist": ["CM-7 a"] tag "documentable": false tag "severity_override_guidance": false - - if os.debian? - dpkg_packages = command("dpkg --get-selections | grep mongodb").stdout.split("\n") - if dpkg_packages.empty? - describe 'There are no mongo database packages installed, therefore for this control is NA' do - skip 'There are no mongo database packages installed, therefore for this control is NA' - end - else - dpkg_packages.each do |package| - package = command("echo #{package} | sed 's/ hold$//'").stdout.split - describe "The installed mongodb package: #{package}" do - subject { package } - it { should be_in input('mongodb_debian_packages') } - end - end + + + approved_mongo_packages = input('approved_mongo_packages') + + dpkg_packages = packages(/mongodb/).names + if dpkg_packages.empty? + describe 'There are no mongo database packages installed, therefore for this control is NA' do + skip 'There are no mongo database packages installed, therefore for this control is NA' end - elsif os.redhat? - rpm_packages = command("rpm -qa | grep mongodb").stdout.split("\n") - if rpm_packages.empty? - describe 'There are no mongo database packages installed, therefore for this control is NA' do - skip 'There are no mongo database packages installed, therefore for this control is NA' - end - else - rpm_packages.each do |package| - package = command("echo #{package} | sed 's/.x86.*//'").stdout.split - describe "The installed mongodb package: #{package}" do - subject { package } - it { should be_in input('mongodb_redhat_packages') } - end + else + dpkg_packages.each do |package| + describe "The installed mongodb package: #{package}" do + subject { package } + it { should be_in approved_mongo_packages } end end end -end +end \ No newline at end of file diff --git a/inputs.yml b/inputs.yml index 629ca17..002c1f7 100644 --- a/inputs.yml +++ b/inputs.yml @@ -12,15 +12,7 @@ mongo_use_pki: 'true' mongo_use_ldap: 'false' mongo_use_saslauthd: 'false' -mongodb_redhat_packages: [ - 'mongodb-enterprise-3.6.20-1.el7', - 'mongodb-enterprise-mongos-3.6.20-1.el7', - 'mongodb-enterprise-server-3.6.20-1.el7', - 'mongodb-enterprise-shell-3.6.20-1.el7', - 'mongodb-enterprise-tools-3.6.20-1.el7' -] - -mongodb_debian_packages: [ +approved_mongo_packages: [ 'mongodb-enterprise', 'mongodb-enterprise-mongos', 'mongodb-enterprise-server', diff --git a/inspec.yml b/inspec.yml index 9cb3138..a7d887c 100644 --- a/inspec.yml +++ b/inspec.yml @@ -57,20 +57,8 @@ inputs: value: 'false' required: true - - name: mongodb_redhat_packages - description: 'List of MongoDB Redhat Packages' - type: array - value: [ - 'mongodb-enterprise-3.6.20-1.el7', - 'mongodb-enterprise-mongos-3.6.20-1.el7', - 'mongodb-enterprise-server-3.6.20-1.el7', - 'mongodb-enterprise-shell-3.6.20-1.el7', - 'mongodb-enterprise-tools-3.6.20-1.el7' - ] - required: true - - - name: mongodb_debian_packages - description: 'List of MongoDB Debian Packages' + - name: approved_mongo_packages + description: 'List of MongoDB Packages' type: array value: [ 'mongodb-enterprise', From 084b820b8275247fa526ee4c6f842803753c4054 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Mon, 24 May 2021 00:33:38 -0400 Subject: [PATCH 07/32] Fixing 81849 to incorporate missing check Signed-off-by: HackerShark --- controls/V-81849.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controls/V-81849.rb b/controls/V-81849.rb index 0ee7d56..52f6a78 100644 --- a/controls/V-81849.rb +++ b/controls/V-81849.rb @@ -115,4 +115,8 @@ its('group') { should be_in mongodb_service_group } end + describe command("dirname #{mongodb_auditlog_dir}") do + it { should cmp '/var/lib/mongo'} + end + end From 1bb651f9a4e4a3c6ceb6f4d90866b26fd9cae329 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Mon, 24 May 2021 00:37:01 -0400 Subject: [PATCH 08/32] modified 81869 to better check against more conditions Signed-off-by: HackerShark --- controls/V-81869.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/controls/V-81869.rb b/controls/V-81869.rb index c992368..4ac9d92 100644 --- a/controls/V-81869.rb +++ b/controls/V-81869.rb @@ -60,8 +60,13 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w{net ssl allowInvalidCertificates}) { should be nil } + describe.one do + describe yaml(input('mongod_conf')) do + its(%w{net ssl allowInvalidCertificates}) { should be nil } + end + describe yaml(input('mongod_conf')) do + its(%w{net ssl allowInvalidCertificates}) { should be false } + end end describe yaml(input('mongod_conf')) do its(%w{net ssl mode}) { should cmp 'requireSSL' } From 5af90d99ee9fbeff62ef6d0d6789b95fafba5851 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Tue, 8 Jun 2021 09:38:46 -0400 Subject: [PATCH 09/32] fixed 81875, 81887. Added mongodb resource Signed-off-by: HackerShark --- controls/V-81875.rb | 10 +++- controls/V-81887.rb | 11 ++-- inputs.yml | 1 + inspec.yml | 5 ++ libraries/mongo_command.rb | 116 +++++++++++++++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 libraries/mongo_command.rb diff --git a/controls/V-81875.rb b/controls/V-81875.rb index da8a4d8..043f3ff 100644 --- a/controls/V-81875.rb +++ b/controls/V-81875.rb @@ -74,7 +74,13 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w{net ssl FIPSMode}) { should cmp 'true' } + if input('is_sensitive') + describe yaml(input('mongod_conf')) do + its(%w{net ssl FIPSMode}) { should cmp 'true' } + end + else + describe 'The system is not a classified environment, therefore for this control is NA' do + skip 'The system is not a classified environment, therefore for this control is NA' + end end end diff --git a/controls/V-81887.rb b/controls/V-81887.rb index 5695a4e..bd01355 100644 --- a/controls/V-81887.rb +++ b/controls/V-81887.rb @@ -43,11 +43,14 @@ tag "documentable": false tag "severity_override_guidance": false + mongodb_service_account = input('mongodb_service_account') + mongodb_service_group = input('mongodb_service_group') + if file(input('mongod_conf')).exist? describe file(input('mongod_conf')) do it { should_not be_more_permissive_than('0755') } - its('owner') { should be_in input('mongodb_service_account') } - its('group') { should be_in input('mongodb_service_group') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } end else describe 'This control must be reviewed manually because the configuration @@ -60,8 +63,8 @@ if file(input('mongo_data_dir')).exist? describe directory(input('mongo_data_dir')) do it { should_not be_more_permissive_than('0755') } - its('owner') { should be_in input('mongodb_service_account') } - its('group') { should be_in input('mongodb_service_group') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } end else describe 'This control must be reviewed manually because the Mongodb data diff --git a/inputs.yml b/inputs.yml index 002c1f7..10475f6 100644 --- a/inputs.yml +++ b/inputs.yml @@ -55,3 +55,4 @@ accountAdmin01_allowed_role: ['[ ] } '] +is_sensitive: true diff --git a/inspec.yml b/inspec.yml index a7d887c..78393c3 100644 --- a/inspec.yml +++ b/inspec.yml @@ -134,3 +134,8 @@ inputs: description: Mongodb Service Group type: array value: ["mongodb", "mongod"] + + - name: is_sensitive + description: MongoDB is deployed in a classified environment + type: boolean + value: true diff --git a/libraries/mongo_command.rb b/libraries/mongo_command.rb new file mode 100644 index 0000000..ed75fa1 --- /dev/null +++ b/libraries/mongo_command.rb @@ -0,0 +1,116 @@ +require 'json' + +class MongoCommand < Inspec.resource(1) + name 'mongo_command' + desc 'Runs a MongoDB command using the mongo CLI against a given database (default database: admin)' + example <<-EOL + describe mongo_command('db.showRoles()') do + its('params.length') { should be > 0 } + end + EOL + + attr_reader :command, :database, :params + + def initialize(command, options = {}) + @command = command + @username = options[:username] + @password = options[:password] + @database = options.fetch(:database, 'admin') + @allow_auth_errors = options.fetch(:allow_auth_errors, false) + @tls = options.fetch(:tls, true) + @verify_ssl = options.fetch(:verify_ssl, true) + + check_for_cli_command + @inspec_command = run_mongo_command(command) + @params = parse(@inspec_command.stdout) + end + + def stdout + @inspec_command.stdout + end + + def stderr + @inspec_command.stderr + end + + def to_s + str = "MongoDB Command (#{@command}" + str += ", username: #{@username}" unless @username.nil? + str += ", password: " unless @password.nil? + str += ')' + + str + end + + private + + def parse(output) + # return right away if stdout is nil + return [] if output.nil? + + # strip any network warnings from the output + # Unfortunately, it appears the --sslAllowInvalidHostnames doesn't actually squelch + # any warnings, even when using --quiet mode + output_lines = output.lines.delete_if { |line| line.include?(' W NETWORK ')} + output_lines = output.lines.delete_if { |line| line.include?('UUID(')} + + # if, after removing any network warnings, there are no lines to process, + # we received no command output. + return [] if output_lines.empty? + + # put our output back together as a string + output = output_lines.join + + # skip the whole resource if we could not run the command at all + return skip_resource "User is not authorized to run command #{command}" if + is_auth_error?(output) && !auth_errors_allowed? + + # if the output indicates there's an authorization error, and we allow auth + # errors, we won't throw an exception, just set the params to an empty array. + return [] if is_auth_error?(output) && auth_errors_allowed? + + # At this point, we should have parseable JSON we can use and no auth errors. + # Let's read it in. + JSON.parse(output.to_s) + rescue JSON::ParserError => e + skip_resource "Unable to parse JSON response from mongo client: #{e.message}" unless @allow_auth_errors + [] + end + + def check_for_cli_command + check_command = inspec.command(format_command("db.version()")) + if check_command.exit_status != 0 + skip_resource "Unable to run mongo commands: #{check_command.stderr}" + end + end + + def run_mongo_command(command) + inspec.command(format_command(command)) + end + + def tls_verify_disabled? + ['false', false].include?(@verify_ssl) + end + + def tls_disabled? + ['false', false].include?(@tls) + end + + def is_auth_error?(output) + output.include?('Error: not authorized') + end + + def auth_errors_allowed? + @allow_auth_errors == true + end + + def format_command(command) + command = %{echo "#{command}" | mongo --quiet #{database}} + command += " --tls" unless tls_disabled? + command += " --username #{@username}" unless @username.nil? + command += " --password #{@password}" unless @password.nil? + command += " --tlsAllowInvalidCertificates" if tls_verify_disabled? && tls_disabled? + command += " --tlsAllowInvalidHostnames" if tls_verify_disabled? && tls_disabled? + command + end +end \ No newline at end of file From 174f4473207740b0abf3044731bd8e965e2e0726 Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Wed, 9 Jun 2021 10:53:32 -0400 Subject: [PATCH 10/32] SSL and other auth ehancments to mongo_command resource Signed-off-by: Rony Xavier --- libraries/mongo_command.rb | 61 +++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/libraries/mongo_command.rb b/libraries/mongo_command.rb index ed75fa1..3e49287 100644 --- a/libraries/mongo_command.rb +++ b/libraries/mongo_command.rb @@ -12,13 +12,18 @@ class MongoCommand < Inspec.resource(1) attr_reader :command, :database, :params def initialize(command, options = {}) - @command = command - @username = options[:username] - @password = options[:password] - @database = options.fetch(:database, 'admin') - @allow_auth_errors = options.fetch(:allow_auth_errors, false) - @tls = options.fetch(:tls, true) - @verify_ssl = options.fetch(:verify_ssl, true) + @command = command + @username = options[:username] + @password = options[:password] + @database = options.fetch(:database, 'admin') + @host = options.fetch(:host, '127.0.0.1') + @allow_auth_errors = options.fetch(:allow_auth_errors, false) + @ssl = options.fetch(:ssl, false) + @ssl_pem_key_file = options.fetch(:ssl_pem_key_file, nil) + @ssl_ca_file = options.fetch(:ssl_ca_file, nil) + @authentication_database = options.fetch(:authentication_database, nil) + @authentication_mechanism = options.fetch(:authentication_mechanism, nil) + @verify_ssl = options.fetch(:verify_ssl, true) check_for_cli_command @inspec_command = run_mongo_command(command) @@ -35,8 +40,7 @@ def stderr def to_s str = "MongoDB Command (#{@command}" - str += ", username: #{@username}" unless @username.nil? - str += ", password: " unless @password.nil? + str += ", database: #{@database}" str += ')' str @@ -65,6 +69,10 @@ def parse(output) return skip_resource "User is not authorized to run command #{command}" if is_auth_error?(output) && !auth_errors_allowed? + # skip the whole resource if we could not run the command at all + return skip_resource "Database connection error." if + is_connection_error?(stdout+stderr) + # if the output indicates there's an authorization error, and we allow auth # errors, we won't throw an exception, just set the params to an empty array. return [] if is_auth_error?(output) && auth_errors_allowed? @@ -88,16 +96,22 @@ def run_mongo_command(command) inspec.command(format_command(command)) end - def tls_verify_disabled? + def ssl_verify_disabled? ['false', false].include?(@verify_ssl) end - def tls_disabled? - ['false', false].include?(@tls) + def ssl_enabled? + ['true', true].include?(@ssl) end def is_auth_error?(output) - output.include?('Error: not authorized') + output.include?('Error: not authorized') || + output.include?('Error: there are no users authenticated') || + output.include?('requires authentication') + end + + def is_connection_error?(output) + output.include?('exception: connect failed') end def auth_errors_allowed? @@ -105,12 +119,25 @@ def auth_errors_allowed? end def format_command(command) - command = %{echo "#{command}" | mongo --quiet #{database}} - command += " --tls" unless tls_disabled? + command = %{echo "#{command}" | mongo --quiet #{database} --host '#{@host}'} command += " --username #{@username}" unless @username.nil? command += " --password #{@password}" unless @password.nil? - command += " --tlsAllowInvalidCertificates" if tls_verify_disabled? && tls_disabled? - command += " --tlsAllowInvalidHostnames" if tls_verify_disabled? && tls_disabled? + + command += " --authenticationDatabase" unless @authentication_database.nil? + command += " --authenticationMechanism" unless @authentication_mechanism.nil? + + command += " --ssl" if ssl_enabled? + + if ssl_enabled? + command += " --sslAllowInvalidCertificates" if ssl_verify_disabled? + command += " --sslAllowInvalidHostnames" if ssl_verify_disabled? + + command += " --sslPEMKeyFile #{@ssl_pem_key_file}" unless @ssl_pem_key_file.nil? + command += " --sslCAFile #{@ssl_ca_file}" unless @ssl_ca_file.nil? + end + + + puts command command end end \ No newline at end of file From b5ae6646899a0f80f56575f364fba0fb67a987c4 Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Wed, 9 Jun 2021 13:23:50 -0400 Subject: [PATCH 11/32] SSL and other auth ehancments to mongo_command resource Signed-off-by: Rony Xavier --- libraries/mongo_command.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/mongo_command.rb b/libraries/mongo_command.rb index 3e49287..1aa65bb 100644 --- a/libraries/mongo_command.rb +++ b/libraries/mongo_command.rb @@ -67,7 +67,7 @@ def parse(output) # skip the whole resource if we could not run the command at all return skip_resource "User is not authorized to run command #{command}" if - is_auth_error?(output) && !auth_errors_allowed? + is_auth_error?(stdout+stderr) && !auth_errors_allowed? # skip the whole resource if we could not run the command at all return skip_resource "Database connection error." if @@ -111,7 +111,8 @@ def is_auth_error?(output) end def is_connection_error?(output) - output.include?('exception: connect failed') + output.include?('exception: connect failed') || + output.include?('Failed global initialization') end def auth_errors_allowed? From e8e12173baefec7a31c530f8b25413944f6380d6 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Wed, 9 Jun 2021 17:28:42 -0400 Subject: [PATCH 12/32] fixed 81845, 81857, 81881, 81883, 81899, replaced classified description with sensitive in inspec.yml, added additional inputs to accomodate new mongodb resource in inspec.yml and input.yml Signed-off-by: HackerShark --- controls/V-81845.rb | 83 ++------------------------------------------ controls/V-81857.rb | 84 ++------------------------------------------- controls/V-81881.rb | 10 ++++-- controls/V-81883.rb | 10 ++++-- controls/V-81899.rb | 77 ++--------------------------------------- inputs.yml | 7 ++++ inspec.yml | 43 ++++++++++++++++++++--- 7 files changed, 68 insertions(+), 246 deletions(-) diff --git a/controls/V-81845.rb b/controls/V-81845.rb index 185c8be..02fa6fc 100644 --- a/controls/V-81845.rb +++ b/controls/V-81845.rb @@ -39,86 +39,7 @@ tag "documentable": false tag "severity_override_guidance": false - a = [] - dbnames = [] - - if input('mongo_use_pki') == 'true' - get_databases = command("sudo mongo --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - else - get_databases = command("mongo -u '#{input('user')}' -p '#{input('password')}' --quiet --eval \ - 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') + describe 'A manual review is required to determine the required levels of protection for DBMS server securables by type of login.' do + skip 'A manual review is required to determine the required levels of protection for DBMS server securables by type of login.' end - - if get_databases.grep(/error/).empty? == false - describe 'Verify the correct credentials or a valid client certificate is used to execute the query.' do - skip 'Verify the correct credentials or a valid client certificate is used to execute the query.' - end - else - get_databases.each do |db| - if db.include? 'databases' - - a.push(db) - get_databases.delete(db) - end - end - - get_databases.each do |db| - - loc_colon = db.index('"') - names = db[0, loc_colon] - dbnames.push(names) - end - - if dbnames.empty? - describe 'There are no mongo databases, therefore for this control is NA' do - skip 'There are no mongo databases, therefore for this control is NA' - end - end - - if !dbnames.empty? - dbnames.each do |dbs| - if input('mongo_use_pki') == 'true' - users = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - users = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' --quiet --eval \ - 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - users.each do |t| - - loc_colon = t.index(':') - - user = t[loc_colon+3..-1] - - loc_quote = user.index('"') - - username = user[0, loc_quote] - - if input('mongo_use_pki') == 'true' - getdb_roles = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - getdb_roles = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' --quiet --eval \ - 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - getdb_roles.each do |r| - remove_role = r.index('[') - rr = r[remove_role..-1] - - allowed_role = username - describe "The database role for user: #{username}" do - subject { rr } - it { should be_in input("#{allowed_role}_allowed_role") } - end - end - end - end - end - end end diff --git a/controls/V-81857.rb b/controls/V-81857.rb index 425f53e..f10fb07 100644 --- a/controls/V-81857.rb +++ b/controls/V-81857.rb @@ -58,87 +58,7 @@ tag "documentable": false tag "severity_override_guidance": false - a = [] - dbnames = [] - - if input('mongo_use_pki') == 'true' - get_databases = command("sudo mongo --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - else - get_databases = command("mongo -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - end - - if get_databases.grep(/error/).empty? == false - describe 'Verify the correct credentials or a valid client certificate is used to execute the query.' do - skip 'Verify the correct credentials or a valid client certificate is used to execute the query.' - end - else - get_databases.each do |db| - if db.include? 'databases' - - a.push(db) - get_databases.delete(db) - end - end - - get_databases.each do |db| - - loc_colon = db.index('"') - names = db[0, loc_colon] - dbnames.push(names) - end - - if dbnames.empty? - describe 'There are no mongo databases, therefore for this control is NA' do - skip 'There are no mongo databases, therefore for this control is NA' - end - end - - if !dbnames.empty? - dbnames.each do |dbs| - - if input('mongo_use_pki') == 'true' - users = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - users = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - users.each do |t| - - loc_colon = t.index(':') - - user = t[loc_colon+3..-1] - - loc_quote = user.index('"') - - username = user[0, loc_quote] - - if input('mongo_use_pki') == 'true' - getdb_roles = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - getdb_roles = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - getdb_roles.each do |r| - remove_role = r.index('[') - rr = r[remove_role..-1] - - allowed_role = username - describe "The database role for user: #{username}" do - subject { rr } - it { should be_in input("#{allowed_role}_allowed_role") } - end - end - end - end - end + describe 'A manual review is required to determine if any roles or users have unauthorized access' do + skip 'A manual review is required to determine if any roles or users have unauthorized access' end end diff --git a/controls/V-81881.rb b/controls/V-81881.rb index c1e06a3..08d199c 100644 --- a/controls/V-81881.rb +++ b/controls/V-81881.rb @@ -69,7 +69,13 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w{storage journal enabled}) { should cmp 'true' } + describe.one do + describe yaml(input('mongod_conf')) do + its(%w{storage journal enabled}) { should cmp 'true' } + end + describe processes('mongod') do + its('commands.join') { should_not match /--nojournal/} + end end + end diff --git a/controls/V-81883.rb b/controls/V-81883.rb index 84a3661..ecb4e07 100644 --- a/controls/V-81883.rb +++ b/controls/V-81883.rb @@ -55,7 +55,13 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w{security enableEncryption}) { should cmp 'true' } + describe.one do + describe yaml(input('mongod_conf')) do + its(%w{security enableEncryption}) { should cmp 'true' } + end + describe processes('mongod') do + its('commands.join') { should_not match /--enableEncryption false/} + end end + end diff --git a/controls/V-81899.rb b/controls/V-81899.rb index 81d0473..bac5d5e 100644 --- a/controls/V-81899.rb +++ b/controls/V-81899.rb @@ -62,80 +62,7 @@ tag "documentable": false tag "severity_override_guidance": false - a = [] - dbnames = [] - - if input('mongo_use_pki') == 'true' - get_databases = command("sudo mongo --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - else - get_databases = command("mongo -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - end - - if get_databases.grep(/error/).empty? == false - describe 'Verify the correct credentials or a valid client certificate is used to execute the query.' do - skip 'Verify the correct credentials or a valid client certificate is used to execute the query.' - end - else - get_databases.each do |db| - if db.include? 'databases' - a.push(db) - get_databases.delete(db) - end - end - - get_databases.each do |db| - loc_colon = db.index('"') - names = db[0, loc_colon] - dbnames.push(names) - end - - if dbnames.empty? - describe 'There are no mongo databases, therefore for this control is NA' do - skip 'There are no mongo databases, therefore for this control is NA' - end - end - - if !dbnames.empty? - dbnames.each do |dbs| - - if input('mongo_use_pki') == 'true' - users = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - users = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - users.each do |t| - loc_colon = t.index(':') - user = t[loc_colon+3..-1] - loc_quote = user.index('"') - username = user[0, loc_quote] - - if input('mongo_use_pki') == 'true' - getdb_roles = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - getdb_roles = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - getdb_roles.each do |r| - remove_role = r.index('[') - rr = r[remove_role..-1] - allowed_role = username - describe "The database role for user: #{username}" do - subject { rr } - it { should be_in input("#{allowed_role}_allowed_role") } - end - end - end - end - end + describe 'A manual review is required to determine if any functionality considered privileged has access privileges granted to non-privileged users' do + skip 'A manual review is required to determine if any functionality considered privileged has access privileges granted to non-privileged users' end end diff --git a/inputs.yml b/inputs.yml index 10475f6..3ce8f53 100644 --- a/inputs.yml +++ b/inputs.yml @@ -22,6 +22,13 @@ approved_mongo_packages: [ user: 'mongoadmin' password: 'mongoadmin' +mongod_hostname: '127.0.0.1' +ssl: false +verify_ssl: false +mongod_client_pem: nil +mongod_cafile: nil +authentication_database: nil +authentication_mechanism: nil mongodb_service_account: ["mongodb", "mongod"] mongodb_service_group: ["mongodb", "mongod"] diff --git a/inspec.yml b/inspec.yml index 78393c3..098bb9d 100644 --- a/inspec.yml +++ b/inspec.yml @@ -69,20 +69,55 @@ inputs: ] required: true - - name: user + - name: username description: 'User to log into the mongo database' type: string - value: 'mongoadmin' + value: nil required: true sensitive: true - name: password description: 'password to log into the mongo database' type: string - value: 'mongoadmin' + value: nil required: true sensitive: true + - name: mongod_hostname + description: hostname for mongodb database + type: string + value: '127.0.0.1' + + - name: ssl + description: ssl enabled or not + type: boolean + value: false + + - name: verify_ssl + description: verify ssl + type: boolean + value: false + + - name: mongod_client_pem + description: PEM file for mongo authentication + type: string + value: nil + + - name: mongod_cafile + description: cafile for mongo authentication + type: string + value: nil + + - name: authentication_database + description: authentication database + type: string + value: nil + + - name: authentication_mechanism + description: authentication mechanism + type: string + value: nil + - name: admin_db_users description: 'List of authorized users of the admn database' type: array @@ -136,6 +171,6 @@ inputs: value: ["mongodb", "mongod"] - name: is_sensitive - description: MongoDB is deployed in a classified environment + description: MongoDB is deployed in a sensitive environment type: boolean value: true From e88cee3226d85f3aaabfb89ed2d730bc2654a125 Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Wed, 9 Jun 2021 19:18:31 -0400 Subject: [PATCH 13/32] Add support to non standard mongodb port Signed-off-by: Rony Xavier --- libraries/mongo_command.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/mongo_command.rb b/libraries/mongo_command.rb index 1aa65bb..cbbf032 100644 --- a/libraries/mongo_command.rb +++ b/libraries/mongo_command.rb @@ -17,6 +17,7 @@ def initialize(command, options = {}) @password = options[:password] @database = options.fetch(:database, 'admin') @host = options.fetch(:host, '127.0.0.1') + @port = options.fetch(:port, '27017') @allow_auth_errors = options.fetch(:allow_auth_errors, false) @ssl = options.fetch(:ssl, false) @ssl_pem_key_file = options.fetch(:ssl_pem_key_file, nil) @@ -120,7 +121,7 @@ def auth_errors_allowed? end def format_command(command) - command = %{echo "#{command}" | mongo --quiet #{database} --host '#{@host}'} + command = %{echo "#{command}" | mongo --quiet #{database} --host '#{@host}' --port '#{@port}'} command += " --username #{@username}" unless @username.nil? command += " --password #{@password}" unless @password.nil? From d7df8c426935869ed3b8b57bb09c1750d5079c0b Mon Sep 17 00:00:00 2001 From: HackerShark Date: Thu, 10 Jun 2021 12:10:27 -0400 Subject: [PATCH 14/32] fixed 81863, 81877, 81881, 81883, 81893, 81901, 81903, 81905, 81907, 81909, 81915, 81919, 81921, 81923 Signed-off-by: HackerShark --- controls/V-81863.rb | 64 ++-------------------------------- controls/V-81877.rb | 84 ++------------------------------------------- controls/V-81881.rb | 13 ++++--- controls/V-81883.rb | 6 +++- controls/V-81893.rb | 7 ++-- controls/V-81901.rb | 7 ++-- controls/V-81903.rb | 12 ++++--- controls/V-81905.rb | 1 + controls/V-81907.rb | 1 + controls/V-81909.rb | 83 ++------------------------------------------ controls/V-81915.rb | 30 +++------------- controls/V-81919.rb | 34 +++++++++--------- controls/V-81921.rb | 2 +- controls/V-81923.rb | 2 +- 14 files changed, 54 insertions(+), 292 deletions(-) diff --git a/controls/V-81863.rb b/controls/V-81863.rb index d480ecd..ba006f0 100644 --- a/controls/V-81863.rb +++ b/controls/V-81863.rb @@ -69,67 +69,9 @@ tag "documentable": false tag "severity_override_guidance": false - a = [] - dbnames = [] - - if input('mongo_use_pki') == 'true' - get_databases = command("sudo mongo --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - else - get_databases = command("mongo -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - end - - if get_databases.grep(/error/).empty? == false - describe 'Verify the correct credentials or a valid client certificate is used to execute the query.' do - skip 'Verify the correct credentials or a valid client certificate is used to execute the query.' - end - else - get_databases.each do |db| - if db.include? 'databases' - - a.push(db) - get_databases.delete(db) - end - - end - - get_databases.each do |db| - - loc_colon = db.index('"') - names = db[0, loc_colon] - dbnames.push(names) - end - - dbnames.each do |dbs| - - if input('mongo_use_pki') == 'true' - users = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - users = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - users.each do |t| - - loc_colon = t.index(':') - - user = t[loc_colon+3..-1] - - loc_quote = user.index('"') - - username = user[0, loc_quote] - allowed_db = dbs - describe "Database users of database: #{dbs}" do - subject { username } - it { should be_in input("#{allowed_db}_db_users") } - end - end - end - end + describe 'A manual review is required to determine if a user is found not be a memer or an appropriate organization that can access the database.' do + skip 'A manual review is required to determine if a user is found not be a memer or an appropriate organization that can access the database.' + end describe yaml(input('mongod_conf')) do its(%w{security authorization}) { should cmp 'enabled' } diff --git a/controls/V-81877.rb b/controls/V-81877.rb index 14ee9b5..6052136 100644 --- a/controls/V-81877.rb +++ b/controls/V-81877.rb @@ -86,87 +86,7 @@ tag "documentable": false tag "severity_override_guidance": false - a = [] - dbnames = [] - - if input('mongo_use_pki') == 'true' - get_databases = command("sudo mongo --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - else - get_databases = command("mongo -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - end - - if get_databases.grep(/error/).empty? == false - describe 'Verify the correct credentials or a valid client certificate is used to execute the query.' do - skip 'Verify the correct credentials or a valid client certificate is used to execute the query.' - end - else - get_databases.each do |db| - if db.include? 'databases' - - a.push(db) - get_databases.delete(db) - end - end - - get_databases.each do |db| - - loc_colon = db.index('"') - names = db[0, loc_colon] - dbnames.push(names) - end - - if dbnames.empty? - describe 'There are no mongo databases, therefore for this control is NA' do - skip 'There are no mongo databases, therefore for this control is NA' - end - end - - if !dbnames.empty? - - dbnames.each do |dbs| - - if input('mongo_use_pki') == 'true' - users = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - users = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - users.each do |t| - - loc_colon = t.index(':') - - user = t[loc_colon+3..-1] - - loc_quote = user.index('"') - - username = user[0, loc_quote] - - if input('mongo_use_pki') == 'true' - getdb_roles = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - getdb_roles = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - getdb_roles.each do |r| - remove_role = r.index('[') - rr = r[remove_role..-1] - - allowed_role = username - describe "The database role for user: #{username}" do - subject { rr } - it { should be_in input("#{allowed_role}_allowed_role") } - end - end - end - end - end + describe 'A manual review is required to determine if a user has a role with innapropriate privileges as well as if those roles have the proper privileges & inherited privileges' do + skip 'A manual review is required to determine if a user has a role with innapropriate privileges as well as if those roles have the proper privileges & inherited privileges' end end diff --git a/controls/V-81881.rb b/controls/V-81881.rb index 08d199c..2b2f56a 100644 --- a/controls/V-81881.rb +++ b/controls/V-81881.rb @@ -69,13 +69,12 @@ tag "documentable": false tag "severity_override_guidance": false - describe.one do - describe yaml(input('mongod_conf')) do - its(%w{storage journal enabled}) { should cmp 'true' } - end - describe processes('mongod') do - its('commands.join') { should_not match /--nojournal/} - end + describe yaml(input('mongod_conf')) do + its(%w{storage journal enabled}) { should cmp 'true' } + end + + describe processes('mongod') do + its('commands.join') { should_not match /--nojournal/} end end diff --git a/controls/V-81883.rb b/controls/V-81883.rb index ecb4e07..57f1aa6 100644 --- a/controls/V-81883.rb +++ b/controls/V-81883.rb @@ -60,8 +60,12 @@ its(%w{security enableEncryption}) { should cmp 'true' } end describe processes('mongod') do - its('commands.join') { should_not match /--enableEncryption false/} + its('commands.join') { should match /--enableEncryption true/} end end + describe processes('mongod') do + its('commands.join') { should_not match /--enableEncryption false/} + end + end diff --git a/controls/V-81893.rb b/controls/V-81893.rb index 9ad5d64..88e9916 100644 --- a/controls/V-81893.rb +++ b/controls/V-81893.rb @@ -55,10 +55,7 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w{security authorization}) { should cmp 'enabled' } - end - describe yaml(input('mongod_conf')) do - its(%w{security redactClientLogData}) { should cmp 'true' } + describe 'A manual review is required to check custom database code to verfiy that error messages do not contain information beyond what is needed for troubleshooting the issue.' do + skip 'A manual review is required to check custom database code to verfiy that error messages do not contain information beyond what is needed for troubleshooting the issue.' end end \ No newline at end of file diff --git a/controls/V-81901.rb b/controls/V-81901.rb index 11ac7f1..6d79a8d 100644 --- a/controls/V-81901.rb +++ b/controls/V-81901.rb @@ -47,10 +47,7 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w{auditLog destination}) { should cmp 'syslog' } - end - describe yaml(input('mongod_conf')) do - its(%w{auditLog filter}) { should be_nil } + describe 'A manual review is required to check if replica sets or the rolling maintenance approach is not used for changes to the audit events & filters' do + skip 'A manual review is required to check if replica sets or the rolling maintenance approach is not used for changes to the audit events & filters' end end diff --git a/controls/V-81903.rb b/controls/V-81903.rb index 922ed6b..b5d235c 100644 --- a/controls/V-81903.rb +++ b/controls/V-81903.rb @@ -50,10 +50,12 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w{storage dbPath}) { should cmp '/data/db' } - end - describe yaml(input('mongod_conf')) do - its(%w{auditLog destination}) { should cmp 'syslog' } + describe.one do + describe yaml(input('mongod_conf')) do + its(%w{auditLog destination}) { should cmp 'syslog' } + end + describe processes('mongod') do + its('commands.join') { should match /--auditDestination syslog/} + end end end diff --git a/controls/V-81905.rb b/controls/V-81905.rb index 77c2a33..48af860 100644 --- a/controls/V-81905.rb +++ b/controls/V-81905.rb @@ -62,5 +62,6 @@ describe yaml(input('mongod_conf')) do its(%w{auditLog destination}) { should_not cmp 'file' } + its(%w{auditLog destination}) { should_not be_nil } end end diff --git a/controls/V-81907.rb b/controls/V-81907.rb index 5b71158..4f3e56b 100644 --- a/controls/V-81907.rb +++ b/controls/V-81907.rb @@ -51,5 +51,6 @@ describe yaml(input('mongod_conf')) do its(%w{auditLog destination}) { should_not cmp 'file' } + its(%w{auditLog destination}) { should_not be_nil } end end diff --git a/controls/V-81909.rb b/controls/V-81909.rb index 700bb6c..3ff250f 100644 --- a/controls/V-81909.rb +++ b/controls/V-81909.rb @@ -60,86 +60,7 @@ tag "documentable": false tag "severity_override_guidance": false - a = [] - dbnames = [] - - if input('mongo_use_pki') == 'true' - get_databases = command("sudo mongo --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - else - get_databases = command("mongo -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - end - - if get_databases.grep(/error/).empty? == false - describe 'Verify the correct credentials or a valid client certificate is used to execute the query.' do - skip 'Verify the correct credentials or a valid client certificate is used to execute the query.' - end - else - get_databases.each do |db| - if db.include? 'databases' - - a.push(db) - get_databases.delete(db) - end - end - - get_databases.each do |db| - - loc_colon = db.index('"') - names = db[0, loc_colon] - dbnames.push(names) - end - - if dbnames.empty? - describe 'There are no mongo databases, therefore for this control is NA' do - skip 'There are no mongo databases, therefore for this control is NA' - end - end - - if !dbnames.empty? - dbnames.each do |dbs| - - if input('mongo_use_pki') == 'true' - users = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - users = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - users.each do |t| - - loc_colon = t.index(':') - - user = t[loc_colon+3..-1] - - loc_quote = user.index('"') - - username = user[0, loc_quote] - - if input('mongo_use_pki') == 'true' - getdb_roles = command("mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - getdb_roles = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - getdb_roles.each do |r| - remove_role = r.index('[') - rr = r[remove_role..-1] - - allowed_role = username - describe "The database role for user: #{username}" do - subject { rr } - it { should be_in input("#{allowed_role}_allowed_role") } - end - end - end - end - end + describe 'A manual review is required to determine if any permissions exist that are not documented and approved' do + skip 'A manual review is required to determine if any permissions exist that are not documented and approved' end end diff --git a/controls/V-81915.rb b/controls/V-81915.rb index c1a442e..7c3fbe7 100644 --- a/controls/V-81915.rb +++ b/controls/V-81915.rb @@ -13,10 +13,7 @@ If any mongos process is running (a MongoDB shared cluster) the \"userCacheInvalidationIntervalSecs\" option can be used to specify the cache timeout. - The default is \"30\" seconds and the minimum is \"1\" second. - - In the saslauthd file, if MECH is not equal to ldap, this is a finding. - + The default is \"30\" seconds and the minimum is \"1\" second. " desc "fix", "If MongoDB is configured to authenticate using SASL and LDAP/Active Directory modify and restart the saslauthd command line options in @@ -30,17 +27,7 @@ can be changed from the default \"30\" seconds. This is accomplished by modifying the mongos configuration file (default location: /etc/mongod.conf) and then restarting mongos. - - In the mongod.conf, set timeoutMS to 1000. - security: - ldap: - timeoutMS: 1000 - - In the saslauthd file ( default location: /etc/sysconfig/saslauthd ), set FLAGS to -t 900 - FLAGS= -t 900 - - Also, in the saslauthd file, set MECH to ldap - MECH=ldap " + " impact 0.5 tag "severity": "medium" @@ -55,18 +42,9 @@ tag "severity_override_guidance": false if input('mongo_use_saslauthd') == 'true' && input('mongo_use_ldap') == 'true' - describe ini(input('saslauthd')) do - its(%w{MECH}) {should cmp 'ldap'} - end - describe ini(input('saslauthd')) do - its('FLAGS') {should eq '-t 900'} + describe processes('saslauthd') do + its('commands.join') { should match /-t\s/} end - describe yaml(input('mongod_conf')) do - its(%w{security authorization}) { should cmp 'enabled'} - end - describe yaml(input('mongod_conf')) do - its(%w{security ldap timeoutMS}) { should cmp '10000' } - end else impact 0.0 describe 'This control is Not Applicable because MongoDB is not configured to authenticate using SASL and LDAP.' do diff --git a/controls/V-81919.rb b/controls/V-81919.rb index 5d1e4a1..6eb7a89 100644 --- a/controls/V-81919.rb +++ b/controls/V-81919.rb @@ -60,22 +60,22 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w{security kmip serverName}) { should_not be_nil } + describe.one do + describe yaml(input('mongod_conf')) do + its(%w{security kmip serverName}) { should_not be_nil } + its(%w{security kmip port}) { should_not be_nil } + its(%w{security kmip port}) { should_not be_nil } + its(%w{security kmip serverCAFile}) { should_not be_nil } + its(%w{security kmip clientCertificateFile}) { should_not be_nil } + its(['security' , 'enableEncryption']) { should cmp 'true' } + end + describe processes('mongod') do + its('commands.join') { should match /--enableEncryption/ } + its('commands.join') { should match /--kmipServerName/ } + its('commands.join') { should match /--kmipPort/ } + its('commands.join') { should match /--kmipServerCAFile/ } + its('commands.join') { should match /--kmipClientCertificateFile/ } + end end - describe yaml(input('mongod_conf')) do - its(%w{security kmip port}) { should_not be_nil } - end - describe yaml(input('mongod_conf')) do - its(%w{security kmip port}) { should_not be_nil } - end - describe yaml(input('mongod_conf')) do - its(%w{security kmip serverCAFile}) { should_not be_nil } - end - describe yaml(input('mongod_conf')) do - its(%w{security kmip clientCertificateFile}) { should_not be_nil } - end - describe yaml(input('mongod_conf')) do - its(['security' , 'enableEncryption']) { should cmp 'true' } - end + end diff --git a/controls/V-81921.rb b/controls/V-81921.rb index 586c6d9..3f8348a 100644 --- a/controls/V-81921.rb +++ b/controls/V-81921.rb @@ -62,6 +62,6 @@ its(%w{net ssl mode}) { should cmp 'requireSSL' } end describe yaml(input('mongod_conf')) do - its(%w{net ssl PEMKeyFile}) { should cmp '/etc/ssl/mongodb.pem' } + its(%w{net ssl PEMKeyFile}) { should_not be nil } end end diff --git a/controls/V-81923.rb b/controls/V-81923.rb index cc565fb..ae8a9af 100644 --- a/controls/V-81923.rb +++ b/controls/V-81923.rb @@ -64,6 +64,6 @@ its(%w{net ssl mode}) { should cmp 'requireSSL' } end describe yaml(input('mongod_conf')) do - its(%w{net ssl PEMKeyFile}) { should cmp '/etc/ssl/mongodb.pem' } + its(%w{net ssl PEMKeyFile}) { should_not be nil } end end From 012a9c8bc00368f17356cc69c2f58932183130cf Mon Sep 17 00:00:00 2001 From: HackerShark Date: Tue, 22 Jun 2021 15:50:43 -0400 Subject: [PATCH 15/32] fixed 81917, added new input to inspec.yml and inputs.yml Signed-off-by: HackerShark --- controls/V-81917.rb | 20 +++++++++++++++++--- inputs.yml | 2 ++ inspec.yml | 5 +++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/controls/V-81917.rb b/controls/V-81917.rb index 5a12431..c3c3f10 100644 --- a/controls/V-81917.rb +++ b/controls/V-81917.rb @@ -42,8 +42,22 @@ tag "documentable": false tag "severity_override_guidance": false - describe 'The mongodb ssl certificate issuer' do - subject { command("openssl x509 -in /etc/ssl/mongodb.pem -text | grep -i 'issuer'").stdout } - it { should include 'DoD' } + # Process flag takes precedence over the conf file + x509_conf = yaml(input('mongod_conf'))['net', 'tls', 'certificateKeyFile'] + x509_process_flag = processes('mongod').commands.join.gsub('--tlsCertificateKeyFile', '').strip + + x509_cert_file = input('x509_cert_file') unless input('x509_cert_file').nil? + x509_cert_file = x509_conf unless x509_conf.nil? + x509_cert_file = x509_process_flag unless x509_process_flag.nil? + + + if file(x509_cert_file).exist? + describe x509_certificate(x509_cert_file) do + its('issuer_dn') { should eq input('authorized_certificate_authority') } + end + else + describe 'x509 file not found, manual review required' do + skip 'x509 file not found, manual review required' + end end end diff --git a/inputs.yml b/inputs.yml index 3ce8f53..4519aa7 100644 --- a/inputs.yml +++ b/inputs.yml @@ -63,3 +63,5 @@ accountAdmin01_allowed_role: ['[ '] is_sensitive: true + +x509_cert_file: "/etc/ssl/mongodb.pem" \ No newline at end of file diff --git a/inspec.yml b/inspec.yml index 098bb9d..e970abf 100644 --- a/inspec.yml +++ b/inspec.yml @@ -174,3 +174,8 @@ inputs: description: MongoDB is deployed in a sensitive environment type: boolean value: true + + - name: x509_cert_file + description: x509 cert file location + type: string + value: "/etc/ssl/mongodb.pem" From 9b11453e9341a52a74e73fe0f5768ca11c8a846c Mon Sep 17 00:00:00 2001 From: HackerShark Date: Tue, 22 Jun 2021 15:52:36 -0400 Subject: [PATCH 16/32] fixed 81865 Signed-off-by: HackerShark --- controls/V-81865.rb | 73 ++------------------------------------------- 1 file changed, 2 insertions(+), 71 deletions(-) diff --git a/controls/V-81865.rb b/controls/V-81865.rb index 01e6452..82c60f1 100644 --- a/controls/V-81865.rb +++ b/controls/V-81865.rb @@ -45,76 +45,7 @@ tag "documentable": false tag "severity_override_guidance": false - a = [] - dbnames = [] - - if input('mongo_use_pki') == 'true' - get_databases = command("sudo mongo --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - else - get_databases = command("mongo -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - end - - if get_databases.grep(/error/).empty? == false - describe 'Verify the correct credentials or a valid client certificate is used to execute the query.' do - skip 'Verify the correct credentials or a valid client certificate is used to execute the query.' - end - else - get_databases.each do |db| - if db.include? 'databases' - - a.push(db) - get_databases.delete(db) - end - end - - get_databases.each do |db| - - loc_colon = db.index('"') - names = db[0, loc_colon] - dbnames.push(names) - end - - dbnames.each do |dbs| - if input('mongo_use_pki') == 'true' - users = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - users = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - users.each do |t| - - loc_colon = t.index(':') - - user = t[loc_colon+3..-1] - - loc_quote = user.index('"') - - username = user[0, loc_quote] - - if input('mongo_use_pki') == 'true' - getdb_roles = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"},{credentials: 1, _id: false})'").stdout.strip.split("\n") - else - getdb_roles = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"},{credentials: 1, _id: false})'").stdout.strip.split("\n") - end - - getdb_roles.each do |r| - - describe "The credential meachanism used for user: #{username}" do - subject { r } - it { should_not include 'SCRAM-SHA-1' } - it { should_not include 'MONGODB-CR' } - end - end - end - end + describe processes('mongod') do + its('commands.join') { should_not match /(SCRAM-SHA1|MONGODB-CR)/} end end From 0ffdb8998a76d249c35ecc01354443ed75f36b2d Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Tue, 22 Jun 2021 21:09:47 -0400 Subject: [PATCH 17/32] Resource update to handle UUID line that makes the JSON invalid Signed-off-by: Rony Xavier --- libraries/mongo_command.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/mongo_command.rb b/libraries/mongo_command.rb index cbbf032..77451e5 100644 --- a/libraries/mongo_command.rb +++ b/libraries/mongo_command.rb @@ -40,6 +40,7 @@ def stderr end def to_s + puts "hi" str = "MongoDB Command (#{@command}" str += ", database: #{@database}" str += ')' @@ -56,8 +57,8 @@ def parse(output) # strip any network warnings from the output # Unfortunately, it appears the --sslAllowInvalidHostnames doesn't actually squelch # any warnings, even when using --quiet mode - output_lines = output.lines.delete_if { |line| line.include?(' W NETWORK ')} - output_lines = output.lines.delete_if { |line| line.include?('UUID(')} + + output_lines = output.lines.delete_if { |line| line.match?(/ W NETWORK |UUID/)} # if, after removing any network warnings, there are no lines to process, # we received no command output. From be5691967423cfb6f9b0f26234825d7cb9a157f3 Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Wed, 23 Jun 2021 02:35:49 -0400 Subject: [PATCH 18/32] Updates to manual controls to populate target info Signed-off-by: Rony Xavier --- controls/V-81845.rb | 21 ++++++++- controls/V-81857.rb | 22 ++++++++- controls/V-81865.rb | 13 ++++-- controls/V-81877.rb | 24 ++++++++-- controls/V-81909.rb | 21 ++++++++- controls/V-81911.rb | 91 ++++++++------------------------------ controls/V-81925.rb | 28 ++++++++++-- controls/V-81927.rb | 18 +++++--- libraries/mongo_command.rb | 30 +++++++------ 9 files changed, 160 insertions(+), 108 deletions(-) diff --git a/controls/V-81845.rb b/controls/V-81845.rb index 02fa6fc..d0774db 100644 --- a/controls/V-81845.rb +++ b/controls/V-81845.rb @@ -39,7 +39,24 @@ tag "documentable": false tag "severity_override_guidance": false - describe 'A manual review is required to determine the required levels of protection for DBMS server securables by type of login.' do - skip 'A manual review is required to determine the required levels of protection for DBMS server securables by type of login.' + mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + + dbs.each do |db| + db_command = "db = db.getSiblingDB('#{db}');db.getRoles({rolesInfo: 1,showPrivileges:true,showBuiltinRoles: true})" + results = mongo_session.query(db_command) + + results.each do |entry| + describe "Manually verify privileges for Role: `#{entry['role']}` within Database: `#{db}` + Privileges: #{entry['privileges']}" do + skip + end + end + end + + if dbs.empty? + describe "No databases found on the target" do + skip + end end end diff --git a/controls/V-81857.rb b/controls/V-81857.rb index f10fb07..16b9531 100644 --- a/controls/V-81857.rb +++ b/controls/V-81857.rb @@ -58,7 +58,25 @@ tag "documentable": false tag "severity_override_guidance": false - describe 'A manual review is required to determine if any roles or users have unauthorized access' do - skip 'A manual review is required to determine if any roles or users have unauthorized access' + mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + + dbs.each do |db| + db_command = "db = db.getSiblingDB('#{db}');db.getUsers()" + results = mongo_session.query(db_command) + + results.each do |entry| + describe "Manually verify roles for User: `#{entry['user']}` within Database: `#{entry['db']}` + Roles: #{entry['roles']}" do + skip + end + end + end + + if dbs.empty? + describe "No databases found on the target" do + skip + end end end diff --git a/controls/V-81865.rb b/controls/V-81865.rb index 82c60f1..4066d18 100644 --- a/controls/V-81865.rb +++ b/controls/V-81865.rb @@ -44,8 +44,15 @@ tag "nist": ["IA-5 (1) (a)"] tag "documentable": false tag "severity_override_guidance": false - - describe processes('mongod') do - its('commands.join') { should_not match /(SCRAM-SHA1|MONGODB-CR)/} + + + describe "MongoDB Server should be configured with a non-default authentication Mechanism" do + subject { processes('mongod') } + its('commands.join') { should match /authenticationMechanisms/} + end + + describe "MongoDB Server authentication Mechanism" do + subject { processes('mongod').commands.join } + it { should_not match /SCRAM-SHA1|MONGODB-CR|PLAIN/} end end diff --git a/controls/V-81877.rb b/controls/V-81877.rb index 6052136..9b48f31 100644 --- a/controls/V-81877.rb +++ b/controls/V-81877.rb @@ -71,7 +71,7 @@ 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 tag "severity": "medium" tag "gtitle": "SRG-APP-000180-DB-000115" @@ -86,7 +86,25 @@ tag "documentable": false tag "severity_override_guidance": false - describe 'A manual review is required to determine if a user has a role with innapropriate privileges as well as if those roles have the proper privileges & inherited privileges' do - skip 'A manual review is required to determine if a user has a role with innapropriate privileges as well as if those roles have the proper privileges & inherited privileges' + mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + + dbs.each do |db| + db_command = "db = db.getSiblingDB('#{db}');db.getUsers()" + results = mongo_session.query(db_command) + + results.each do |entry| + describe "Manually verify roles for User: `#{entry['user']}` within Database: `#{entry['db']}` + Roles: #{entry['roles']}" do + skip + end + end + end + + if dbs.empty? + describe "No databases found on the target" do + skip + end end end diff --git a/controls/V-81909.rb b/controls/V-81909.rb index 3ff250f..4a71c7d 100644 --- a/controls/V-81909.rb +++ b/controls/V-81909.rb @@ -60,7 +60,24 @@ tag "documentable": false tag "severity_override_guidance": false - describe 'A manual review is required to determine if any permissions exist that are not documented and approved' do - skip 'A manual review is required to determine if any permissions exist that are not documented and approved' + mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + + dbs.each do |db| + db_command = "db = db.getSiblingDB('#{db}');db.getRoles({rolesInfo: 1,showPrivileges:true,showBuiltinRoles: true})" + results = mongo_session.query(db_command) + + results.each do |entry| + describe "Manually verify privileges for Role: `#{entry['role']}` within Database: `#{db}` + Privileges: #{entry['privileges']}" do + skip + end + end + end + + if dbs.empty? + describe "No databases found on the target" do + skip + end end end diff --git a/controls/V-81911.rb b/controls/V-81911.rb index 22fda47..38fef53 100644 --- a/controls/V-81911.rb +++ b/controls/V-81911.rb @@ -65,86 +65,33 @@ tag "nist": ["CM-5 (1)"] tag "documentable": false tag "severity_override_guidance": false + + describe "Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file" do + skip "Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file" + end - a = [] - dbnames = [] - - if input('mongo_use_pki') == 'true' - get_databases = command("sudo mongo --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') - else - get_databases = command("mongo -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'JSON.stringify(db.adminCommand( { listDatabases: 1, nameOnly: true}))'").stdout.strip.split('"name":"') + describe "Manually verify enforces access restrictions associated with changes to the configuration of the database(s)" do + skip "Manually verify enforces access restrictions associated with changes to the configuration of the database(s)" end - if get_databases.grep(/error/).empty? == false - describe 'Verify the correct credentials or a valid client certificate is used to execute the query.' do - skip 'Verify the correct credentials or a valid client certificate is used to execute the query.' - end - else - get_databases.each do |db| - if db.include? 'databases' + mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) - a.push(db) - get_databases.delete(db) - end - end + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} - get_databases.each do |db| + dbs.each do |db| + db_command = "db = db.getSiblingDB('#{db}');db.getUsers()" + results = mongo_session.query(db_command) - loc_colon = db.index('"') - names = db[0, loc_colon] - dbnames.push(names) - end - if dbnames.empty? - describe 'There are no mongo databases, therefore for this control is NA' do - skip 'There are no mongo databases, therefore for this control is NA' + results.each do |entry| + if entry['roles'].map {|x| x['role']}.include?('userAdminAnyDatabase') + describe "Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdminAnyDatabase` role" do + skip + end end - end - - if !dbnames.empty? - - dbnames.each do |dbs| - - if input('mongo_use_pki') == 'true' - users = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - users = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\"}, {user: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - users.each do |t| - - loc_colon = t.index(':') - - user = t[loc_colon+3..-1] - - loc_quote = user.index('"') - - username = user[0, loc_quote] - - if input('mongo_use_pki') == 'true' - getdb_roles = command("sudo mongo admin --ssl --sslPEMKeyFile #{input('mongod_client_pem')} --sslCAFile #{input('mongod_cafile')} \ - --authenticationDatabase '$external' --authenticationMechanism MONGODB-X509 --host #{input('mongod_hostname')} \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - else - getdb_roles = command("mongo admin -u '#{input('user')}' -p '#{input('password')}' \ - --quiet --eval 'db.system.users.find({db: \"#{dbs}\", user: \"#{username}\"}, {roles: 1, _id: false, distinct: 1})'").stdout.strip.split("\n") - end - - getdb_roles.each do |r| - remove_role = r.index('[') - rr = r[remove_role..-1] - - allowed_role = username - describe "The database role for user: #{username}" do - subject { rr } - it { should be_in input("#{allowed_role}_allowed_role") } - end - end + if entry['roles'].map {|x| x['role']}.include?('userAdmin') + describe "Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdmin` role" do + skip end end end diff --git a/controls/V-81925.rb b/controls/V-81925.rb index b207722..6f76533 100644 --- a/controls/V-81925.rb +++ b/controls/V-81925.rb @@ -44,9 +44,29 @@ tag "documentable": false tag "severity_override_guidance": false - describe 'A manual review is required to ensure when invalid inputs are received, MongoDB behaves in a predictable - and documented manner that reflects organizational and system objectives' do - skip 'A manual review is required to ensure when invalid inputs are received, MongoDB behaves in a predictable - and documented manner that reflects organizational and system objectives' + validator_exception_dbs = ['admin','local','config'] + + mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + + dbs.each do |db| + next if validator_exception_dbs.include?(db) + + db_command = "db = db.getSiblingDB('#{db}');db.getCollectionInfos()" + results = mongo_session.query(db_command) + + results.each do |entry| + describe "Database: `#{db}`; Collection `#{entry['name']}`" do + subject { entry } + its(['options', 'validator']) { should_not be nil } + end + end + end + + if dbs.empty? + describe "No databases found on the target" do + skip + end end end \ No newline at end of file diff --git a/controls/V-81927.rb b/controls/V-81927.rb index 2386e0e..79e888b 100644 --- a/controls/V-81927.rb +++ b/controls/V-81927.rb @@ -68,11 +68,17 @@ tag "documentable": false tag "severity_override_guidance": false - describe 'A manual review is required to ensure MongoDB obscures the feedback of authentication information during the - authentication process to protect the information from possible - exploitation/use by unauthorized individuals.' do - skip 'A manual review is required to ensure MongoDB obscures the feedback of authentication information during the - authentication process to protect the information from possible - exploitation/use by unauthorized individuals.' + tools = ['mongo','mongodump','mongorestore','mongoimport','mongoexport'] + + installed_tools = [] + + tools.each do |tool| + if command(tool).exist? + installed_tools << tool + end + end + + describe "Manually review that the use presence of tools `#{installed_tools}.to_s` is authorized and the users have the required training." do + skip end end diff --git a/libraries/mongo_command.rb b/libraries/mongo_command.rb index 77451e5..138af14 100644 --- a/libraries/mongo_command.rb +++ b/libraries/mongo_command.rb @@ -11,8 +11,7 @@ class MongoCommand < Inspec.resource(1) attr_reader :command, :database, :params - def initialize(command, options = {}) - @command = command + def initialize(options = {}) @username = options[:username] @password = options[:password] @database = options.fetch(:database, 'admin') @@ -27,10 +26,20 @@ def initialize(command, options = {}) @verify_ssl = options.fetch(:verify_ssl, true) check_for_cli_command + + end + + def query(command) @inspec_command = run_mongo_command(command) @params = parse(@inspec_command.stdout) end + def to_s + str = "MongoDB Session" + end + + private + def stdout @inspec_command.stdout end @@ -39,17 +48,6 @@ def stderr @inspec_command.stderr end - def to_s - puts "hi" - str = "MongoDB Command (#{@command}" - str += ", database: #{@database}" - str += ')' - - str - end - - private - def parse(output) # return right away if stdout is nil return [] if output.nil? @@ -58,7 +56,8 @@ def parse(output) # Unfortunately, it appears the --sslAllowInvalidHostnames doesn't actually squelch # any warnings, even when using --quiet mode - output_lines = output.lines.delete_if { |line| line.match?(/ W NETWORK |UUID/)} + output_lines = output.lines.delete_if { |line| line.match?(/ W NETWORK /)} + # if, after removing any network warnings, there are no lines to process, # we received no command output. @@ -67,6 +66,9 @@ def parse(output) # put our output back together as a string output = output_lines.join + # Fix UUID field syntax to create a valid JSON + output = output.gsub(/UUID\("(.*)\"\)/,'"\1"') + # skip the whole resource if we could not run the command at all return skip_resource "User is not authorized to run command #{command}" if is_auth_error?(stdout+stderr) && !auth_errors_allowed? From ecddc81fdc75e5011e4b2dcc37c4dd0954714e67 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Wed, 23 Jun 2021 15:12:23 -0400 Subject: [PATCH 19/32] updating inputs by removing unused ones Signed-off-by: HackerShark --- inputs.yml | 37 ---------------------- inspec.yml | 91 ------------------------------------------------------ 2 files changed, 128 deletions(-) diff --git a/inputs.yml b/inputs.yml index 4519aa7..a346caa 100644 --- a/inputs.yml +++ b/inputs.yml @@ -1,14 +1,8 @@ mongod_conf: '/etc/mongod.conf' mongo_data_dir: '/var/lib/mongo' -mongod_client_pem: '/etc/ssl/client.pem' - -saslauthd: '/etc/sysconfig/saslauthd' - mongod_hostname: 'MONGODB' -is_docker: 'true' -mongo_use_pki: 'true' mongo_use_ldap: 'false' mongo_use_saslauthd: 'false' @@ -24,43 +18,12 @@ user: 'mongoadmin' password: 'mongoadmin' mongod_hostname: '127.0.0.1' ssl: false -verify_ssl: false -mongod_client_pem: nil -mongod_cafile: nil -authentication_database: nil -authentication_mechanism: nil mongodb_service_account: ["mongodb", "mongod"] mongodb_service_group: ["mongodb", "mongod"] -admin_db_users: ["mongodb_admin", "mongoadmin"] db_owners: ["mongodb", "mongod"] -config_db_users: ["config_admin"] mongodb_service_account: ['mongod', 'mongodb'] mongodb_service_group: ['mongod', 'mongodb'] -myUserAdmin_allowed_role: ['[ - { "role" : "userAdminAnyDatabase", "db" : "admin" } - ] }'] - -mongoadmin_allowed_role: ['[ { - "role" : "userAdminAnyDatabase", - "db" : "admin" - } ] }'] - -mongodb_admin_allowed_role: ['[ { - "role" : "userAdminAnyDatabase", - "db" : "admin" - } ] }'] - -appAdmin_allowed_role: ['[ - { "role" : "readWrite", "db" : "config" }, - { "role" : "clusterAdmin", "db" : "admin" } - ] }'] -accountAdmin01_allowed_role: ['[ - { "role" : "clusterAdmin", "db" : "admin" }, - { "role" : "readAnyDatabase", "db" : "admin" }, - { "role" : "readWrite", "db" : "config" } - ] } - '] is_sensitive: true diff --git a/inspec.yml b/inspec.yml index e970abf..e0046ef 100644 --- a/inspec.yml +++ b/inspec.yml @@ -21,30 +21,6 @@ inputs: value: '/var/lib/mongo' required: true - - name: mongod_client_pem - description: 'MongoDB Client PEM File' - type: string - value: '/etc/ssl/client.pem' - required: true - - - name: saslauthd - description: 'MongoDB SASLAUTHD File' - type: string - value: '/etc/sysconfig/saslauthd' - required: true - - - name: is_docker - description: 'MongoDB is Running in Docker Environment - True/False' - type: string - value: 'false' - required: true - - - name: mongo_use_pki - description: 'MongoDB is Using PKI Authentication - True/False' - type: string - value: 'true' - required: true - - name: mongo_use_ldap description: 'MongoDB is Using LDAP - True/False' type: string @@ -93,73 +69,6 @@ inputs: type: boolean value: false - - name: verify_ssl - description: verify ssl - type: boolean - value: false - - - name: mongod_client_pem - description: PEM file for mongo authentication - type: string - value: nil - - - name: mongod_cafile - description: cafile for mongo authentication - type: string - value: nil - - - name: authentication_database - description: authentication database - type: string - value: nil - - - name: authentication_mechanism - description: authentication mechanism - type: string - value: nil - - - name: admin_db_users - description: 'List of authorized users of the admn database' - type: array - value: ["mongodb_admin"] - required: true - sensitive: true - - - name: config_db_users - description: 'List of authorized users of the admn database' - type: array - value: ["config_admin"] - required: true - sensitive: true - - - name: myUserAdmin_allowed_role - description: 'List of authorized users of the admn database' - type: array - value: ['[ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] }'] - required: true - - - name: mongoadmin_allowed_role - description: 'List of authorized users of the admn database' - type: array - value: ['[ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] }'] - required: true - - - name: mongodb_admin_allowed_role - description: 'List of authorized users of the admn database' - type: array - value: ['[ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] }'] - required: true - - - name: appAdmin_allowed_role - description: 'List of authorized users of the admn database' - type: array - value: ['[ { "role" : "readWrite", "db" : "config" }, { "role" : "clusterAdmin", "db" : "admin" } ] }'] - - - name: accountAdmin01_allowed_role - description: 'List of authorized users of the admn database' - type: array - value: ['[ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "readAnyDatabase", "db" : "admin" }, { "role" : "readWrite", "db" : "config" } ] }'] - - name: mongodb_service_account description: Mongodb Service Account type: array From e629cfe8ec527bc79588fe7a901f86f2649c00d4 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Wed, 23 Jun 2021 15:22:42 -0400 Subject: [PATCH 20/32] Updated controls 81845 81857 81877 81909 81911 81925 to use inputs for the database connection, fixed input name for username in inputs file Signed-off-by: HackerShark --- controls/V-81845.rb | 2 +- controls/V-81857.rb | 2 +- controls/V-81877.rb | 2 +- controls/V-81909.rb | 2 +- controls/V-81911.rb | 2 +- controls/V-81925.rb | 2 +- inputs.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/controls/V-81845.rb b/controls/V-81845.rb index d0774db..3c89c39 100644 --- a/controls/V-81845.rb +++ b/controls/V-81845.rb @@ -39,7 +39,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} dbs.each do |db| diff --git a/controls/V-81857.rb b/controls/V-81857.rb index 16b9531..4efce9f 100644 --- a/controls/V-81857.rb +++ b/controls/V-81857.rb @@ -58,7 +58,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81877.rb b/controls/V-81877.rb index 9b48f31..6a56248 100644 --- a/controls/V-81877.rb +++ b/controls/V-81877.rb @@ -86,7 +86,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81909.rb b/controls/V-81909.rb index 4a71c7d..2e7053a 100644 --- a/controls/V-81909.rb +++ b/controls/V-81909.rb @@ -60,7 +60,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} dbs.each do |db| diff --git a/controls/V-81911.rb b/controls/V-81911.rb index 38fef53..cebe9d1 100644 --- a/controls/V-81911.rb +++ b/controls/V-81911.rb @@ -74,7 +74,7 @@ skip "Manually verify enforces access restrictions associated with changes to the configuration of the database(s)" end - mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81925.rb b/controls/V-81925.rb index 6f76533..aed1edb 100644 --- a/controls/V-81925.rb +++ b/controls/V-81925.rb @@ -46,7 +46,7 @@ validator_exception_dbs = ['admin','local','config'] - mongo_session = mongo_command(username: 'mongoadmin', password: 'mongoadmin', ssl: false) + mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/inputs.yml b/inputs.yml index a346caa..c7e32fe 100644 --- a/inputs.yml +++ b/inputs.yml @@ -14,7 +14,7 @@ approved_mongo_packages: [ 'mongodb-enterprise-tools' ] -user: 'mongoadmin' +username: 'mongoadmin' password: 'mongoadmin' mongod_hostname: '127.0.0.1' ssl: false From e5279ea6e38fd0ce1018b270e0f4bc903e7c19b0 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Wed, 23 Jun 2021 15:36:54 -0400 Subject: [PATCH 21/32] Updated controls 81845 81857 81877 81909 81911 81925 to use hostname input for the database connection Signed-off-by: HackerShark --- controls/V-81845.rb | 2 +- controls/V-81857.rb | 2 +- controls/V-81877.rb | 2 +- controls/V-81909.rb | 2 +- controls/V-81911.rb | 2 +- controls/V-81925.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controls/V-81845.rb b/controls/V-81845.rb index 3c89c39..ae7e7e8 100644 --- a/controls/V-81845.rb +++ b/controls/V-81845.rb @@ -39,7 +39,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} dbs.each do |db| diff --git a/controls/V-81857.rb b/controls/V-81857.rb index 4efce9f..9eeae15 100644 --- a/controls/V-81857.rb +++ b/controls/V-81857.rb @@ -58,7 +58,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81877.rb b/controls/V-81877.rb index 6a56248..a21f553 100644 --- a/controls/V-81877.rb +++ b/controls/V-81877.rb @@ -86,7 +86,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81909.rb b/controls/V-81909.rb index 2e7053a..461f7ef 100644 --- a/controls/V-81909.rb +++ b/controls/V-81909.rb @@ -60,7 +60,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} dbs.each do |db| diff --git a/controls/V-81911.rb b/controls/V-81911.rb index cebe9d1..63a66c8 100644 --- a/controls/V-81911.rb +++ b/controls/V-81911.rb @@ -74,7 +74,7 @@ skip "Manually verify enforces access restrictions associated with changes to the configuration of the database(s)" end - mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81925.rb b/controls/V-81925.rb index aed1edb..26a1f31 100644 --- a/controls/V-81925.rb +++ b/controls/V-81925.rb @@ -46,7 +46,7 @@ validator_exception_dbs = ['admin','local','config'] - mongo_session = mongo_command(username: input('username'), password: input('password'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} From 9bdca6da2a7ee273c4077c589b82316443b55b9f Mon Sep 17 00:00:00 2001 From: HackerShark Date: Fri, 25 Jun 2021 00:54:36 -0400 Subject: [PATCH 22/32] Updated controls 81845 81857 81877 81909 81911 81925 to use additional inputs for the database connection, updated inputs.yml and inspec.yml to accomadate new inputs Signed-off-by: HackerShark --- controls/V-81845.rb | 2 +- controls/V-81857.rb | 2 +- controls/V-81877.rb | 2 +- controls/V-81909.rb | 2 +- controls/V-81911.rb | 2 +- controls/V-81925.rb | 2 +- inputs.yml | 6 ++++++ inspec.yml | 32 +++++++++++++++++++++++++++++++- 8 files changed, 43 insertions(+), 7 deletions(-) diff --git a/controls/V-81845.rb b/controls/V-81845.rb index ae7e7e8..a15351a 100644 --- a/controls/V-81845.rb +++ b/controls/V-81845.rb @@ -39,7 +39,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} dbs.each do |db| diff --git a/controls/V-81857.rb b/controls/V-81857.rb index 9eeae15..053ac63 100644 --- a/controls/V-81857.rb +++ b/controls/V-81857.rb @@ -58,7 +58,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81877.rb b/controls/V-81877.rb index a21f553..b772c95 100644 --- a/controls/V-81877.rb +++ b/controls/V-81877.rb @@ -86,7 +86,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81909.rb b/controls/V-81909.rb index 461f7ef..9f97896 100644 --- a/controls/V-81909.rb +++ b/controls/V-81909.rb @@ -60,7 +60,7 @@ tag "documentable": false tag "severity_override_guidance": false - mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} dbs.each do |db| diff --git a/controls/V-81911.rb b/controls/V-81911.rb index 63a66c8..1e1a02b 100644 --- a/controls/V-81911.rb +++ b/controls/V-81911.rb @@ -74,7 +74,7 @@ skip "Manually verify enforces access restrictions associated with changes to the configuration of the database(s)" end - mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/controls/V-81925.rb b/controls/V-81925.rb index 26a1f31..54d6771 100644 --- a/controls/V-81925.rb +++ b/controls/V-81925.rb @@ -46,7 +46,7 @@ validator_exception_dbs = ['admin','local','config'] - mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), ssl: input('ssl')) + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} diff --git a/inputs.yml b/inputs.yml index c7e32fe..32c1d98 100644 --- a/inputs.yml +++ b/inputs.yml @@ -17,7 +17,13 @@ approved_mongo_packages: [ username: 'mongoadmin' password: 'mongoadmin' mongod_hostname: '127.0.0.1' +mongod_port: '27017' ssl: false +verify_ssl: false +mongod_client_pem: nil +mongod_cafile: nil +authentication_database: nil +authentication_mechanism: nil mongodb_service_account: ["mongodb", "mongod"] mongodb_service_group: ["mongodb", "mongod"] diff --git a/inspec.yml b/inspec.yml index e0046ef..fbd055f 100644 --- a/inspec.yml +++ b/inspec.yml @@ -64,11 +64,41 @@ inputs: type: string value: '127.0.0.1' + - name: mongod_port + description: Mongo Port + type: string + value: '27017' + - name: ssl description: ssl enabled or not type: boolean value: false + - name: verify_ssl + description: Verify SSL + type: boolean + value: false + + - name: mongod_client_pem + description: pem file location + type: string + value: nil + + - name: mongod_cafile + description: cafile location + type: string + value: nil + + - name: authentication_database + description: authentication database + type: string + value: nil + + - name: authentication_mechanism + description: authentication mechanism + type: string + value: nil + - name: mongodb_service_account description: Mongodb Service Account type: array @@ -87,4 +117,4 @@ inputs: - name: x509_cert_file description: x509 cert file location type: string - value: "/etc/ssl/mongodb.pem" + value: "/etc/ssl/mongodb.pem" \ No newline at end of file From bab8d0f6d94ecb0c65e7205f8291800e87d2fe15 Mon Sep 17 00:00:00 2001 From: HackerShark Date: Fri, 25 Jun 2021 10:17:37 -0400 Subject: [PATCH 23/32] Ran cookstyle autocorrect to fix chef linting issues Signed-off-by: HackerShark --- controls/V-81843.rb | 27 +++++++-------- controls/V-81845.rb | 32 ++++++++--------- controls/V-81847.rb | 84 ++++++++++++++++++++++----------------------- controls/V-81849.rb | 31 ++++++++--------- controls/V-81851.rb | 32 ++++++++--------- controls/V-81853.rb | 24 ++++++------- controls/V-81855.rb | 36 +++++++++---------- controls/V-81857.rb | 32 ++++++++--------- controls/V-81859.rb | 27 +++++++-------- controls/V-81861.rb | 38 ++++++++++---------- controls/V-81863.rb | 25 +++++++------- controls/V-81865.rb | 35 +++++++++---------- controls/V-81867.rb | 32 ++++++++--------- controls/V-81869.rb | 36 +++++++++---------- controls/V-81871.rb | 33 +++++++++--------- controls/V-81873.rb | 24 ++++++------- controls/V-81875.rb | 34 +++++++++--------- controls/V-81877.rb | 38 ++++++++++---------- controls/V-81879.rb | 28 +++++++-------- controls/V-81881.rb | 29 ++++++++-------- controls/V-81883.rb | 31 ++++++++--------- controls/V-81885.rb | 26 +++++++------- controls/V-81887.rb | 36 +++++++++---------- controls/V-81889.rb | 26 +++++++------- controls/V-81891.rb | 30 ++++++++-------- controls/V-81893.rb | 28 +++++++-------- controls/V-81895.rb | 28 +++++++-------- controls/V-81897.rb | 30 ++++++++-------- controls/V-81899.rb | 28 +++++++-------- controls/V-81901.rb | 24 ++++++------- controls/V-81903.rb | 30 ++++++++-------- controls/V-81905.rb | 28 +++++++-------- controls/V-81907.rb | 30 ++++++++-------- controls/V-81909.rb | 30 ++++++++-------- controls/V-81911.rb | 48 +++++++++++++------------- controls/V-81913.rb | 26 +++++++------- controls/V-81915.rb | 30 ++++++++-------- controls/V-81917.rb | 27 +++++++-------- controls/V-81919.rb | 37 ++++++++++---------- controls/V-81921.rb | 28 +++++++-------- controls/V-81923.rb | 28 +++++++-------- controls/V-81925.rb | 36 +++++++++---------- controls/V-81927.rb | 26 +++++++------- controls/V-81929.rb | 24 ++++++------- 44 files changed, 690 insertions(+), 702 deletions(-) diff --git a/controls/V-81843.rb b/controls/V-81843.rb index a66a4d1..498bf80 100644 --- a/controls/V-81843.rb +++ b/controls/V-81843.rb @@ -1,19 +1,19 @@ - control "V-81843" do +control 'V-81843' 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: + + 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." - desc "fix", "Edit the MongoDB configuration file (default location: + desc 'fix', "Edit the MongoDB configuration file (default location: /etc/mongod.conf) to include the following: security: @@ -35,19 +35,18 @@ 6. Create additional users as needed for your deployment." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000023-DB-000001" - tag "gid": "V-81843" - tag "rid": "SV-96557r1_rule" - tag "stig_id": "MD3X-00-000010" - tag "fix_id": "F-88693r1_fix" - tag "cci": ["CCI-000015"] - tag "nist": ["AC-2 (1)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000023-DB-000001' + tag "gid": 'V-81843' + tag "rid": 'SV-96557r1_rule' + tag "stig_id": 'MD3X-00-000010' + tag "fix_id": 'F-88693r1_fix' + tag "cci": ['CCI-000015'] + tag "nist": ['AC-2 (1)'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{security authorization}) { should cmp 'enabled' } + its(%w(security authorization)) { should cmp 'enabled' } end - end diff --git a/controls/V-81845.rb b/controls/V-81845.rb index a15351a..3edff65 100644 --- a/controls/V-81845.rb +++ b/controls/V-81845.rb @@ -1,12 +1,12 @@ - control "V-81845" do +control 'V-81845' 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", "Review the system documentation to determine the required + + desc 'check', "Review the system documentation to determine the required levels of protection for DBMS 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. @@ -20,7 +20,7 @@ showBuiltinRoles: true } )" - desc "fix", "Use createRole(), updateRole(), dropRole(), grantRole() + desc 'fix', "Use createRole(), updateRole(), dropRole(), grantRole() statements to add and remove permissions on server-level securables, bringing them into line with the documented requirements. @@ -28,19 +28,19 @@ https://docs.mongodb.com/v3.4/reference/method/js-role-management/" impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000033-DB-000084" - tag "gid": "V-81845" - tag "rid": "SV-96559r1_rule" - tag "stig_id": "MD3X-00-000020" - tag "fix_id": "F-88695r2_fix" - tag "cci": ["CCI-000213"] - tag "nist": ["AC-3"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000033-DB-000084' + tag "gid": 'V-81845' + tag "rid": 'SV-96559r1_rule' + tag "stig_id": 'MD3X-00-000020' + tag "fix_id": 'F-88695r2_fix' + tag "cci": ['CCI-000213'] + tag "nist": ['AC-3'] tag "documentable": false tag "severity_override_guidance": false - + mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) - dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map { |x| x['name'] } dbs.each do |db| db_command = "db = db.getSiblingDB('#{db}');db.getRoles({rolesInfo: 1,showPrivileges:true,showBuiltinRoles: true})" @@ -48,14 +48,14 @@ results.each do |entry| describe "Manually verify privileges for Role: `#{entry['role']}` within Database: `#{db}` - Privileges: #{entry['privileges']}" do + Privileges: #{entry['privileges']}" do skip end end end if dbs.empty? - describe "No databases found on the target" do + describe 'No databases found on the target' do skip end end diff --git a/controls/V-81847.rb b/controls/V-81847.rb index 192c37e..03ca75b 100644 --- a/controls/V-81847.rb +++ b/controls/V-81847.rb @@ -1,10 +1,10 @@ - control "V-81847" do +control 'V-81847' 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", "Check the MongoDB configuration file (default location: + desc 'check', "Check the MongoDB configuration file (default location: '/etc/mongod.conf)' for a key named 'auditLog:'. Example shown below: @@ -27,7 +27,7 @@ auditLog: destination: syslog filter: '{ atype: { $in: [ \"createCollection\", \"dropCollection\" ] } }'" - desc "fix", "If the \"auditLog\" setting was not present in the MongoDB + 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: @@ -40,51 +40,51 @@ 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." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000089-DB-000064" - 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-000093-DB-000052", "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 "gid": "V-81847" - tag "rid": "SV-96561r1_rule" - tag "stig_id": "MD3X-00-000040" - tag "fix_id": "F-88697r1_fix" - tag "cci": ["CCI-000130", "CCI-000131", "CCI-000132", "CCI-000133", - "CCI-000134", "CCI-000135", "CCI-000140", "CCI-000166", "CCI-000171", - "CCI-000172", "CCI-001462", "CCI-001464", "CCI-001487", "CCI-001814", - "CCI-001844", "CCI-001851", "CCI-001858"] - tag "nist": ["AU-3", "AU-3", "AU-3", "AU-3", "AU-3", "AU-3 (1)", "AU-5 b", - "AU-10", "AU-12 b", "AU-12 c", "AU-14 (2)", "AU-14 (1)", "AU-3", "CM-5 (1)", - "AU-3 (2)", "AU-4 (1)", "AU-5 (2)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000089-DB-000064' + tag "satisfies": %w(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-000093-DB-000052 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 "gid": 'V-81847' + tag "rid": 'SV-96561r1_rule' + tag "stig_id": 'MD3X-00-000040' + tag "fix_id": 'F-88697r1_fix' + tag "cci": %w(CCI-000130 CCI-000131 CCI-000132 CCI-000133 + CCI-000134 CCI-000135 CCI-000140 CCI-000166 CCI-000171 + CCI-000172 CCI-001462 CCI-001464 CCI-001487 CCI-001814 + CCI-001844 CCI-001851 CCI-001858) + tag "nist": ['AU-3', 'AU-3', 'AU-3', 'AU-3', 'AU-3', 'AU-3 (1)', 'AU-5 b', + 'AU-10', 'AU-12 b', 'AU-12 c', 'AU-14 (2)', 'AU-14 (1)', 'AU-3', 'CM-5 (1)', + 'AU-3 (2)', 'AU-4 (1)', 'AU-5 (2)'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{auditLog destination}) { should cmp 'syslog' } + its(%w(auditLog destination)) { should cmp 'syslog' } end describe yaml(input('mongod_conf')) do - its(%w{auditLog filter}) { should be_nil } + its(%w(auditLog filter)) { should be_nil } end end diff --git a/controls/V-81849.rb b/controls/V-81849.rb index 52f6a78..4cc4612 100644 --- a/controls/V-81849.rb +++ b/controls/V-81849.rb @@ -1,4 +1,4 @@ - control "V-81849" do +control 'V-81849' do title "The audit information produced by MongoDB must be protected from unauthorized read access." desc "If audit data were to become compromised, then competent forensic @@ -27,7 +27,7 @@ activity. " - desc "check", "Verify User ownership, Group ownership, and permissions on the + desc 'check', "Verify User ownership, Group ownership, and permissions on the \"\": > ls –ald @@ -59,7 +59,7 @@ the output will be the \"\" /var/lib/mongo" - desc "fix", "Run these commands: + desc 'fix', "Run these commands: \"chown mongod \" \"chgrp mongod \" @@ -88,16 +88,16 @@ /var/lib/mongo" impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000118-DB-000059" - tag "satisfies": ["SRG-APP-000118-DB-000059", "SRG-APP-000119-DB-000060", - "SRG-APP-000120-DB-000061"] - tag "gid": "V-81849" - tag "rid": "SV-96563r1_rule" - tag "stig_id": "MD3X-00-000190" - tag "fix_id": "F-88699r1_fix" - tag "cci": ["CCI-000162", "CCI-000163", "CCI-000164"] - tag "nist": ["AU-9"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000118-DB-000059' + tag "satisfies": %w(SRG-APP-000118-DB-000059 SRG-APP-000119-DB-000060 + SRG-APP-000120-DB-000061) + tag "gid": 'V-81849' + tag "rid": 'SV-96563r1_rule' + tag "stig_id": 'MD3X-00-000190' + tag "fix_id": 'F-88699r1_fix' + tag "cci": %w(CCI-000162 CCI-000163 CCI-000164) + tag "nist": ['AU-9'] tag "documentable": false tag "severity_override_guidance": false @@ -110,13 +110,12 @@ end describe file(mongodb_auditlog_dir) do - it { should_not be_more_permissive_than('0700') } + it { should_not be_more_permissive_than('0700') } its('owner') { should be_in mongodb_service_account } its('group') { should be_in mongodb_service_group } end describe command("dirname #{mongodb_auditlog_dir}") do - it { should cmp '/var/lib/mongo'} + it { should cmp '/var/lib/mongo' } end - end diff --git a/controls/V-81851.rb b/controls/V-81851.rb index abe9e21..9be1b6c 100644 --- a/controls/V-81851.rb +++ b/controls/V-81851.rb @@ -1,6 +1,6 @@ - control "V-81851" do +control 'V-81851' do title 'MongoDB must protect its audit features from unauthorized access.' - desc "Protecting audit data also includes identifying and protecting the + 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 @@ -22,7 +22,7 @@ could also manipulate logs to hide evidence of malicious activity. " - desc "check", "Verify User ownership, Group ownership, and permissions on the + desc 'check', "Verify User ownership, Group ownership, and permissions on the “\": (default name and location is '/etc/mongod.conf') @@ -39,7 +39,7 @@ If the Group owner is not \"mongod\", this is a finding. If the filename is more permissive than \"700\", this is a finding." - desc "fix", "Run these commands: + desc 'fix', "Run these commands: \"chown mongod \" \"chgrp mongod \" @@ -55,24 +55,24 @@ > chmod 700 /etc/mongod.conf" impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000121-DB-000202" - tag "satisfies": ["SRG-APP-000121-DB-000202", "SRG-APP-000122-DB-000203", - "SRG-APP-000122-DB-000204"] - tag "gid": "V-81851" - tag "rid": "SV-96565r1_rule" - tag "stig_id": "MD3X-00-000220" - tag "fix_id": "F-88701r1_fix" - tag "cci": ["CCI-001493", "CCI-001494", "CCI-001495"] - tag "nist": ["AU-9"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000121-DB-000202' + tag "satisfies": %w(SRG-APP-000121-DB-000202 SRG-APP-000122-DB-000203 + SRG-APP-000122-DB-000204) + tag "gid": 'V-81851' + tag "rid": 'SV-96565r1_rule' + tag "stig_id": 'MD3X-00-000220' + tag "fix_id": 'F-88701r1_fix' + tag "cci": %w(CCI-001493 CCI-001494 CCI-001495) + tag "nist": ['AU-9'] tag "documentable": false tag "severity_override_guidance": false mongodb_service_account = input('mongodb_service_account') mongodb_service_group = input('mongodb_service_group') - + describe file(input('mongod_conf')) do - it { should_not be_more_permissive_than('0700') } + it { should_not be_more_permissive_than('0700') } its('owner') { should be_in mongodb_service_account } its('group') { should be_in mongodb_service_group } end diff --git a/controls/V-81853.rb b/controls/V-81853.rb index fee2028..df9f70f 100644 --- a/controls/V-81853.rb +++ b/controls/V-81853.rb @@ -1,4 +1,4 @@ -control "V-81853" do +control 'V-81853' do title "MongoDB software installation account must be restricted to authorized users." desc "When dealing with change control issues, it should be noted any @@ -20,7 +20,7 @@ to only those persons who are qualified and authorized to use them. " - desc "check", "Review procedures for controlling, granting access to, and + 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 @@ -28,18 +28,18 @@ this is a finding." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000133-DB-000198" - tag "gid": "V-81853" - tag "rid": "SV-96567r1_rule" - tag "stig_id": "MD3X-00-000250" - tag "fix_id": "F-88703r1_fix" - tag "cci": ["CCI-001499"] - tag "nist": ["CM-5 (6)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000133-DB-000198' + tag "gid": 'V-81853' + tag "rid": 'SV-96567r1_rule' + tag "stig_id": 'MD3X-00-000250' + tag "fix_id": 'F-88703r1_fix' + tag "cci": ['CCI-001499'] + tag "nist": ['CM-5 (6)'] tag "documentable": false tag "severity_override_guidance": false - - desc "fix", "Develop, document, and implement procedures to restrict and track + + desc 'fix', "Develop, document, and implement procedures to restrict and track use of the DBMS software installation account." describe 'A manual review is required to ensure there are procedures in place to restrict and track the use of the DBMS software installation account' do skip 'A manual review is required to ensure there are procedures in place to restrict and track the use of the DBMS software installation account' diff --git a/controls/V-81855.rb b/controls/V-81855.rb index e49eb52..396bda9 100644 --- a/controls/V-81855.rb +++ b/controls/V-81855.rb @@ -1,4 +1,4 @@ -control "V-81855" do +control 'V-81855' 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." @@ -19,7 +19,7 @@ protection between applications. " - desc "check", "Review the MongoDB software library directory and note other + desc 'check', "Review the MongoDB software library directory and note other root directories located on the same disk directory or any subdirectories. If any non-MongoDB software directories exist on the disk directory, examine or investigate their use. If any of the directories are used by other @@ -30,33 +30,33 @@ software libraries. If other applications are located in the same directory as the MongoDB database this is a finding." - desc "fix", "Install all applications on directories separate from the MongoDB + desc 'fix', "Install all applications on directories separate from the MongoDB software library directory. Relocate any directories or reinstall other application software that currently shares the MongoDB software library directory." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000133-DB-000199" - tag "gid": "V-81855" - tag "rid": "SV-96569r1_rule" - tag "stig_id": "MD3X-00-000260" - tag "fix_id": "F-88705r1_fix" - tag "cci": ["CCI-001499"] - tag "nist": ["CM-5 (6)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000133-DB-000199' + tag "gid": 'V-81855' + tag "rid": 'SV-96569r1_rule' + tag "stig_id": 'MD3X-00-000260' + tag "fix_id": 'F-88705r1_fix' + tag "cci": ['CCI-001499'] + tag "nist": ['CM-5 (6)'] tag "documentable": false tag "severity_override_guidance": false - + if virtualization.system.eql?('docker') impact 0.0 desc 'caveat', 'This is Not Applicable since the MongoDB is installed within a Docker container so it is separate from the host OS' else - describe "This test requires a Manual Review: Ensure all database software, - including DBMS configuration files, is stored in dedicated directories, or + describe "This test requires a Manual Review: Ensure all database software, + including DBMS configuration files, is stored in dedicated directories, or DASD pools, separate from the host OS and other applications." do - skip "This test requires a Manual Review: Ensure all database software, - including DBMS configuration files, is stored in dedicated directories, or + skip "This test requires a Manual Review: Ensure all database software, + including DBMS configuration files, is stored in dedicated directories, or DASD pools, separate from the host OS and other applications." end - end -end \ No newline at end of file + end +end diff --git a/controls/V-81857.rb b/controls/V-81857.rb index 053ac63..1e55726 100644 --- a/controls/V-81857.rb +++ b/controls/V-81857.rb @@ -1,9 +1,9 @@ - control "V-81857" do +control 'V-81857' 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 + 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. @@ -15,8 +15,8 @@ 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 + + desc 'check', "Run the following command to get the roles from a MongoDB database. For each database in MongoDB: @@ -37,7 +37,7 @@ Analyze the output and if any roles or users have unauthorized access, this is a finding." - desc "fix", "Use the following commands to remove unauthorized access to a + desc 'fix', "Use the following commands to remove unauthorized access to a MongoDB database. db.revokePrivilegesFromRole() @@ -47,20 +47,20 @@ https://docs.mongodb.com/v3.4/reference/method/js-role-management/" impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000133-DB-000362" - tag "gid": "V-81857" - tag "rid": "SV-96571r1_rule" - tag "stig_id": "MD3X-00-000270" - tag "fix_id": "F-88707r1_fix" - tag "cci": ["CCI-001499"] - tag "nist": ["CM-5 (6)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000133-DB-000362' + tag "gid": 'V-81857' + tag "rid": 'SV-96571r1_rule' + tag "stig_id": 'MD3X-00-000270' + tag "fix_id": 'F-88707r1_fix' + tag "cci": ['CCI-001499'] + tag "nist": ['CM-5 (6)'] tag "documentable": false tag "severity_override_guidance": false mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) - dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map { |x| x['name'] } dbs.each do |db| db_command = "db = db.getSiblingDB('#{db}');db.getUsers()" @@ -68,14 +68,14 @@ results.each do |entry| describe "Manually verify roles for User: `#{entry['user']}` within Database: `#{entry['db']}` - Roles: #{entry['roles']}" do + Roles: #{entry['roles']}" do skip end end end if dbs.empty? - describe "No databases found on the target" do + describe 'No databases found on the target' do skip end end diff --git a/controls/V-81859.rb b/controls/V-81859.rb index 50084dc..e3247d2 100644 --- a/controls/V-81859.rb +++ b/controls/V-81859.rb @@ -1,4 +1,4 @@ - control "V-81859" do +control 'V-81859' do title "Unused database components, DBMS software, and database objects must be removed." desc "Information systems are capable of providing a wide variety of @@ -12,8 +12,8 @@ DBMSs must adhere to the principles of least functionality by providing only essential capabilities. " - - desc "check", "Review the list of components and features installed with the + + desc 'check', "Review the list of components and features installed with the MongoDB database. If unused components are installed and are not documented and authorized, this @@ -27,7 +27,7 @@ If any packages displayed by this command are not being used, this is a finding." - desc "fix", "On data-bearing nodes and arbiter nodes, the + desc 'fix', "On data-bearing nodes and arbiter nodes, the mongodb-enterprise-tools, mongodb-enterprise-shell and mongodb-enterprise-mongos can be removed (or not installed). @@ -36,18 +36,17 @@ package." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000141-DB-000091" - tag "gid": "V-81859" - tag "rid": "SV-96573r1_rule" - tag "stig_id": "MD3X-00-000280" - tag "fix_id": "F-88709r1_fix" - tag "cci": ["CCI-000381"] - tag "nist": ["CM-7 a"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000141-DB-000091' + tag "gid": 'V-81859' + tag "rid": 'SV-96573r1_rule' + tag "stig_id": 'MD3X-00-000280' + tag "fix_id": 'F-88709r1_fix' + tag "cci": ['CCI-000381'] + tag "nist": ['CM-7 a'] tag "documentable": false tag "severity_override_guidance": false - approved_mongo_packages = input('approved_mongo_packages') dpkg_packages = packages(/mongodb/).names @@ -63,4 +62,4 @@ end end end -end \ No newline at end of file +end diff --git a/controls/V-81861.rb b/controls/V-81861.rb index 059f24b..5ddb657 100644 --- a/controls/V-81861.rb +++ b/controls/V-81861.rb @@ -1,4 +1,4 @@ - control "V-81861" do +control 'V-81861' 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 @@ -21,8 +21,8 @@ configuration settings, OS service settings, OS file access security, and DBMS user/role permissions. " - - desc "check", "In the MongoDB database configuration file (default location: + + desc 'check', "In the MongoDB database configuration file (default location: /etc/mongod.conf), review the following parameters: net: @@ -32,7 +32,7 @@ RESTInterfaceEnabled: true If any of the are \"True\" or \"Enabled\", this is a finding." - desc "fix", "In the MongoDB database configuration file (default location: + desc 'fix', "In the MongoDB database configuration file (default location: /etc/mongod.conf), ensure the following parameters either: Does not exist in the file @@ -45,43 +45,43 @@ RESTInterfaceEnabled: false" impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000141-DB-000092" - tag "satisfies": ["SRG-APP-000141-DB-000092", "SRG-APP-000142-DB-000094"] - tag "gid": "V-81861" - tag "rid": "SV-96575r1_rule" - tag "stig_id": "MD3X-00-000290" - tag "fix_id": "F-88711r1_fix" - tag "cci": ["CCI-000381", "CCI-000382"] - tag "nist": ["CM-7 a", "CM-7 b"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000141-DB-000092' + tag "satisfies": %w(SRG-APP-000141-DB-000092 SRG-APP-000142-DB-000094) + tag "gid": 'V-81861' + tag "rid": 'SV-96575r1_rule' + tag "stig_id": 'MD3X-00-000290' + tag "fix_id": 'F-88711r1_fix' + tag "cci": %w(CCI-000381 CCI-000382) + tag "nist": ['CM-7 a', 'CM-7 b'] tag "documentable": false tag "severity_override_guidance": false mongo_conf_file = input('mongod_conf').to_s describe.one do describe yaml(mongo_conf_file) do - its(%w{net http enabled}) { should cmp 'false' } + its(%w(net http enabled)) { should cmp 'false' } end describe yaml(mongo_conf_file) do - its(%w{net http enabled}) { should be_nil } + its(%w(net http enabled)) { should be_nil } end end describe.one do describe yaml(mongo_conf_file) do - its(%w{net http JSONPEnabled}) { should cmp 'false' } + its(%w(net http JSONPEnabled)) { should cmp 'false' } end describe yaml(mongo_conf_file) do - its(%w{net http JSONPEnabled}) { should be_nil } + its(%w(net http JSONPEnabled)) { should be_nil } end end describe.one do describe yaml(mongo_conf_file) do - its(%w{net http RESTInterfaceEnabled}) { should cmp 'false' } + its(%w(net http RESTInterfaceEnabled)) { should cmp 'false' } end describe yaml(mongo_conf_file) do - its(%w{net http RESTInterfaceEnabled}) { should be_nil } + its(%w(net http RESTInterfaceEnabled)) { should be_nil } end end end diff --git a/controls/V-81863.rb b/controls/V-81863.rb index ba006f0..74496a1 100644 --- a/controls/V-81863.rb +++ b/controls/V-81863.rb @@ -1,4 +1,4 @@ - control "V-81863" do +control 'V-81863' 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, @@ -19,7 +19,7 @@ accountability of individual activity. " - desc "check", "To view another user’s information, you must have the + desc 'check', "To view another user’s information, you must have the \"viewUser\" action on the other user’s database. For each database in the system, run the following command: @@ -39,7 +39,7 @@ authorization: \"enabled\" If this parameter is not present, this is a finding." - desc "fix", "Prereq: To drop a user from a database, must have the + desc 'fix', "Prereq: To drop a user from a database, must have the \"dropUser\" action on the database. For any user not a member of an appropriate organization and has access to a @@ -58,14 +58,14 @@ any mongod or mongos process using this MongoDB configuration file." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000148-DB-000103" - tag "gid": "V-81863" - tag "rid": "SV-96577r1_rule" - tag "stig_id": "MD3X-00-000310" - tag "fix_id": "F-88713r1_fix" - tag "cci": ["CCI-000764"] - tag "nist": ["IA-2"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000148-DB-000103' + tag "gid": 'V-81863' + tag "rid": 'SV-96577r1_rule' + tag "stig_id": 'MD3X-00-000310' + tag "fix_id": 'F-88713r1_fix' + tag "cci": ['CCI-000764'] + tag "nist": ['IA-2'] tag "documentable": false tag "severity_override_guidance": false @@ -74,7 +74,6 @@ end describe yaml(input('mongod_conf')) do - its(%w{security authorization}) { should cmp 'enabled' } + its(%w(security authorization)) { should cmp 'enabled' } end - end diff --git a/controls/V-81865.rb b/controls/V-81865.rb index 4066d18..a6896d6 100644 --- a/controls/V-81865.rb +++ b/controls/V-81865.rb @@ -1,4 +1,4 @@ -control "V-81865" do +control 'V-81865' do title "If DBMS authentication, using passwords, is employed, MongoDB must enforce the DoD standards for password complexity and lifetime." desc "OS/enterprise authentication and identification must be used @@ -15,8 +15,8 @@ must be configured to do so. For other DBMSs, the rules must be enforced using available configuration parameters or custom code. " - - desc "check", "If MongoDB is using Native LDAP authentication where the LDAP + + 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. @@ -27,32 +27,31 @@ this is a finding. See: https://docs.mongodb.com/v3.4/core/authentication/#authentication-methods" - desc "fix", "Either configure MongoDB for Native LDAP authentication where + desc 'fix', "Either configure MongoDB for Native LDAP authentication where LDAP is configured to enforce password complexity and lifetime. OR Configure MongoDB Kerberos authentication where Kerberos is configured to enforce password complexity and lifetime." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000164-DB-000401" - tag "gid": "V-81865" - tag "rid": "SV-96579r1_rule" - tag "stig_id": "MD3X-00-000320" - tag "fix_id": "F-88715r1_fix" - tag "cci": ["CCI-000192"] - tag "nist": ["IA-5 (1) (a)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000164-DB-000401' + tag "gid": 'V-81865' + tag "rid": 'SV-96579r1_rule' + tag "stig_id": 'MD3X-00-000320' + tag "fix_id": 'F-88715r1_fix' + tag "cci": ['CCI-000192'] + tag "nist": ['IA-5 (1) (a)'] tag "documentable": false tag "severity_override_guidance": false - - describe "MongoDB Server should be configured with a non-default authentication Mechanism" do - subject { processes('mongod') } - its('commands.join') { should match /authenticationMechanisms/} + describe 'MongoDB Server should be configured with a non-default authentication Mechanism' do + subject { processes('mongod') } + its('commands.join') { should match /authenticationMechanisms/ } end - describe "MongoDB Server authentication Mechanism" do + describe 'MongoDB Server authentication Mechanism' do subject { processes('mongod').commands.join } - it { should_not match /SCRAM-SHA1|MONGODB-CR|PLAIN/} + it { should_not match /SCRAM-SHA1|MONGODB-CR|PLAIN/ } end end diff --git a/controls/V-81867.rb b/controls/V-81867.rb index 9d92f6e..6cb92cf 100644 --- a/controls/V-81867.rb +++ b/controls/V-81867.rb @@ -1,4 +1,4 @@ -control "V-81867" do +control 'V-81867' 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. @@ -9,8 +9,8 @@ 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 x.509 certificate authentication for use with + + desc 'check', "MongoDB supports x.509 certificate authentication for use with a secure TLS/SSL connection. The x.509 client authentication allows clients to authenticate to servers with @@ -31,7 +31,7 @@ client certificate for the user field. If the mechanism field is not set to \"MONGODB-X509\", this is a finding." - desc "fix", "Do the following: + desc 'fix', "Do the following: - Create local CA and signing keys. - Generate and sign server certificates for member authentication. - Generate and sign client certificates for client authentication. @@ -44,23 +44,23 @@ Additionally, SSL/TLS must be on as documented here: https://docs.mongodb.com/v3.4/tutorial/configure-ssl/" - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000171-DB-000074" - tag "gid": "V-81867" - tag "rid": "SV-96581r1_rule" - tag "stig_id": "MD3X-00-000330" - tag "fix_id": "F-88717r1_fix" - tag "cci": ["CCI-000196"] - tag "nist": ["IA-5 (1) (c)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000171-DB-000074' + tag "gid": 'V-81867' + tag "rid": 'SV-96581r1_rule' + tag "stig_id": 'MD3X-00-000330' + tag "fix_id": 'F-88717r1_fix' + tag "cci": ['CCI-000196'] + tag "nist": ['IA-5 (1) (c)'] tag "documentable": false - tag "severity_override_guidance": false + tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{security authorization}) { should cmp 'enabled' } + its(%w(security authorization)) { should cmp 'enabled' } end describe yaml(input('mongod_conf')) do - its(%w{security clusterAuthMode}) { should cmp 'x509' } + its(%w(security clusterAuthMode)) { should cmp 'x509' } end end diff --git a/controls/V-81869.rb b/controls/V-81869.rb index 4ac9d92..f00985c 100644 --- a/controls/V-81869.rb +++ b/controls/V-81869.rb @@ -1,4 +1,4 @@ - control "V-81869" do +control 'V-81869' 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. @@ -13,7 +13,7 @@ unauthorized access to the database. " - desc "check", "In the MongoDB database configuration file (default location: + desc 'check', "In the MongoDB database configuration file (default location: /etc/mongod.conf), review the following parameters: net: @@ -29,7 +29,7 @@ net: ssl: allowInvalidCertificates: true" - desc "fix", "In the MongoDB database configuration file (default location: + desc 'fix', "In the MongoDB database configuration file (default location: /etc/mongod.conf) ensure the following parameters following parameter are set and configured correctly: @@ -46,35 +46,35 @@ allowInvalidCertificates: true Stop/start (restart) the mongod or mongos instance using this configuration." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000172-DB-000075" - tag "satisfies": ["SRG-APP-000172-DB-000075", "SRG-APP-000175-DB-000067"] - tag "gid": "V-81869" - tag "rid": "SV-96583r1_rule" - tag "stig_id": "MD3X-00-000340" - tag "fix_id": "F-88719r1_fix" - tag "cci": ["CCI-000185", "CCI-000197"] - tag "nist": ["IA-5 (2) (a)", "IA-5 (1) (c)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000172-DB-000075' + tag "satisfies": %w(SRG-APP-000172-DB-000075 SRG-APP-000175-DB-000067) + tag "gid": 'V-81869' + tag "rid": 'SV-96583r1_rule' + tag "stig_id": 'MD3X-00-000340' + tag "fix_id": 'F-88719r1_fix' + tag "cci": %w(CCI-000185 CCI-000197) + tag "nist": ['IA-5 (2) (a)', 'IA-5 (1) (c)'] tag "documentable": false tag "severity_override_guidance": false describe.one do describe yaml(input('mongod_conf')) do - its(%w{net ssl allowInvalidCertificates}) { should be nil } + its(%w(net ssl allowInvalidCertificates)) { should be nil } end describe yaml(input('mongod_conf')) do - its(%w{net ssl allowInvalidCertificates}) { should be false } + its(%w(net ssl allowInvalidCertificates)) { should be false } end end describe yaml(input('mongod_conf')) do - its(%w{net ssl mode}) { should cmp 'requireSSL' } + its(%w(net ssl mode)) { should cmp 'requireSSL' } end describe yaml(input('mongod_conf')) do - its(%w{net ssl PEMKeyFile}) { should cmp '/etc/ssl/mongodb.pem' } + its(%w(net ssl PEMKeyFile)) { should cmp '/etc/ssl/mongodb.pem' } end describe yaml(input('mongod_conf')) do - its(%w{net ssl CAFile}) { should cmp '/etc/ssl/mongodbca.pem' } + its(%w(net ssl CAFile)) { should cmp '/etc/ssl/mongodbca.pem' } end end diff --git a/controls/V-81871.rb b/controls/V-81871.rb index 2b3bc94..110a9a7 100644 --- a/controls/V-81871.rb +++ b/controls/V-81871.rb @@ -1,4 +1,4 @@ - control "V-81871" do +control 'V-81871' 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. @@ -19,8 +19,8 @@ use them to impersonate the database on the network or otherwise perform unauthorized actions. " - - desc "check", "In the MongoDB database configuration file (default location: + + desc 'check', "In the MongoDB database configuration file (default location: /etc/mongod.conf), review the following parameters: net: ssl: @@ -41,21 +41,21 @@ 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", "Run these commands: + desc 'fix', "Run these commands: \"chown mongod:mongod /etc/ssl/mongodb.pem\" \"chmod 600 /etc/ssl/mongodb.pem\" \"chown mongod:mongod /etc/ssl/mongodbca.pem\" \"chmod 600 /etc/ssl/mongodbca.pem\"" impact 0.7 - tag "severity": "high" - tag "gtitle": "SRG-APP-000176-DB-000068" - tag "gid": "V-81871" - tag "rid": "SV-96585r1_rule" - tag "stig_id": "MD3X-00-000360" - tag "fix_id": "F-88721r1_fix" - tag "cci": ["CCI-000186"] - tag "nist": ["IA-5 (2) (b)"] + tag "severity": 'high' + tag "gtitle": 'SRG-APP-000176-DB-000068' + tag "gid": 'V-81871' + tag "rid": 'SV-96585r1_rule' + tag "stig_id": 'MD3X-00-000360' + tag "fix_id": 'F-88721r1_fix' + tag "cci": ['CCI-000186'] + tag "nist": ['IA-5 (2) (b)'] tag "documentable": false tag "severity_override_guidance": false @@ -63,13 +63,13 @@ mongod_cafile = yaml(input('mongod_conf'))['net', 'ssl', 'CAFile'] mongodb_service_account = input('mongodb_service_account') mongodb_service_group = input('mongodb_service_group') - + describe file(mongod_pem) do it { should exist } end describe file(mongod_pem) do - it { should_not be_more_permissive_than('0600') } + it { should_not be_more_permissive_than('0600') } its('owner') { should be_in mongodb_service_account } its('group') { should be_in mongodb_service_group } end @@ -79,9 +79,8 @@ end describe file(mongod_cafile) do - it { should_not be_more_permissive_than('0600') } + it { should_not be_more_permissive_than('0600') } its('owner') { should be_in mongodb_service_account } its('group') { should be_in mongodb_service_group } end - -end \ No newline at end of file +end diff --git a/controls/V-81873.rb b/controls/V-81873.rb index d85467d..d6c4e5b 100644 --- a/controls/V-81873.rb +++ b/controls/V-81873.rb @@ -1,4 +1,4 @@ - control "V-81873" do +control 'V-81873' 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. @@ -6,7 +6,7 @@ account for the authenticated identity to be meaningful to MongoDB and useful for authorization decisions." - desc "check", "To authenticate with a client certificate, you must first add + desc 'check', "To authenticate with a client certificate, you must 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; i.e. @@ -23,7 +23,7 @@ If the output shows a Relative Distinguished Name (RDN) for users that are not authorized, this is a finding." - desc "fix", "Add x.509 Certificate subject as an authorized user. + desc 'fix', "Add x.509 Certificate subject as an authorized user. To authenticate with a client certificate, you must first add the value of the subject from the client certificate as a MongoDB user. @@ -79,17 +79,17 @@ db.dropUser(\"\")" impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000177-DB-000069" - tag "gid": "V-81873" - tag "rid": "SV-96587r1_rule" - tag "stig_id": "MD3X-00-000370" - tag "fix_id": "F-88723r1_fix" - tag "cci": ["CCI-000187"] - tag "nist": ["IA-5 (2) (c)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000177-DB-000069' + tag "gid": 'V-81873' + tag "rid": 'SV-96587r1_rule' + tag "stig_id": 'MD3X-00-000370' + tag "fix_id": 'F-88723r1_fix' + tag "cci": ['CCI-000187'] + tag "nist": ['IA-5 (2) (c)'] tag "documentable": false tag "severity_override_guidance": false - + describe 'A manual review is required to ensure MongoDB maps the PKI-authenticated identity to an associated user account' do skip 'A manual review is required to ensure MongoDB maps the PKI-authenticated identity to an associated user diff --git a/controls/V-81875.rb b/controls/V-81875.rb index 043f3ff..3922eb2 100644 --- a/controls/V-81875.rb +++ b/controls/V-81875.rb @@ -1,4 +1,4 @@ - control "V-81875" do +control 'V-81875' do title "MongoDB must use NIST FIPS 140-2-validated cryptographic modules for cryptographic operations." desc "Use of weak or not validated cryptographic algorithms undermines the @@ -20,8 +20,8 @@ NSA Type-X (where X=1, 2, 3, 4) products are NSA-certified, hardware-based encryption modules. " - - desc "check", "If MongoDB is deployed in a classified environment: + + desc 'check', "If MongoDB is deployed in a classified environment: In the MongoDB database configuration file (default location: /etc/mongod.conf), search for and review the following parameters: @@ -44,7 +44,7 @@ cat /proc/sys/crypto/fips_enabled If the above command does not return \"1\", this is a finding." - desc "fix", "Enable FIPS 140-2 mode for MongoDB Enterprise. + desc 'fix', "Enable FIPS 140-2 mode for MongoDB Enterprise. Edit the MongoDB database configuration file (default location: /etc/mongod.conf) to contain the following parameter setting: @@ -60,23 +60,23 @@ mode." impact 0.7 - tag "severity": "high" - tag "gtitle": "SRG-APP-000179-DB-000114" - tag "satisfies": ["SRG-APP-000179-DB-000114", "SRG-APP-000514-DB-000381", - "SRG-APP-000514-DB-000382", "SRG-APP-000514-DB-000383", - "SRG-APP-000416-DB-000380"] - tag "gid": "V-81875" - tag "rid": "SV-96589r1_rule" - tag "stig_id": "MD3X-00-000380" - tag "fix_id": "F-88725r1_fix" - tag "cci": ["CCI-000803", "CCI-002450"] - tag "nist": ["IA-7", "SC-13"] + tag "severity": 'high' + tag "gtitle": 'SRG-APP-000179-DB-000114' + tag "satisfies": %w(SRG-APP-000179-DB-000114 SRG-APP-000514-DB-000381 + SRG-APP-000514-DB-000382 SRG-APP-000514-DB-000383 + SRG-APP-000416-DB-000380) + tag "gid": 'V-81875' + tag "rid": 'SV-96589r1_rule' + tag "stig_id": 'MD3X-00-000380' + tag "fix_id": 'F-88725r1_fix' + tag "cci": %w(CCI-000803 CCI-002450) + tag "nist": %w(IA-7 SC-13) tag "documentable": false tag "severity_override_guidance": false - + if input('is_sensitive') describe yaml(input('mongod_conf')) do - its(%w{net ssl FIPSMode}) { should cmp 'true' } + its(%w(net ssl FIPSMode)) { should cmp 'true' } end else describe 'The system is not a classified environment, therefore for this control is NA' do diff --git a/controls/V-81877.rb b/controls/V-81877.rb index b772c95..053ced0 100644 --- a/controls/V-81877.rb +++ b/controls/V-81877.rb @@ -1,7 +1,7 @@ - control "V-81877" do +control 'V-81877' 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 + 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). @@ -20,8 +20,8 @@ organizational operations, organizational assets, individuals, other organizations, and the Nation. " - - desc "check", "MongoDB grants access to data and commands through role-based + + 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. You can additionally create user-defined roles. @@ -56,7 +56,7 @@ 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", "Prereq: To view a user's roles, must have the \"viewUser\" + desc 'fix', "Prereq: To view a user's roles, must have the \"viewUser\" privilege. Connect to MongoDB. @@ -73,22 +73,22 @@ To grant a role to a user use the db.grantRolesToUser() method." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000180-DB-000115" - tag "satisfies": ["SRG-APP-000180-DB-000115", "SRG-APP-000211-DB-000122", - "SRG-APP-000211-DB-000124"] - tag "gid": "V-81877" - tag "rid": "SV-96591r1_rule" - tag "stig_id": "MD3X-00-000390" - tag "fix_id": "F-88727r2_fix" - tag "cci": ["CCI-000804", "CCI-001082", "CCI-001084"] - tag "nist": ["IA-8", "SC-2", "SC-3"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000180-DB-000115' + tag "satisfies": %w(SRG-APP-000180-DB-000115 SRG-APP-000211-DB-000122 + SRG-APP-000211-DB-000124) + tag "gid": 'V-81877' + tag "rid": 'SV-96591r1_rule' + tag "stig_id": 'MD3X-00-000390' + tag "fix_id": 'F-88727r2_fix' + tag "cci": %w(CCI-000804 CCI-001082 CCI-001084) + tag "nist": %w(IA-8 SC-2 SC-3) tag "documentable": false - tag "severity_override_guidance": false + tag "severity_override_guidance": false mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) - dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map { |x| x['name'] } dbs.each do |db| db_command = "db = db.getSiblingDB('#{db}');db.getUsers()" @@ -96,14 +96,14 @@ results.each do |entry| describe "Manually verify roles for User: `#{entry['user']}` within Database: `#{entry['db']}` - Roles: #{entry['roles']}" do + Roles: #{entry['roles']}" do skip end end end if dbs.empty? - describe "No databases found on the target" do + describe 'No databases found on the target' do skip end end diff --git a/controls/V-81879.rb b/controls/V-81879.rb index 38b6cab..63f50a7 100644 --- a/controls/V-81879.rb +++ b/controls/V-81879.rb @@ -1,4 +1,4 @@ - control "V-81879" do +control 'V-81879' 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 @@ -15,7 +15,7 @@ demonstrated to be effective. " - desc "check", "Check the MongoDB configuration file (default location: + desc 'check', "Check the MongoDB configuration file (default location: /etc/mongod.conf). The following should be set: @@ -25,24 +25,24 @@ mode: requireSSL If this is not found in the MongoDB configuration file, this is a finding." - desc "fix", "Follow the documentation guide at + desc 'fix', "Follow the documentation guide at https://docs.mongodb.com/v3.4/tutorial/configure-ssl/. Stop/start (restart) and mongod or mongos using the MongoDB configuration file." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000224-DB-000384" - tag "gid": "V-81879" - tag "rid": "SV-96593r1_rule" - tag "stig_id": "MD3X-00-000410" - tag "fix_id": "F-88729r1_fix" - tag "cci": ["CCI-001188"] - tag "nist": ["SC-23 (3)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000224-DB-000384' + tag "gid": 'V-81879' + tag "rid": 'SV-96593r1_rule' + tag "stig_id": 'MD3X-00-000410' + tag "fix_id": 'F-88729r1_fix' + tag "cci": ['CCI-001188'] + tag "nist": ['SC-23 (3)'] tag "documentable": false tag "severity_override_guidance": false - + describe yaml(input('mongod_conf')) do - its(%w{net ssl mode}) { should cmp 'requireSSL' } + its(%w(net ssl mode)) { should cmp 'requireSSL' } end end diff --git a/controls/V-81881.rb b/controls/V-81881.rb index 2b2f56a..c3532d2 100644 --- a/controls/V-81881.rb +++ b/controls/V-81881.rb @@ -1,4 +1,4 @@ -control "V-81881" do +control 'V-81881' 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 @@ -30,7 +30,7 @@ naturally. The term abort refers to both requested and unexpected terminations. " - desc "check", "Journaling is enabled by default in 64-bit systems. + desc 'check', "Journaling is enabled by default in 64-bit systems. With journaling enabled, if mongod stops unexpectedly, the program can recover everything written to the journal. @@ -44,7 +44,7 @@ If the mongod process was started with the \"--nojournal\" option, this is a finding." - desc "fix", "Modify the mongod startup command-line options by removing the + desc 'fix', "Modify the mongod startup command-line options by removing the \"--nojournal\" option. Edit the MongoDB database configuration file (default location: @@ -57,24 +57,23 @@ Stop/start (restart) any or all mongod processes." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000225-DB-000153" - tag "satisfies": ["SRG-APP-000225-DB-000153", "SRG-APP-000226-DB-000147"] - tag "gid": "V-81881" - tag "rid": "SV-96595r1_rule" - tag "stig_id": "MD3X-00-000420" - tag "fix_id": "F-88731r1_fix" - tag "cci": ["CCI-001190", "CCI-001665"] - tag "nist": ["SC-24"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000225-DB-000153' + tag "satisfies": %w(SRG-APP-000225-DB-000153 SRG-APP-000226-DB-000147) + tag "gid": 'V-81881' + tag "rid": 'SV-96595r1_rule' + tag "stig_id": 'MD3X-00-000420' + tag "fix_id": 'F-88731r1_fix' + tag "cci": %w(CCI-001190 CCI-001665) + tag "nist": ['SC-24'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{storage journal enabled}) { should cmp 'true' } + its(%w(storage journal enabled)) { should cmp 'true' } end describe processes('mongod') do - its('commands.join') { should_not match /--nojournal/} + its('commands.join') { should_not match /--nojournal/ } end - end diff --git a/controls/V-81883.rb b/controls/V-81883.rb index 57f1aa6..32c16c9 100644 --- a/controls/V-81883.rb +++ b/controls/V-81883.rb @@ -1,4 +1,4 @@ - control "V-81883" do +control 'V-81883' 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 @@ -16,7 +16,7 @@ the data will be open to compromise and unauthorized modification. " - desc "check", "If the MongoDB Encrypted Storage Engines is being used, ensure + desc 'check', "If the MongoDB Encrypted Storage Engines is being used, ensure that the \"security.enableEncryption\" option is set to \"true\" in the MongoDB configuration file (default location: /etc/mongod.conf) or that MongoDB was started with the \"--enableEncryption\" command line option. @@ -30,7 +30,7 @@ If any mongod process is started with \"--enableEncryption false\", this is a finding." - desc "fix", "Ensure that the MongoDB Configuration file (default location: + desc 'fix', "Ensure that the MongoDB Configuration file (default location: /etc/mongod.conf) has the following set: security: @@ -42,30 +42,29 @@ Stop/start (restart) and mongod process using either the MongoDB configuration file or that contains the \"--enableEncryption\" option." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000231-DB-000154" - tag "gid": "V-81883" - tag "rid": "SV-96597r1_rule" - tag "stig_id": "MD3X-00-000440" - tag "fix_id": "F-88733r1_fix" - tag "cci": ["CCI-001199"] - tag "nist": ["SC-28"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000231-DB-000154' + tag "gid": 'V-81883' + tag "rid": 'SV-96597r1_rule' + tag "stig_id": 'MD3X-00-000440' + tag "fix_id": 'F-88733r1_fix' + tag "cci": ['CCI-001199'] + tag "nist": ['SC-28'] tag "documentable": false tag "severity_override_guidance": false describe.one do describe yaml(input('mongod_conf')) do - its(%w{security enableEncryption}) { should cmp 'true' } + its(%w(security enableEncryption)) { should cmp 'true' } end describe processes('mongod') do - its('commands.join') { should match /--enableEncryption true/} + its('commands.join') { should match /--enableEncryption true/ } end end describe processes('mongod') do - its('commands.join') { should_not match /--enableEncryption false/} + its('commands.join') { should_not match /--enableEncryption false/ } end - end diff --git a/controls/V-81885.rb b/controls/V-81885.rb index fa90571..4dbf9bf 100644 --- a/controls/V-81885.rb +++ b/controls/V-81885.rb @@ -1,4 +1,4 @@ -control "V-81885" do +control 'V-81885' 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 @@ -13,8 +13,8 @@ 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 + + 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 @@ -25,20 +25,20 @@ 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 + 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 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000243-DB-000128" - tag "gid": "V-81885" - tag "rid": "SV-96599r1_rule" - tag "stig_id": "MD3X-00-000460" - tag "fix_id": "F-88735r1_fix" - tag "cci": ["CCI-001090"] - tag "nist": ["SC-4"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000243-DB-000128' + tag "gid": 'V-81885' + tag "rid": 'SV-96599r1_rule' + tag "stig_id": 'MD3X-00-000460' + tag "fix_id": 'F-88735r1_fix' + tag "cci": ['CCI-001090'] + tag "nist": ['SC-4'] tag "documentable": false tag "severity_override_guidance": false diff --git a/controls/V-81887.rb b/controls/V-81887.rb index bd01355..c372a8a 100644 --- a/controls/V-81887.rb +++ b/controls/V-81887.rb @@ -1,4 +1,4 @@ - control "V-81887" do +control 'V-81887' 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 @@ -10,7 +10,7 @@ Control of information in shared resources is also referred to as object reuse. " - desc "check", "Verify the permissions for the following database files or + desc 'check', "Verify the permissions for the following database files or directories: MongoDB default configuration file: \"/etc/mongod.conf\" @@ -19,7 +19,7 @@ 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." - desc "fix", "Correct the permission to the files and/or directories that are + desc 'fix', "Correct the permission to the files and/or directories that are in violation. MongoDB Configuration file (default location): @@ -31,15 +31,15 @@ chmod -R 755/var/lib/mongo" impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000243-DB-000373" - tag "satisfies": ["SRG-APP-000243-DB-000373", "SRG-APP-000243-DB-000374"] - tag "gid": "V-81887" - tag "rid": "SV-96601r1_rule" - tag "stig_id": "MD3X-00-000470" - tag "fix_id": "F-88737r1_fix" - tag "cci": ["CCI-001090"] - tag "nist": ["SC-4"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000243-DB-000373' + tag "satisfies": %w(SRG-APP-000243-DB-000373 SRG-APP-000243-DB-000374) + tag "gid": 'V-81887' + tag "rid": 'SV-96601r1_rule' + tag "stig_id": 'MD3X-00-000470' + tag "fix_id": 'F-88737r1_fix' + tag "cci": ['CCI-001090'] + tag "nist": ['SC-4'] tag "documentable": false tag "severity_override_guidance": false @@ -48,7 +48,7 @@ if file(input('mongod_conf')).exist? describe file(input('mongod_conf')) do - it { should_not be_more_permissive_than('0755') } + it { should_not be_more_permissive_than('0755') } its('owner') { should be_in mongodb_service_account } its('group') { should be_in mongodb_service_group } end @@ -57,12 +57,12 @@ file is not found at the location specified.' do skip 'This control must be reviewed manually because the configuration file is not found at the location specified.' - end + end end - + if file(input('mongo_data_dir')).exist? describe directory(input('mongo_data_dir')) do - it { should_not be_more_permissive_than('0755') } + it { should_not be_more_permissive_than('0755') } its('owner') { should be_in mongodb_service_account } its('group') { should be_in mongodb_service_group } end @@ -71,6 +71,6 @@ directory is not found at the location specified.' do skip 'This control must be reviewed manually because the Mongodb data directory is not found at the location specified.' - end - end + end + end end diff --git a/controls/V-81889.rb b/controls/V-81889.rb index e9d29ab..3dd05ca 100644 --- a/controls/V-81889.rb +++ b/controls/V-81889.rb @@ -1,4 +1,4 @@ - control "V-81889" do +control 'V-81889' 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 @@ -31,7 +31,7 @@ addressed, and must document what has been discovered. " - desc "check", "As a client program assembles a query in MongoDB, it builds a + 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. @@ -47,7 +47,7 @@ If validation is desired, but no rules are set, the valdiationAction is not \"error\" or the \"bypassDocumentValidation\" option is used for write commands on the application side, this is a finding." - desc "fix", "Disable the javascriptEnabled option in the config file. + desc 'fix', "Disable the javascriptEnabled option in the config file. security: javascriptEnabled: false @@ -55,20 +55,20 @@ If document validation is needed, it should be configured according to the documentation page at https://docs.mongodb.com/manual/core/document-validation/." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000251-DB-000160" - tag "gid": "V-81889" - tag "rid": "SV-96603r1_rule" - tag "stig_id": "MD3X-00-000490" - tag "fix_id": "F-88739r1_fix" - tag "cci": ["CCI-001310"] - tag "nist": ["SI-10"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000251-DB-000160' + tag "gid": 'V-81889' + tag "rid": 'SV-96603r1_rule' + tag "stig_id": 'MD3X-00-000490' + tag "fix_id": 'F-88739r1_fix' + tag "cci": ['CCI-001310'] + tag "nist": ['SI-10'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{security javascriptEnabled}) { should cmp 'false' } + its(%w(security javascriptEnabled)) { should cmp 'false' } end end diff --git a/controls/V-81891.rb b/controls/V-81891.rb index 52878fa..165288b 100644 --- a/controls/V-81891.rb +++ b/controls/V-81891.rb @@ -1,7 +1,7 @@ - control "V-81891" do +control 'V-81891' 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 + 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 @@ -29,7 +29,7 @@ addressed, and must document what has been discovered. " - desc "check", "MongoDB operations permit arbitrary JavaScript expressions to + 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 @@ -38,28 +38,28 @@ security: javascriptEnabled: \"false\"" - desc "fix", "Disable the \"javascriptEnabled\" option. + 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 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000251-DB-000391" - tag "satisfies": ["SRG-APP-000251-DB-000391", "SRG-APP-000251-DB-000392"] - tag "gid": "V-81891" - tag "rid": "SV-96605r1_rule" - tag "stig_id": "MD3X-00-000500" - tag "fix_id": "F-88741r1_fix" - tag "cci": ["CCI-001310"] - tag "nist": ["SI-10"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000251-DB-000391' + tag "satisfies": %w(SRG-APP-000251-DB-000391 SRG-APP-000251-DB-000392) + tag "gid": 'V-81891' + tag "rid": 'SV-96605r1_rule' + tag "stig_id": 'MD3X-00-000500' + tag "fix_id": 'F-88741r1_fix' + tag "cci": ['CCI-001310'] + tag "nist": ['SI-10'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{security javascriptEnabled}) { should cmp 'false' } + its(%w(security javascriptEnabled)) { should cmp 'false' } end end diff --git a/controls/V-81893.rb b/controls/V-81893.rb index 88e9916..e6ad307 100644 --- a/controls/V-81893.rb +++ b/controls/V-81893.rb @@ -1,8 +1,8 @@ - control "V-81893" do +control 'V-81893' 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 + 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. @@ -28,8 +28,8 @@ to obtain assurances from the development organization that this issue has been addressed, and must document what has been discovered. " - - desc "check", "Check custom database code to verify that error messages do not + + desc 'check', "Check custom database code to verify that error messages do not contain information beyond what is needed for troubleshooting the issue. If custom database errors contain PII data, sensitive business data, or information useful for identifying the host system or database structure, this @@ -39,23 +39,23 @@ If a user is attempting to perform an operation for which they do not have privileges, the database will return an error message that the operation is not authorized." - desc "fix", "Configure custom database code and associated application code + desc 'fix', "Configure custom database code and associated application code not to divulge sensitive information or information useful for system identification in error messages." impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000266-DB-000162" - tag "gid": "V-81893" - tag "rid": "SV-96607r1_rule" - tag "stig_id": "MD3X-00-000520" - tag "fix_id": "F-88743r1_fix" - tag "cci": ["CCI-001312"] - tag "nist": ["SI-11 a"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000266-DB-000162' + tag "gid": 'V-81893' + tag "rid": 'SV-96607r1_rule' + tag "stig_id": 'MD3X-00-000520' + tag "fix_id": 'F-88743r1_fix' + tag "cci": ['CCI-001312'] + tag "nist": ['SI-11 a'] tag "documentable": false tag "severity_override_guidance": false describe 'A manual review is required to check custom database code to verfiy that error messages do not contain information beyond what is needed for troubleshooting the issue.' do skip 'A manual review is required to check custom database code to verfiy that error messages do not contain information beyond what is needed for troubleshooting the issue.' end -end \ No newline at end of file +end diff --git a/controls/V-81895.rb b/controls/V-81895.rb index cd3b4cc..8658520 100644 --- a/controls/V-81895.rb +++ b/controls/V-81895.rb @@ -1,4 +1,4 @@ - control "V-81895" do +control 'V-81895' do title "MongoDB must reveal detailed error messages only to the ISSO, ISSM, SA, and DBA." desc "If MongoDB provides too much information in error logs and @@ -35,8 +35,8 @@ 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 + + desc 'check', "A mongod or mongos running with \"security.redactClientLogData\" redacts any message accompanying a given log event before logging. @@ -52,7 +52,7 @@ redactClientLogData: \"true\" If this parameter is not present, this is a finding." - desc "fix", "Edit the MongoDB configuration file (default location: + 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: @@ -60,20 +60,20 @@ redactClientLogData: \"true\" Stop/start (restart) any mongod or mongos using the MongoDB configuration file." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000267-DB-000163" - tag "gid": "V-81895" - tag "rid": "SV-96609r1_rule" - tag "stig_id": "MD3X-00-000530" - tag "fix_id": "F-88745r1_fix" - tag "cci": ["CCI-001314"] - tag "nist": ["SI-11 b"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000267-DB-000163' + tag "gid": 'V-81895' + tag "rid": 'SV-96609r1_rule' + tag "stig_id": 'MD3X-00-000530' + tag "fix_id": 'F-88745r1_fix' + tag "cci": ['CCI-001314'] + tag "nist": ['SI-11 b'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{security redactClientLogData}) { should cmp 'true' } + its(%w(security redactClientLogData)) { should cmp 'true' } end end diff --git a/controls/V-81897.rb b/controls/V-81897.rb index 4683744..57542f7 100644 --- a/controls/V-81897.rb +++ b/controls/V-81897.rb @@ -1,7 +1,7 @@ - control "V-81897" do +control 'V-81897' do title "MongoDB must associate organization-defined types of security labels having organization-defined security label values with information in storage." - desc "Without the association of security labels to information, there is no + 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 @@ -24,7 +24,7 @@ product, a third-party product, or custom application code. " - desc "check", "MongoDB supports role-based access control at the collection + desc 'check', "MongoDB supports role-based access control at the collection level. If enabled, the database process should be started with \"security.authorization:enabled\" in the config file or with \"--auth\" in the command line. @@ -45,7 +45,7 @@ If desired and aggregation queries in the application code are not using the $redact stage with appropriate logic, this is a finding." - desc "fix", "Follow the documentation page to setup + desc 'fix', "Follow the documentation page to setup RBAC:https://docs.mongodb.com/manual/core/authorization/. For the required collections, create specific read-only views that allow access @@ -56,18 +56,18 @@ Use the \"$redact\" operator to restrict the contents of the documents based on information stored in the documents themselves as documented here: https://docs.mongodb.com/master/reference/operator/aggregation/redact/" - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000311-DB-000308" - tag "satisfies": ["SRG-APP-000311-DB-000308", "SRG-APP-000313-DB-000309", - "SRG-APP-000313-DB-000310"] - tag "gid": "V-81897" - tag "rid": "SV-96611r1_rule" - tag "stig_id": "MD3X-00-000540" - tag "fix_id": "F-88747r1_fix" - tag "cci": ["CCI-002262", "CCI-002263", "CCI-002264"] - tag "nist": ["AC-16 a"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000311-DB-000308' + tag "satisfies": %w(SRG-APP-000311-DB-000308 SRG-APP-000313-DB-000309 + SRG-APP-000313-DB-000310) + tag "gid": 'V-81897' + tag "rid": 'SV-96611r1_rule' + tag "stig_id": 'MD3X-00-000540' + tag "fix_id": 'F-88747r1_fix' + tag "cci": %w(CCI-002262 CCI-002263 CCI-002264) + tag "nist": ['AC-16 a'] tag "documentable": false tag "severity_override_guidance": false diff --git a/controls/V-81899.rb b/controls/V-81899.rb index bac5d5e..df54de6 100644 --- a/controls/V-81899.rb +++ b/controls/V-81899.rb @@ -1,4 +1,4 @@ - control "V-81899" do +control 'V-81899' 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 @@ -30,14 +30,14 @@ require identity-based access control, that limitation is not required for this use of discretionary access control. " - - desc "check", "Review the system documentation to obtain the definition of the + + desc 'check', "Review the system documentation to obtain the definition of the database/DBMS functionality considered privileged in the context of the system in question. If any functionality considered privileged has access privileges granted to non-privileged users, this is a finding." - desc "fix", "Revoke any roles with unnecessary privileges to privileged + desc 'fix', "Revoke any roles with unnecessary privileges to privileged functionality by executing the revoke command as documented here: https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/ @@ -48,17 +48,17 @@ If a new role with associated privileges needs to be created, follow the documentation here: https://docs.mongodb.com/v3.4/reference/command/createRole/" - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000328-DB-000301" - tag "satisfies": ["SRG-APP-000328-DB-000301", "SRG-APP-000340-DB-000304"] - tag "gid": "V-81899" - tag "rid": "SV-96613r1_rule" - tag "stig_id": "MD3X-00-000570" - tag "fix_id": "F-88749r1_fix" - tag "cci": ["CCI-002165", "CCI-002235"] - tag "nist": ["AC-3 (4)", "AC-6 (10)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000328-DB-000301' + tag "satisfies": %w(SRG-APP-000328-DB-000301 SRG-APP-000340-DB-000304) + tag "gid": 'V-81899' + tag "rid": 'SV-96613r1_rule' + tag "stig_id": 'MD3X-00-000570' + tag "fix_id": 'F-88749r1_fix' + tag "cci": %w(CCI-002165 CCI-002235) + tag "nist": ['AC-3 (4)', 'AC-6 (10)'] tag "documentable": false tag "severity_override_guidance": false diff --git a/controls/V-81901.rb b/controls/V-81901.rb index 6d79a8d..0207fd4 100644 --- a/controls/V-81901.rb +++ b/controls/V-81901.rb @@ -1,4 +1,4 @@ - control "V-81901" do +control 'V-81901' do title "MongoDB must provide the means for individuals in authorized roles to change the auditing to be performed on all application components, based on all selectable event criteria within organization-defined time thresholds." @@ -16,7 +16,7 @@ real time, within minutes, or within hours. " - desc "check", "The MongoDB auditing facility allows authorized administrators + desc 'check', "The MongoDB auditing facility allows authorized administrators and users track system activity. Once auditing is configured and enabled, changes to the audit events and filters require restarting the mongod (and mongos, if applicable) instances. This can be done with zero down time by @@ -26,7 +26,7 @@ If replica sets or the rolling maintenance approach is not used for the procedure by the application owner, this is a finding." - desc "fix", "Use the rolling maintenance procedure. + desc 'fix', "Use the rolling maintenance procedure. For each member of a replica set, starting with a secondary member, perform the following sequence of events, ending with the primary: @@ -34,16 +34,16 @@ 1. Restart the mongod instance as a standalone. 2. Perform the configure auditing task on the standalone instance. 3. Restart the mongod instance as a member of the replica set." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000353-DB-000324" - tag "gid": "V-81901" - tag "rid": "SV-96615r1_rule" - tag "stig_id": "MD3X-00-000590" - tag "fix_id": "F-88751r1_fix" - tag "cci": ["CCI-001914"] - tag "nist": ["AU-12 (3)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000353-DB-000324' + tag "gid": 'V-81901' + tag "rid": 'SV-96615r1_rule' + tag "stig_id": 'MD3X-00-000590' + tag "fix_id": 'F-88751r1_fix' + tag "cci": ['CCI-001914'] + tag "nist": ['AU-12 (3)'] tag "documentable": false tag "severity_override_guidance": false diff --git a/controls/V-81903.rb b/controls/V-81903.rb index b5d235c..93ef996 100644 --- a/controls/V-81903.rb +++ b/controls/V-81903.rb @@ -1,7 +1,7 @@ - control "V-81903" do +control 'V-81903' 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 + 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. @@ -17,7 +17,7 @@ off-loading the records to the centralized system. " - desc "check", "MongoDB can be configured to write audit events to the syslog + desc 'check', "MongoDB can be configured to write audit events to the syslog in Linux, but this is not available in Windows. Audit events can also be written to a file in either JSON on BSON format. Through the use of third-party tools or via syslog directly, audit records can be pushed to a centralized log @@ -25,7 +25,7 @@ If a centralized tool for log management is not installed and configured to collect audit logs or syslogs, this is a finding." - desc "fix", "Install a centralized syslog collecting tool and configured it as + desc 'fix', "Install a centralized syslog collecting tool and configured it as instructed in its documentation. To enable auditing and print audit events to the syslog in JSON format, specify @@ -37,25 +37,25 @@ dbPath: /data/db auditLog: destination: syslog" - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000356-DB-000314" - tag "gid": "V-81903" - tag "rid": "SV-96617r1_rule" - tag "stig_id": "MD3X-00-000600" - tag "fix_id": "F-88753r1_fix" - tag "cci": ["CCI-001844"] - tag "nist": ["AU-3 (2)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000356-DB-000314' + tag "gid": 'V-81903' + tag "rid": 'SV-96617r1_rule' + tag "stig_id": 'MD3X-00-000600' + tag "fix_id": 'F-88753r1_fix' + tag "cci": ['CCI-001844'] + tag "nist": ['AU-3 (2)'] tag "documentable": false tag "severity_override_guidance": false describe.one do describe yaml(input('mongod_conf')) do - its(%w{auditLog destination}) { should cmp 'syslog' } + its(%w(auditLog destination)) { should cmp 'syslog' } end describe processes('mongod') do - its('commands.join') { should match /--auditDestination syslog/} + its('commands.join') { should match /--auditDestination syslog/ } end end end diff --git a/controls/V-81905.rb b/controls/V-81905.rb index 48af860..0a412ed 100644 --- a/controls/V-81905.rb +++ b/controls/V-81905.rb @@ -1,4 +1,4 @@ - control "V-81905" do +control 'V-81905' 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, @@ -23,7 +23,7 @@ ability to reuse the space formerly occupied by off-loaded records. " - desc "check", "Investigate whether there have been any incidents where MongoDB + desc 'check', "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. @@ -42,26 +42,26 @@ identify how the \"auditlog.destination\" is configured. When the \"auditlog.destination\" is \"file\", this is a finding." - desc "fix", "View the mongodb configuration file (default location: + desc 'fix', "View the mongodb configuration file (default location: /etc/mongod.conf) and view the \"auditlog.path\" to identify the storage volume. 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 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000357-DB-000316" - tag "gid": "V-81905" - tag "rid": "SV-96619r1_rule" - tag "stig_id": "MD3X-00-000620" - tag "fix_id": "F-88755r3_fix" - tag "cci": ["CCI-001849"] - tag "nist": ["AU-4"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000357-DB-000316' + tag "gid": 'V-81905' + tag "rid": 'SV-96619r1_rule' + tag "stig_id": 'MD3X-00-000620' + tag "fix_id": 'F-88755r3_fix' + tag "cci": ['CCI-001849'] + tag "nist": ['AU-4'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{auditLog destination}) { should_not cmp 'file' } - its(%w{auditLog destination}) { should_not be_nil } + its(%w(auditLog destination)) { should_not cmp 'file' } + its(%w(auditLog destination)) { should_not be_nil } end end diff --git a/controls/V-81907.rb b/controls/V-81907.rb index 4f3e56b..b137682 100644 --- a/controls/V-81907.rb +++ b/controls/V-81907.rb @@ -1,4 +1,4 @@ - control "V-81907" do +control 'V-81907' do title "MongoDB must provide a warning to appropriate support staff when allocated audit record storage volume reaches 75% of maximum audit record storage capacity." @@ -16,8 +16,8 @@ The appropriate support staff include, at a minimum, the ISSO and the DBA/SA. " - - desc "check", "A MongoDB audit log that is configured to be stored in a file + + desc 'check', "A MongoDB audit log that is configured to be stored in a file is identified in the MongoDB configuration file (default: /etc/mongod.conf) under the \"auditLog:\" key and subkey \"destination:\" where \"destination\" is \"file\". @@ -29,28 +29,28 @@ identify how the \"auditlog.destination\" is configured. When the \"auditlog.destination\" is \"file\", this is a finding." - desc "fix", "View the mongodb configuration file (default location: + 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%." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000359-DB-000319" - tag "gid": "V-81907" - tag "rid": "SV-96621r1_rule" - tag "stig_id": "MD3X-00-000630" - tag "fix_id": "F-88757r2_fix" - tag "cci": ["CCI-001855"] - tag "nist": ["AU-5 (1)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000359-DB-000319' + tag "gid": 'V-81907' + tag "rid": 'SV-96621r1_rule' + tag "stig_id": 'MD3X-00-000630' + tag "fix_id": 'F-88757r2_fix' + tag "cci": ['CCI-001855'] + tag "nist": ['AU-5 (1)'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{auditLog destination}) { should_not cmp 'file' } - its(%w{auditLog destination}) { should_not be_nil } + its(%w(auditLog destination)) { should_not cmp 'file' } + its(%w(auditLog destination)) { should_not be_nil } end end diff --git a/controls/V-81909.rb b/controls/V-81909.rb index 9f97896..9674ecd 100644 --- a/controls/V-81909.rb +++ b/controls/V-81909.rb @@ -1,4 +1,4 @@ - control "V-81909" do +control 'V-81909' do title "MongoDB must prohibit user installation of logic modules (stored procedures, functions, triggers, views, etc.) without explicit privileged status." @@ -25,7 +25,7 @@ procedures, functions, triggers, views, etc. " - desc "check", "If MongoDB supports only software development, experimentation, + 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. @@ -40,28 +40,28 @@ If any such permissions exist and are not documented and approved, this is a finding." - desc "fix", "Revoke any roles with unnecessary privileges to privileged + desc 'fix', "Revoke any roles with unnecessary privileges to privileged functionality by executing the revoke command. Revoke any unnecessary privileges from any roles by executing the revoke command. Create, as needed, new role(s) with associated privileges." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000378-DB-000365" - tag "gid": "V-81909" - tag "rid": "SV-96623r1_rule" - tag "stig_id": "MD3X-00-000650" - tag "fix_id": "F-88759r1_fix" - tag "cci": ["CCI-001812"] - tag "nist": ["CM-11 (2)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000378-DB-000365' + tag "gid": 'V-81909' + tag "rid": 'SV-96623r1_rule' + tag "stig_id": 'MD3X-00-000650' + tag "fix_id": 'F-88759r1_fix' + tag "cci": ['CCI-001812'] + tag "nist": ['CM-11 (2)'] tag "documentable": false tag "severity_override_guidance": false mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) - dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map { |x| x['name'] } dbs.each do |db| db_command = "db = db.getSiblingDB('#{db}');db.getRoles({rolesInfo: 1,showPrivileges:true,showBuiltinRoles: true})" @@ -69,14 +69,14 @@ results.each do |entry| describe "Manually verify privileges for Role: `#{entry['role']}` within Database: `#{db}` - Privileges: #{entry['privileges']}" do + Privileges: #{entry['privileges']}" do skip end end end if dbs.empty? - describe "No databases found on the target" do + describe 'No databases found on the target' do skip end end diff --git a/controls/V-81911.rb b/controls/V-81911.rb index 1e1a02b..2a6ec8c 100644 --- a/controls/V-81911.rb +++ b/controls/V-81911.rb @@ -1,4 +1,4 @@ - control "V-81911" do +control 'V-81911' 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 @@ -15,7 +15,7 @@ including upgrades and modifications. " - desc "check", "Review the security configuration of the MongoDB database(s). + desc 'check', "Review the security configuration of the MongoDB database(s). If unauthorized users can start the mongod or mongos processes or edit the MongoDB configuration file (default location: /etc/mongod.conf), this is a @@ -35,7 +35,7 @@ MongoDB commands to view roles in a particular database: db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })" - desc "fix", "Prereq: To view a user's roles, must have the \"viewUser\" + desc 'fix', "Prereq: To view a user's roles, must have the \"viewUser\" privilege. https://docs.mongodb.com/v3.4/reference/privilege-actions/ @@ -53,46 +53,44 @@ To grant a role to a user use the db.grantRolesToUser() method. https://docs.mongodb.com/v3.4/reference/method/db.grantRolesToUser/" - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000380-DB-000360" - tag "gid": "V-81911" - tag "rid": "SV-96625r1_rule" - tag "stig_id": "MD3X-00-000670" - tag "fix_id": "F-88761r1_fix" - tag "cci": ["CCI-001813"] - tag "nist": ["CM-5 (1)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000380-DB-000360' + tag "gid": 'V-81911' + tag "rid": 'SV-96625r1_rule' + tag "stig_id": 'MD3X-00-000670' + tag "fix_id": 'F-88761r1_fix' + tag "cci": ['CCI-001813'] + tag "nist": ['CM-5 (1)'] tag "documentable": false tag "severity_override_guidance": false - - describe "Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file" do - skip "Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file" + + describe 'Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file' do + skip 'Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file' end - describe "Manually verify enforces access restrictions associated with changes to the configuration of the database(s)" do - skip "Manually verify enforces access restrictions associated with changes to the configuration of the database(s)" + describe 'Manually verify enforces access restrictions associated with changes to the configuration of the database(s)' do + skip 'Manually verify enforces access restrictions associated with changes to the configuration of the database(s)' end mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) - dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map { |x| x['name'] } dbs.each do |db| db_command = "db = db.getSiblingDB('#{db}');db.getUsers()" results = mongo_session.query(db_command) - results.each do |entry| - if entry['roles'].map {|x| x['role']}.include?('userAdminAnyDatabase') - describe "Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdminAnyDatabase` role" do + if entry['roles'].map { |x| x['role'] }.include?('userAdminAnyDatabase') + describe "Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdminAnyDatabase` role" do skip end end - if entry['roles'].map {|x| x['role']}.include?('userAdmin') - describe "Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdmin` role" do - skip - end + next unless entry['roles'].map { |x| x['role'] }.include?('userAdmin') + describe "Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdmin` role" do + skip end end end diff --git a/controls/V-81913.rb b/controls/V-81913.rb index 6f853cd..4e20b48 100644 --- a/controls/V-81913.rb +++ b/controls/V-81913.rb @@ -1,4 +1,4 @@ - control "V-81913" do +control 'V-81913' 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 @@ -28,23 +28,23 @@ Within the DoD, the minimum circumstances requiring reauthentication are privilege escalation and role changes. " - - desc "check", "If organization-defined circumstances or situations require + + desc 'check', "If organization-defined circumstances or situations require reauthentication, and these situations are not configured to terminate existing logins to require reauthentication, this is a finding." - desc "fix", "Determine the organization-defined circumstances or situations + desc 'fix', "Determine the organization-defined circumstances or situations that require reauthentication and ensure that the mongod and mongos processes are stopped/started (restart)." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000389-DB-000372" - tag "gid": "V-81913" - tag "rid": "SV-96627r1_rule" - tag "stig_id": "MD3X-00-000700" - tag "fix_id": "F-88763r1_fix" - tag "cci": ["CCI-002038"] - tag "nist": ["IA-11"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000389-DB-000372' + tag "gid": 'V-81913' + tag "rid": 'SV-96627r1_rule' + tag "stig_id": 'MD3X-00-000700' + tag "fix_id": 'F-88763r1_fix' + tag "cci": ['CCI-002038'] + tag "nist": ['IA-11'] tag "documentable": false tag "severity_override_guidance": false diff --git a/controls/V-81915.rb b/controls/V-81915.rb index 7c3fbe7..19367e5 100644 --- a/controls/V-81915.rb +++ b/controls/V-81915.rb @@ -1,10 +1,10 @@ - control "V-81915" do +control 'V-81915' 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 + desc 'check', "If MongoDB is configured to authenticate using SASL and LDAP/Active Directory 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). @@ -13,9 +13,9 @@ If any mongos process is running (a MongoDB shared cluster) the \"userCacheInvalidationIntervalSecs\" option can be used to specify the cache timeout. - The default is \"30\" seconds and the minimum is \"1\" second. + The default is \"30\" seconds and the minimum is \"1\" second. " - desc "fix", "If MongoDB is configured to authenticate using SASL and + desc 'fix', "If MongoDB is configured to authenticate using SASL and LDAP/Active Directory modify and restart the saslauthd command line options in the system boot script and set the \"-t\" option to the appropriate timeout in seconds. @@ -30,25 +30,25 @@ " impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000400-DB-000367" - tag "gid": "V-81915" - tag "rid": "SV-96629r1_rule" - tag "stig_id": "MD3X-00-000710" - tag "fix_id": "F-88765r1_fix" - tag "cci": ["CCI-002007"] - tag "nist": ["IA-5 (13)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000400-DB-000367' + tag "gid": 'V-81915' + tag "rid": 'SV-96629r1_rule' + tag "stig_id": 'MD3X-00-000710' + tag "fix_id": 'F-88765r1_fix' + tag "cci": ['CCI-002007'] + tag "nist": ['IA-5 (13)'] tag "documentable": false tag "severity_override_guidance": false if input('mongo_use_saslauthd') == 'true' && input('mongo_use_ldap') == 'true' describe processes('saslauthd') do - its('commands.join') { should match /-t\s/} + its('commands.join') { should match /-t\s/ } end else impact 0.0 describe 'This control is Not Applicable because MongoDB is not configured to authenticate using SASL and LDAP.' do skip 'This control is Not Applicable because MongoDB is not configured to authenticate using SASL and LDAP.' - end - end + end + end end diff --git a/controls/V-81917.rb b/controls/V-81917.rb index c3c3f10..49373c6 100644 --- a/controls/V-81917.rb +++ b/controls/V-81917.rb @@ -1,4 +1,4 @@ - control "V-81917" do +control 'V-81917' 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." @@ -16,7 +16,7 @@ rather than for the network packet. " - desc "check", "To run MongoDB in SSL mode, you have to obtain a valid + desc 'check', "To run MongoDB in SSL mode, you have to obtain a valid certificate singed by a single certificate authority. Before starting the MongoDB database in SSL mode, verify that certificate used @@ -25,20 +25,20 @@ 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 + 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 authorities." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000427-DB-000385" - tag "gid": "V-81917" - tag "rid": "SV-96631r1_rule" - tag "stig_id": "MD3X-00-000730" - tag "fix_id": "F-88767r1_fix" - tag "cci": ["CCI-002470"] - tag "nist": ["SC-23 (5)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000427-DB-000385' + tag "gid": 'V-81917' + tag "rid": 'SV-96631r1_rule' + tag "stig_id": 'MD3X-00-000730' + tag "fix_id": 'F-88767r1_fix' + tag "cci": ['CCI-002470'] + tag "nist": ['SC-23 (5)'] tag "documentable": false tag "severity_override_guidance": false @@ -49,9 +49,8 @@ x509_cert_file = input('x509_cert_file') unless input('x509_cert_file').nil? x509_cert_file = x509_conf unless x509_conf.nil? x509_cert_file = x509_process_flag unless x509_process_flag.nil? - - if file(x509_cert_file).exist? + if file(x509_cert_file).exist? describe x509_certificate(x509_cert_file) do its('issuer_dn') { should eq input('authorized_certificate_authority') } end diff --git a/controls/V-81919.rb b/controls/V-81919.rb index 6eb7a89..8998040 100644 --- a/controls/V-81919.rb +++ b/controls/V-81919.rb @@ -1,4 +1,4 @@ - control "V-81919" do +control 'V-81919' 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 @@ -22,7 +22,7 @@ " - desc "check", "Review the documentation and/or specification for the + desc 'check', "Review the documentation and/or specification for the organization-defined information. If any data is PII, classified or is deemed by the organization to be encrypted @@ -41,33 +41,33 @@ Items in the <> above and starting with kmip* 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 + desc 'fix', "Configure MongoDB to use the Encrypted Storage Engine and a KMIP appliance as documented here: https://docs.mongodb.com/v3.4/core/security-encryption-at-rest/ https://docs.mongodb.com/v3.4/tutorial/configure-encryption/" impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000428-DB-000386" - tag "satisfies": ["SRG-APP-000428-DB-000386", "SRG-APP-000429-DB-000387"] - tag "gid": "V-81919" - tag "rid": "SV-96633r1_rule" - tag "stig_id": "MD3X-00-000740" - tag "fix_id": "F-88769r1_fix" - tag "cci": ["CCI-002475"] - tag "nist": ["SC-28 (1)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000428-DB-000386' + tag "satisfies": %w(SRG-APP-000428-DB-000386 SRG-APP-000429-DB-000387) + tag "gid": 'V-81919' + tag "rid": 'SV-96633r1_rule' + tag "stig_id": 'MD3X-00-000740' + tag "fix_id": 'F-88769r1_fix' + tag "cci": ['CCI-002475'] + tag "nist": ['SC-28 (1)'] tag "documentable": false tag "severity_override_guidance": false describe.one do describe yaml(input('mongod_conf')) do - its(%w{security kmip serverName}) { should_not be_nil } - its(%w{security kmip port}) { should_not be_nil } - its(%w{security kmip port}) { should_not be_nil } - its(%w{security kmip serverCAFile}) { should_not be_nil } - its(%w{security kmip clientCertificateFile}) { should_not be_nil } - its(['security' , 'enableEncryption']) { should cmp 'true' } + its(%w(security kmip serverName)) { should_not be_nil } + its(%w(security kmip port)) { should_not be_nil } + its(%w(security kmip port)) { should_not be_nil } + its(%w(security kmip serverCAFile)) { should_not be_nil } + its(%w(security kmip clientCertificateFile)) { should_not be_nil } + its(%w(security enableEncryption)) { should cmp 'true' } end describe processes('mongod') do its('commands.join') { should match /--enableEncryption/ } @@ -77,5 +77,4 @@ its('commands.join') { should match /--kmipClientCertificateFile/ } end end - end diff --git a/controls/V-81921.rb b/controls/V-81921.rb index 3f8348a..474e868 100644 --- a/controls/V-81921.rb +++ b/controls/V-81921.rb @@ -1,4 +1,4 @@ - control "V-81921" do +control 'V-81921' 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 @@ -15,7 +15,7 @@ infrastructure must leverage transmission protection mechanisms. " - desc "check", "Review the system information/specification for information + 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. @@ -30,7 +30,7 @@ PEMKeyFile: /etc/ssl/mongodb.pem If net.ssl.mode is not set to \"requireSSL\", this is a finding." - desc "fix", "Stop the MongoDB instance if it is running. Obtain a certificate + 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 ssl configuration options such as: @@ -45,23 +45,23 @@ Start/stop (restart) all mongod or mongos instances using the MongoDB configuration file (default location: /etc/mongod.conf)." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000441-DB-000378" - tag "gid": "V-81921" - tag "rid": "SV-96635r1_rule" - tag "stig_id": "MD3X-00-000760" - tag "fix_id": "F-88771r1_fix" - tag "cci": ["CCI-002420"] - tag "nist": ["SC-8 (2)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000441-DB-000378' + tag "gid": 'V-81921' + tag "rid": 'SV-96635r1_rule' + tag "stig_id": 'MD3X-00-000760' + tag "fix_id": 'F-88771r1_fix' + tag "cci": ['CCI-002420'] + tag "nist": ['SC-8 (2)'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{net ssl mode}) { should cmp 'requireSSL' } + its(%w(net ssl mode)) { should cmp 'requireSSL' } end describe yaml(input('mongod_conf')) do - its(%w{net ssl PEMKeyFile}) { should_not be nil } + its(%w(net ssl PEMKeyFile)) { should_not be nil } end end diff --git a/controls/V-81923.rb b/controls/V-81923.rb index ae8a9af..0a58c95 100644 --- a/controls/V-81923.rb +++ b/controls/V-81923.rb @@ -1,4 +1,4 @@ - control "V-81923" do +control 'V-81923' do title "MongoDB must maintain the confidentiality and integrity of information during reception." desc "Information can be either unintentionally or maliciously disclosed or @@ -17,7 +17,7 @@ must leverage protection mechanisms. " - desc "check", "If the data owner does not have a strict requirement for + 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. @@ -31,7 +31,7 @@ PEMKeyFile: /etc/ssl/mongodb.pem If net.ssl.mode is not set to \"requireSSL\", this is a finding." - desc "fix", "Obtain a certificate from a valid DoD certificate authority to be + desc 'fix', "Obtain a certificate from a valid DoD certificate authority to be used for encrypted data transmission. Modify the MongoDB configuration file (default location: /etc/mongod.conf) with @@ -47,23 +47,23 @@ Start/stop (restart) all mongod or mongos instances using the MongoDB configuration file (default location: /etc/mongod.conf)." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000442-DB-000379" - tag "gid": "V-81923" - tag "rid": "SV-96637r1_rule" - tag "stig_id": "MD3X-00-000770" - tag "fix_id": "F-88773r2_fix" - tag "cci": ["CCI-002422"] - tag "nist": ["SC-8 (2)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000442-DB-000379' + tag "gid": 'V-81923' + tag "rid": 'SV-96637r1_rule' + tag "stig_id": 'MD3X-00-000770' + tag "fix_id": 'F-88773r2_fix' + tag "cci": ['CCI-002422'] + tag "nist": ['SC-8 (2)'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w{net ssl mode}) { should cmp 'requireSSL' } + its(%w(net ssl mode)) { should cmp 'requireSSL' } end describe yaml(input('mongod_conf')) do - its(%w{net ssl PEMKeyFile}) { should_not be nil } + its(%w(net ssl PEMKeyFile)) { should_not be nil } end end diff --git a/controls/V-81925.rb b/controls/V-81925.rb index 54d6771..3c4d8f9 100644 --- a/controls/V-81925.rb +++ b/controls/V-81925.rb @@ -1,4 +1,4 @@ - control "V-81925" do +control 'V-81925' 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 @@ -18,7 +18,7 @@ addressed, and must document what has been discovered. " - desc "check", "As a user with the \"dbAdminAnyDatabase\" role, execute the + desc 'check', "As a user with the \"dbAdminAnyDatabase\" role, execute the following on the database of interest: use myDB db.getCollectionInfos() @@ -27,28 +27,28 @@ information within myDB. For each collection's information received. If the \"options\" sub-document within each does not contain a \"validator\" sub-document, this is a finding." - desc "fix", "Document validation can be added at the time of creation of a + desc 'fix', "Document validation can be added at the time of creation of a 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." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000447-DB-000393" - tag "gid": "V-81925" - tag "rid": "SV-96639r1_rule" - tag "stig_id": "MD3X-00-000780" - tag "fix_id": "F-88775r1_fix" - tag "cci": ["CCI-002754"] - tag "nist": ["SI-10 (3)"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000447-DB-000393' + tag "gid": 'V-81925' + tag "rid": 'SV-96639r1_rule' + tag "stig_id": 'MD3X-00-000780' + tag "fix_id": 'F-88775r1_fix' + tag "cci": ['CCI-002754'] + tag "nist": ['SI-10 (3)'] tag "documentable": false tag "severity_override_guidance": false - validator_exception_dbs = ['admin','local','config'] + validator_exception_dbs = %w(admin local config) mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism')) - dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map{|x| x['name']} + dbs = mongo_session.query("db.adminCommand('listDatabases')")['databases'].map { |x| x['name'] } dbs.each do |db| next if validator_exception_dbs.include?(db) @@ -57,16 +57,16 @@ results = mongo_session.query(db_command) results.each do |entry| - describe "Database: `#{db}`; Collection `#{entry['name']}`" do + describe "Database: `#{db}`; Collection `#{entry['name']}`" do subject { entry } - its(['options', 'validator']) { should_not be nil } + its(%w(options validator)) { should_not be nil } end end end if dbs.empty? - describe "No databases found on the target" do + describe 'No databases found on the target' do skip end end -end \ No newline at end of file +end diff --git a/controls/V-81927.rb b/controls/V-81927.rb index 79e888b..b9a1c0d 100644 --- a/controls/V-81927.rb +++ b/controls/V-81927.rb @@ -1,4 +1,4 @@ - control "V-81927" do +control 'V-81927' do title "MongoDB must obscure feedback of authentication information during the authentication process to protect the information from possible exploitation/use by unauthorized individuals." @@ -30,7 +30,7 @@ addressed, and must document what has been discovered. " - desc "check", "For the MongoDB command-line tools \"mongo shell\", + desc 'check', "For the MongoDB command-line tools \"mongo shell\", \"mongodump\", \"mongorestore\", \"mongoimport\", \"mongoexport\", which cannot be configured not to accept a plain-text password, and any other essential tool with the same limitation, verify that the system documentation explains the @@ -45,7 +45,7 @@ this practice. If evidence of training does not exist, this is a finding." - desc "fix", "For the \"mongo shell\", \"mongodump\", \"mongorestore\", + 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: @@ -55,20 +55,20 @@ 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 - tag "severity": "high" - tag "gtitle": "SRG-APP-000178-DB-000083" - tag "gid": "V-81927" - tag "rid": "SV-96641r1_rule" - tag "stig_id": "MD3X-00-000800" - tag "fix_id": "F-88777r1_fix" - tag "cci": ["CCI-000206"] - tag "nist": ["IA-6"] + tag "severity": 'high' + tag "gtitle": 'SRG-APP-000178-DB-000083' + tag "gid": 'V-81927' + tag "rid": 'SV-96641r1_rule' + tag "stig_id": 'MD3X-00-000800' + tag "fix_id": 'F-88777r1_fix' + tag "cci": ['CCI-000206'] + tag "nist": ['IA-6'] tag "documentable": false tag "severity_override_guidance": false - tools = ['mongo','mongodump','mongorestore','mongoimport','mongoexport'] + tools = %w(mongo mongodump mongorestore mongoimport mongoexport) installed_tools = [] diff --git a/controls/V-81929.rb b/controls/V-81929.rb index 24f5680..74bceb7 100644 --- a/controls/V-81929.rb +++ b/controls/V-81929.rb @@ -1,4 +1,4 @@ - control "V-81929" do +control 'V-81929' 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." @@ -13,27 +13,27 @@ sources. " - desc "check", "Review the MongoDB documentation and configuration to determine + desc 'check', "Review the MongoDB documentation and configuration to determine it is configured in accordance with DoD security configuration and implementation guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs. If the MongoDB is not configured in accordance with security configuration settings, this is a finding." - desc "fix", "Configure MongoDB in accordance with security configuration + desc 'fix', "Configure MongoDB in accordance with security configuration settings by reviewing the Operation System and MongoDB documentation and applying the necessary configuration parameters to meet the configurations required by the STIG, NSA configuration guidelines, CTOs, DTMs, and IAVMs." - + impact 0.5 - tag "severity": "medium" - tag "gtitle": "SRG-APP-000516-DB-000363" - tag "gid": "V-81929" - tag "rid": "SV-96643r1_rule" - tag "stig_id": "MD3X-00-001100" - tag "fix_id": "F-88779r1_fix" - tag "cci": ["CCI-000366"] - tag "nist": ["CM-6 b"] + tag "severity": 'medium' + tag "gtitle": 'SRG-APP-000516-DB-000363' + tag "gid": 'V-81929' + tag "rid": 'SV-96643r1_rule' + tag "stig_id": 'MD3X-00-001100' + tag "fix_id": 'F-88779r1_fix' + tag "cci": ['CCI-000366'] + tag "nist": ['CM-6 b'] tag "documentable": false tag "severity_override_guidance": false From 5d665221f3b69e4de1432c1eca178f635c576e9a Mon Sep 17 00:00:00 2001 From: HackerShark Date: Fri, 25 Jun 2021 13:07:33 -0400 Subject: [PATCH 24/32] Updated inputs in inspec.yml and inputs.yml to accomodate null values. Also did minor touch ups to the inputs in inspec.yml Signed-off-by: HackerShark --- inputs.yml | 8 ++-- inspec.yml | 108 +++++++++++++++++++++++++---------------------------- 2 files changed, 54 insertions(+), 62 deletions(-) diff --git a/inputs.yml b/inputs.yml index 32c1d98..d2ac3e5 100644 --- a/inputs.yml +++ b/inputs.yml @@ -20,10 +20,10 @@ mongod_hostname: '127.0.0.1' mongod_port: '27017' ssl: false verify_ssl: false -mongod_client_pem: nil -mongod_cafile: nil -authentication_database: nil -authentication_mechanism: nil +mongod_client_pem: null +mongod_cafile: null +authentication_database: null +authentication_mechanism: null mongodb_service_account: ["mongodb", "mongod"] mongodb_service_group: ["mongodb", "mongod"] diff --git a/inspec.yml b/inspec.yml index fbd055f..50cda01 100644 --- a/inspec.yml +++ b/inspec.yml @@ -9,6 +9,52 @@ version: 1.2.0 inspec_version: ">= 4.0" inputs: + - name: username + description: 'User to log into the mongo database' + value: null + sensitive: true + + - name: password + description: 'Password to log into the mongo database' + value: null + sensitive: true + + - name: mongod_hostname + description: 'Hostname for mongodb database' + type: string + value: '127.0.0.1' + + - name: mongod_port + description: 'Port number for the mongodb database' + type: string + value: '27017' + + - name: ssl + description: 'Is ssl enabled' + type: boolean + value: false + + - name: verify_ssl + description: 'Flag for sslAllowInvalidCertificates' + type: boolean + value: false + + - name: mongod_client_pem + description: 'PEM file location on the scan target' + value: null + + - name: mongod_cafile + description: 'CAFILE location on the scan target' + value: null + + - name: authentication_database + description: 'Flag for authentication database' + value: null + + - name: authentication_mechanism + description: 'Flag for authenticaiton mechanism' + value: null + - name: mongod_conf description: 'MongoDB configuration file' type: string @@ -45,76 +91,22 @@ inputs: ] required: true - - name: username - description: 'User to log into the mongo database' - type: string - value: nil - required: true - sensitive: true - - - name: password - description: 'password to log into the mongo database' - type: string - value: nil - required: true - sensitive: true - - - name: mongod_hostname - description: hostname for mongodb database - type: string - value: '127.0.0.1' - - - name: mongod_port - description: Mongo Port - type: string - value: '27017' - - - name: ssl - description: ssl enabled or not - type: boolean - value: false - - - name: verify_ssl - description: Verify SSL - type: boolean - value: false - - - name: mongod_client_pem - description: pem file location - type: string - value: nil - - - name: mongod_cafile - description: cafile location - type: string - value: nil - - - name: authentication_database - description: authentication database - type: string - value: nil - - - name: authentication_mechanism - description: authentication mechanism - type: string - value: nil - - name: mongodb_service_account - description: Mongodb Service Account + description: 'Mongodb Service Account' type: array value: ["mongodb", "mongod"] - name: mongodb_service_group - description: Mongodb Service Group + description: 'Mongodb Service Group' type: array value: ["mongodb", "mongod"] - name: is_sensitive - description: MongoDB is deployed in a sensitive environment + description: 'Is MongoDB deployed in a sensitive environment' type: boolean value: true - name: x509_cert_file - description: x509 cert file location + description: 'x509 cert file location on scan target' type: string value: "/etc/ssl/mongodb.pem" \ No newline at end of file From 3a13b9bfa97033201816dcceeeb1ef8dc8fb6a08 Mon Sep 17 00:00:00 2001 From: Aaron Lippold Date: Fri, 25 Jun 2021 20:14:30 +0000 Subject: [PATCH 25/32] removed `puts` command to fix broken ci/cd Signed-off-by: GitHub --- libraries/mongo_command.rb | 2 +- test.json | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test.json diff --git a/libraries/mongo_command.rb b/libraries/mongo_command.rb index 138af14..40c0505 100644 --- a/libraries/mongo_command.rb +++ b/libraries/mongo_command.rb @@ -142,7 +142,7 @@ def format_command(command) end - puts command + #puts command command end end \ No newline at end of file diff --git a/test.json b/test.json new file mode 100644 index 0000000..ac5e153 --- /dev/null +++ b/test.json @@ -0,0 +1,13 @@ +echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' +echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' +{"name":"mongodb-enterprise-advanced-3-stig-baseline","title":"mongodb-enterprise-advanced-3-stig-baseline","maintainer":"The MITRE SAF Team","copyright":"(c) 2020, The MITRE Corporation","copyright_email":"saf@groups.mitre.org","license":"Apache-2.0","summary":"Inspec Validation Profile for MongoDB Enterprise Advanced 3.x STIG","version":"1.2.0","inspec_version":">= 4.0","inputs":[],"supports":[],"controls":[{"title":"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.","desc":"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.","descriptions":{"default":"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.","check":"Verify that the MongoDB configuration file (default location:\n /etc/mongod.conf) contains the following:\n\n security:\n authorization: \"enabled\"\n\n If this parameter is not present, this is a finding.","fix":"Edit the MongoDB configuration file (default location:\n /etc/mongod.conf) to include the following:\n\n security:\n authorization: \"enabled\"\n\n This will enable SCRAM-SHA-1 authentication (default).\n\n Instruction on configuring the default authentication is provided here:\n\n https://docs.mongodb.com/v3.4/tutorial/enable-authentication/\n\n The high-level steps described by the above will require the following:\n\n 1. Start MongoDB without access control.\n 2. Connect to the instance.\n 3. Create the user administrator.\n 4. Restart the MongoDB instance with access control.\n 5. Connect and authenticate as the user administrator.\n 6. Create additional users as needed for your deployment."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000023-DB-000001","gid":"V-81843","rid":"SV-96557r1_rule","stig_id":"MD3X-00-000010","fix_id":"F-88693r1_fix","cci":["CCI-000015"],"nist":["AC-2 (1)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81843' do\n title \"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.\"\n desc \"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.\"\n\n desc 'check', \"Verify that the MongoDB configuration file (default location:\n /etc/mongod.conf) contains the following:\n\n security:\n authorization: \\\"enabled\\\"\n\n If this parameter is not present, this is a finding.\"\n desc 'fix', \"Edit the MongoDB configuration file (default location:\n /etc/mongod.conf) to include the following:\n\n security:\n authorization: \\\"enabled\\\"\n\n This will enable SCRAM-SHA-1 authentication (default).\n\n Instruction on configuring the default authentication is provided here:\n\n https://docs.mongodb.com/v3.4/tutorial/enable-authentication/\n\n The high-level steps described by the above will require the following:\n\n 1. Start MongoDB without access control.\n 2. Connect to the instance.\n 3. Create the user administrator.\n 4. Restart the MongoDB instance with access control.\n 5. Connect and authenticate as the user administrator.\n 6. Create additional users as needed for your deployment.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000023-DB-000001'\n tag \"gid\": 'V-81843'\n tag \"rid\": 'SV-96557r1_rule'\n tag \"stig_id\": 'MD3X-00-000010'\n tag \"fix_id\": 'F-88693r1_fix'\n tag \"cci\": ['CCI-000015']\n tag \"nist\": ['AC-2 (1)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security authorization)) { should cmp 'enabled' }\n end\nend\n","source_location":{"ref":"./controls/V-81843.rb","line":1},"id":"V-81843"},{"title":"MongoDB software installation account must be restricted to authorized\n users.","desc":"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can have significant effects on the\n overall security of the system.\n\n If the system were to allow any user to make changes to software libraries,\n then those changes might be implemented without undergoing the appropriate\n testing and approvals that are part of a robust change management process.\n\n Accordingly, only qualified and authorized individuals must be allowed\n access to information system components for purposes of initiating changes,\n including upgrades and modifications.\n\n DBA and other privileged administrative or application owner accounts are\n granted privileges that allow actions that can have a great impact on database\n security and operation. It is especially important to grant privileged access\n to only those persons who are qualified and authorized to use them.","descriptions":{"default":"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can have significant effects on the\n overall security of the system.\n\n If the system were to allow any user to make changes to software libraries,\n then those changes might be implemented without undergoing the appropriate\n testing and approvals that are part of a robust change management process.\n\n Accordingly, only qualified and authorized individuals must be allowed\n access to information system components for purposes of initiating changes,\n including upgrades and modifications.\n\n DBA and other privileged administrative or application owner accounts are\n granted privileges that allow actions that can have a great impact on database\n security and operation. It is especially important to grant privileged access\n to only those persons who are qualified and authorized to use them.","check":"Review procedures for controlling, granting access to, and\n tracking use of the DBMS software installation account.\n\n If access or use of this account is not restricted to the minimum number of\n personnel required or if unauthorized access to the account has been granted,\n this is a finding.","fix":"Develop, document, and implement procedures to restrict and track\n use of the DBMS software installation account."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000133-DB-000198","gid":"V-81853","rid":"SV-96567r1_rule","stig_id":"MD3X-00-000250","fix_id":"F-88703r1_fix","cci":["CCI-001499"],"nist":["CM-5 (6)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81853' do\n title \"MongoDB software installation account must be restricted to authorized\n users.\"\n desc \"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can have significant effects on the\n overall security of the system.\n\n If the system were to allow any user to make changes to software libraries,\n then those changes might be implemented without undergoing the appropriate\n testing and approvals that are part of a robust change management process.\n\n Accordingly, only qualified and authorized individuals must be allowed\n access to information system components for purposes of initiating changes,\n including upgrades and modifications.\n\n DBA and other privileged administrative or application owner accounts are\n granted privileges that allow actions that can have a great impact on database\n security and operation. It is especially important to grant privileged access\n to only those persons who are qualified and authorized to use them.\n \"\n\n desc 'check', \"Review procedures for controlling, granting access to, and\n tracking use of the DBMS software installation account.\n\n If access or use of this account is not restricted to the minimum number of\n personnel required or if unauthorized access to the account has been granted,\n this is a finding.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000133-DB-000198'\n tag \"gid\": 'V-81853'\n tag \"rid\": 'SV-96567r1_rule'\n tag \"stig_id\": 'MD3X-00-000250'\n tag \"fix_id\": 'F-88703r1_fix'\n tag \"cci\": ['CCI-001499']\n tag \"nist\": ['CM-5 (6)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n desc 'fix', \"Develop, document, and implement procedures to restrict and track\n use of the DBMS software installation account.\"\n describe 'A manual review is required to ensure there are procedures in place to restrict and track the use of the DBMS software installation account' do\n skip 'A manual review is required to ensure there are procedures in place to restrict and track the use of the DBMS software installation account'\n end\nend\n","source_location":{"ref":"./controls/V-81853.rb","line":1},"id":"V-81853"},{"title":"Database contents must be protected from unauthorized and unintended\n information transfer by enforcement of a data-transfer policy.","desc":"Applications, including DBMSs, must prevent unauthorized and\n unintended information transfer via shared system resources.\n\n Data used for the development and testing of applications often involves\n copying data from production. It is important that specific procedures exist\n for this process, to include the conditions under which such transfer may take\n place, where the copies may reside, and the rules for ensuring sensitive data\n are not exposed.\n\n Copies of sensitive data must not be misplaced or left in a temporary\n location without the proper controls.","descriptions":{"default":"Applications, including DBMSs, must prevent unauthorized and\n unintended information transfer via shared system resources.\n\n Data used for the development and testing of applications often involves\n copying data from production. It is important that specific procedures exist\n for this process, to include the conditions under which such transfer may take\n place, where the copies may reside, and the rules for ensuring sensitive data\n are not exposed.\n\n Copies of sensitive data must not be misplaced or left in a temporary\n location without the proper controls.","check":"Review the procedures for the refreshing of development/test\n data from production.\n\n Review any scripts or code that exists for the movement of production data to\n development/test systems, or to any other location or for any other purpose.\n\n Verify that copies of production data are not left in unprotected locations.\n\n If the code that exists for data movement does not comply with the\n organization-defined data transfer policy and/or fails to remove any copies of\n production data from unprotected locations, this is a finding.","fix":"Modify any code used for moving data from production to\n development/test systems to comply with the organization-defined data transfer\n policy, and to ensure copies of production data are not left in unsecured\n locations."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000243-DB-000128","gid":"V-81885","rid":"SV-96599r1_rule","stig_id":"MD3X-00-000460","fix_id":"F-88735r1_fix","cci":["CCI-001090"],"nist":["SC-4"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81885' do\n title \"Database contents must be protected from unauthorized and unintended\n information transfer by enforcement of a data-transfer policy.\"\n desc \"Applications, including DBMSs, must prevent unauthorized and\n unintended information transfer via shared system resources.\n\n Data used for the development and testing of applications often involves\n copying data from production. It is important that specific procedures exist\n for this process, to include the conditions under which such transfer may take\n place, where the copies may reside, and the rules for ensuring sensitive data\n are not exposed.\n\n Copies of sensitive data must not be misplaced or left in a temporary\n location without the proper controls.\n \"\n\n desc 'check', \"Review the procedures for the refreshing of development/test\n data from production.\n\n Review any scripts or code that exists for the movement of production data to\n development/test systems, or to any other location or for any other purpose.\n\n Verify that copies of production data are not left in unprotected locations.\n\n If the code that exists for data movement does not comply with the\n organization-defined data transfer policy and/or fails to remove any copies of\n production data from unprotected locations, this is a finding.\"\n desc 'fix', \"Modify any code used for moving data from production to\n development/test systems to comply with the organization-defined data transfer\n policy, and to ensure copies of production data are not left in unsecured\n locations.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000243-DB-000128'\n tag \"gid\": 'V-81885'\n tag \"rid\": 'SV-96599r1_rule'\n tag \"stig_id\": 'MD3X-00-000460'\n tag \"fix_id\": 'F-88735r1_fix'\n tag \"cci\": ['CCI-001090']\n tag \"nist\": ['SC-4']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure that database contents are protected from unauthorized and unintended\n information transfer by enforcement of a data-transfer policy.' do\n skip 'A manual review is required to ensure that database contents are protected from unauthorized and unintended\n information transfer by enforcement of a data-transfer policy.'\n end\nend\n","source_location":{"ref":"./controls/V-81885.rb","line":1},"id":"V-81885"},{"title":"MongoDB must allocate audit record storage capacity in accordance with\n site audit record storage requirements.","desc":"In order to ensure sufficient storage capacity for the audit logs,\n MongoDB must be able to allocate audit record storage capacity. Although\n another requirement (SRG-APP-000515-DB-000318) mandates that audit data be\n off-loaded to a centralized log management system, it remains necessary to\n provide space on the database server to serve as a buffer against outages and\n capacity limits of the off-loading mechanism.\n\n The task of allocating audit record storage capacity is usually performed\n during initial installation of MongoDB and is closely associated with the DBA\n and system administrator roles. The DBA or system administrator will usually\n coordinate the allocation of physical drive space with the application\n owner/installer and the application will prompt the installer to provide the\n capacity information, the physical location of the disk, or both.\n\n In determining the capacity requirements, consider such factors as: total\n number of users; expected number of concurrent users during busy periods;\n number and type of events being monitored; types and amounts of data being\n captured; the frequency/speed with which audit records are off-loaded to the\n central log management system; and any limitations that exist on MongoDB's\n ability to reuse the space formerly occupied by off-loaded records.","descriptions":{"default":"In order to ensure sufficient storage capacity for the audit logs,\n MongoDB must be able to allocate audit record storage capacity. Although\n another requirement (SRG-APP-000515-DB-000318) mandates that audit data be\n off-loaded to a centralized log management system, it remains necessary to\n provide space on the database server to serve as a buffer against outages and\n capacity limits of the off-loading mechanism.\n\n The task of allocating audit record storage capacity is usually performed\n during initial installation of MongoDB and is closely associated with the DBA\n and system administrator roles. The DBA or system administrator will usually\n coordinate the allocation of physical drive space with the application\n owner/installer and the application will prompt the installer to provide the\n capacity information, the physical location of the disk, or both.\n\n In determining the capacity requirements, consider such factors as: total\n number of users; expected number of concurrent users during busy periods;\n number and type of events being monitored; types and amounts of data being\n captured; the frequency/speed with which audit records are off-loaded to the\n central log management system; and any limitations that exist on MongoDB's\n ability to reuse the space formerly occupied by off-loaded records.","check":"Investigate whether there have been any incidents where MongoDB\n ran out of audit log space since the last time the space was allocated or other\n corrective measures were taken.\n\n If there have been incidents where MongoDB ran out of audit log space, this is\n a finding.\n\n A MongoDB audit log that is configured to be stored in a file is identified in\n the MongoDB configuration file (default: /etc/mongod.conf) under the\n \"auditLog:\" key and subkey \"destination:\" where \"destination\" is\n \"file\".\n\n If this is the case then the \"AuditLog:\" subkey \"path:\" determines where\n (device/directory) that file will be located.\n\n View the mongodb configuration file (default location: /etc/mongod.conf) and\n identify how the \"auditlog.destination\" is configured.\n\n When the \"auditlog.destination\" is \"file\", this is a finding.","fix":"View the mongodb configuration file (default location:\n /etc/mongod.conf) and view the \"auditlog.path\" to identify the storage volume.\n\n Allocate sufficient space to the storage volume hosting the file identified in\n the MongoDB configuration \"auditLog.path\" to support audit file peak demand."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000357-DB-000316","gid":"V-81905","rid":"SV-96619r1_rule","stig_id":"MD3X-00-000620","fix_id":"F-88755r3_fix","cci":["CCI-001849"],"nist":["AU-4"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81905' do\n title \"MongoDB must allocate audit record storage capacity in accordance with\n site audit record storage requirements.\"\n desc \"In order to ensure sufficient storage capacity for the audit logs,\n MongoDB must be able to allocate audit record storage capacity. Although\n another requirement (SRG-APP-000515-DB-000318) mandates that audit data be\n off-loaded to a centralized log management system, it remains necessary to\n provide space on the database server to serve as a buffer against outages and\n capacity limits of the off-loading mechanism.\n\n The task of allocating audit record storage capacity is usually performed\n during initial installation of MongoDB and is closely associated with the DBA\n and system administrator roles. The DBA or system administrator will usually\n coordinate the allocation of physical drive space with the application\n owner/installer and the application will prompt the installer to provide the\n capacity information, the physical location of the disk, or both.\n\n In determining the capacity requirements, consider such factors as: total\n number of users; expected number of concurrent users during busy periods;\n number and type of events being monitored; types and amounts of data being\n captured; the frequency/speed with which audit records are off-loaded to the\n central log management system; and any limitations that exist on MongoDB's\n ability to reuse the space formerly occupied by off-loaded records.\n \"\n\n desc 'check', \"Investigate whether there have been any incidents where MongoDB\n ran out of audit log space since the last time the space was allocated or other\n corrective measures were taken.\n\n If there have been incidents where MongoDB ran out of audit log space, this is\n a finding.\n\n A MongoDB audit log that is configured to be stored in a file is identified in\n the MongoDB configuration file (default: /etc/mongod.conf) under the\n \\\"auditLog:\\\" key and subkey \\\"destination:\\\" where \\\"destination\\\" is\n \\\"file\\\".\n\n If this is the case then the \\\"AuditLog:\\\" subkey \\\"path:\\\" determines where\n (device/directory) that file will be located.\n\n View the mongodb configuration file (default location: /etc/mongod.conf) and\n identify how the \\\"auditlog.destination\\\" is configured.\n\n When the \\\"auditlog.destination\\\" is \\\"file\\\", this is a finding.\"\n desc 'fix', \"View the mongodb configuration file (default location:\n /etc/mongod.conf) and view the \\\"auditlog.path\\\" to identify the storage volume.\n\n Allocate sufficient space to the storage volume hosting the file identified in\n the MongoDB configuration \\\"auditLog.path\\\" to support audit file peak demand.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000357-DB-000316'\n tag \"gid\": 'V-81905'\n tag \"rid\": 'SV-96619r1_rule'\n tag \"stig_id\": 'MD3X-00-000620'\n tag \"fix_id\": 'F-88755r3_fix'\n tag \"cci\": ['CCI-001849']\n tag \"nist\": ['AU-4']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog destination)) { should_not cmp 'file' }\n its(%w(auditLog destination)) { should_not be_nil }\n end\nend\n","source_location":{"ref":"./controls/V-81905.rb","line":1},"id":"V-81905"},{"title":"MongoDB must prohibit the use of cached authenticators after an\n organization-defined time period.","desc":"If cached authentication information is out-of-date, the validity of\n the authentication information may be questionable.","descriptions":{"default":"If cached authentication information is out-of-date, the validity of\n the authentication information may be questionable.","check":"If MongoDB is configured to authenticate using SASL and\n LDAP/Active Directory check the saslauthd command line options in the system\n boot script that starts saslauthd (the location will be dependent on the\n specific Linux operating system and boot script layout and naming conventions).\n If the \"-t\" option is not set for the \"saslauthd\" process in the system\n boot script, this is a finding.\n If any mongos process is running (a MongoDB shared cluster) the\n \"userCacheInvalidationIntervalSecs\" option can be used to specify the cache\n timeout.\n The default is \"30\" seconds and the minimum is \"1\" second.","fix":"If MongoDB is configured to authenticate using SASL and\n LDAP/Active Directory modify and restart the saslauthd command line options in\n the system boot script and set the \"-t\" option to the appropriate timeout in\n seconds.\n From the Linux Command line (with root/sudo privs) run the following command to\n restart the saslauthd process after making the change for the \"-t\" parameter:\n systemctl restart saslauthd\n If any mongos process is running (a MongoDB shared cluster) the\n \"userCacheInvalidationIntervalSecs\" option to adjust the timeout in seconds\n can be changed from the default \"30\" seconds.\n This is accomplished by modifying the mongos configuration file (default\n location: /etc/mongod.conf) and then restarting mongos."},"impact":0.0,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000400-DB-000367","gid":"V-81915","rid":"SV-96629r1_rule","stig_id":"MD3X-00-000710","fix_id":"F-88765r1_fix","cci":["CCI-002007"],"nist":["IA-5 (13)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81915' do\n title \"MongoDB must prohibit the use of cached authenticators after an\n organization-defined time period.\"\n desc \"If cached authentication information is out-of-date, the validity of\n the authentication information may be questionable.\"\n\n desc 'check', \"If MongoDB is configured to authenticate using SASL and\n LDAP/Active Directory check the saslauthd command line options in the system\n boot script that starts saslauthd (the location will be dependent on the\n specific Linux operating system and boot script layout and naming conventions).\n If the \\\"-t\\\" option is not set for the \\\"saslauthd\\\" process in the system\n boot script, this is a finding.\n If any mongos process is running (a MongoDB shared cluster) the\n \\\"userCacheInvalidationIntervalSecs\\\" option can be used to specify the cache\n timeout.\n The default is \\\"30\\\" seconds and the minimum is \\\"1\\\" second.\n \"\n desc 'fix', \"If MongoDB is configured to authenticate using SASL and\n LDAP/Active Directory modify and restart the saslauthd command line options in\n the system boot script and set the \\\"-t\\\" option to the appropriate timeout in\n seconds.\n From the Linux Command line (with root/sudo privs) run the following command to\n restart the saslauthd process after making the change for the \\\"-t\\\" parameter:\n systemctl restart saslauthd\n If any mongos process is running (a MongoDB shared cluster) the\n \\\"userCacheInvalidationIntervalSecs\\\" option to adjust the timeout in seconds\n can be changed from the default \\\"30\\\" seconds.\n This is accomplished by modifying the mongos configuration file (default\n location: /etc/mongod.conf) and then restarting mongos.\n \"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000400-DB-000367'\n tag \"gid\": 'V-81915'\n tag \"rid\": 'SV-96629r1_rule'\n tag \"stig_id\": 'MD3X-00-000710'\n tag \"fix_id\": 'F-88765r1_fix'\n tag \"cci\": ['CCI-002007']\n tag \"nist\": ['IA-5 (13)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n if input('mongo_use_saslauthd') == 'true' && input('mongo_use_ldap') == 'true'\n describe processes('saslauthd') do\n its('commands.join') { should match /-t\\s/ }\n end\n else\n impact 0.0\n describe 'This control is Not Applicable because MongoDB is not configured to authenticate using SASL and LDAP.' do\n skip 'This control is Not Applicable because MongoDB is not configured to authenticate using SASL and LDAP.'\n end\n end\nend\n","source_location":{"ref":"./controls/V-81915.rb","line":1},"id":"V-81915"},{"title":"MongoDB must only accept end entity certificates issued by DoD PKI or\n DoD-approved PKI Certification Authorities (CAs) for the establishment of all\n encrypted sessions.","desc":"Only DoD-approved external PKIs have been evaluated to ensure that\n they have security controls and identity vetting procedures in place which are\n sufficient for DoD systems to rely on the identity asserted in the certificate.\n PKIs lacking sufficient security controls and identity vetting procedures risk\n being compromised and issuing certificates that enable adversaries to\n impersonate legitimate users.\n\n The authoritative list of DoD-approved PKIs is published at\n http://iase.disa.mil/pki-pke/interoperability.\n\n This requirement focuses on communications protection for MongoDB session\n rather than for the network packet.","descriptions":{"default":"Only DoD-approved external PKIs have been evaluated to ensure that\n they have security controls and identity vetting procedures in place which are\n sufficient for DoD systems to rely on the identity asserted in the certificate.\n PKIs lacking sufficient security controls and identity vetting procedures risk\n being compromised and issuing certificates that enable adversaries to\n impersonate legitimate users.\n\n The authoritative list of DoD-approved PKIs is published at\n http://iase.disa.mil/pki-pke/interoperability.\n\n This requirement focuses on communications protection for MongoDB session\n rather than for the network packet.","check":"To run MongoDB in SSL mode, you have to obtain a valid\n certificate singed by a single certificate authority.\n\n Before starting the MongoDB database in SSL mode, verify that certificate used\n is issued by a valid DoD certificate authority (openssl x509 -in\n -text | grep -i \"issuer\").\n\n If there is any issuer present in the certificate that is not a DoD approved\n certificate authority, this is a finding.","fix":"Remove any certificate that was not issued by an approved DoD\n certificate authority. Contact the organization's certificate issuer and\n request a new certificate that is issued by a valid DoD certificate\n authorities."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000427-DB-000385","gid":"V-81917","rid":"SV-96631r1_rule","stig_id":"MD3X-00-000730","fix_id":"F-88767r1_fix","cci":["CCI-002470"],"nist":["SC-23 (5)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81917' do\n title \"MongoDB must only accept end entity certificates issued by DoD PKI or\n DoD-approved PKI Certification Authorities (CAs) for the establishment of all\n encrypted sessions.\"\n desc \"Only DoD-approved external PKIs have been evaluated to ensure that\n they have security controls and identity vetting procedures in place which are\n sufficient for DoD systems to rely on the identity asserted in the certificate.\n PKIs lacking sufficient security controls and identity vetting procedures risk\n being compromised and issuing certificates that enable adversaries to\n impersonate legitimate users.\n\n The authoritative list of DoD-approved PKIs is published at\n http://iase.disa.mil/pki-pke/interoperability.\n\n This requirement focuses on communications protection for MongoDB session\n rather than for the network packet.\n \"\n\n desc 'check', \"To run MongoDB in SSL mode, you have to obtain a valid\n certificate singed by a single certificate authority.\n\n Before starting the MongoDB database in SSL mode, verify that certificate used\n is issued by a valid DoD certificate authority (openssl x509 -in\n -text | grep -i \\\"issuer\\\").\n\n If there is any issuer present in the certificate that is not a DoD approved\n certificate authority, this is a finding.\"\n desc 'fix', \"Remove any certificate that was not issued by an approved DoD\n certificate authority. Contact the organization's certificate issuer and\n request a new certificate that is issued by a valid DoD certificate\n authorities.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000427-DB-000385'\n tag \"gid\": 'V-81917'\n tag \"rid\": 'SV-96631r1_rule'\n tag \"stig_id\": 'MD3X-00-000730'\n tag \"fix_id\": 'F-88767r1_fix'\n tag \"cci\": ['CCI-002470']\n tag \"nist\": ['SC-23 (5)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n # Process flag takes precedence over the conf file\n x509_conf = yaml(input('mongod_conf'))['net', 'tls', 'certificateKeyFile']\n x509_process_flag = processes('mongod').commands.join.gsub('--tlsCertificateKeyFile', '').strip\n\n x509_cert_file = input('x509_cert_file') unless input('x509_cert_file').nil?\n x509_cert_file = x509_conf unless x509_conf.nil?\n x509_cert_file = x509_process_flag unless x509_process_flag.nil?\n\n if file(x509_cert_file).exist?\n describe x509_certificate(x509_cert_file) do\n its('issuer_dn') { should eq input('authorized_certificate_authority') }\n end\n else\n describe 'x509 file not found, manual review required' do\n skip 'x509 file not found, manual review required'\n end\n end\nend\n","source_location":{"ref":"./controls/V-81917.rb","line":1},"id":"V-81917"},{"title":"MongoDB must provide the means for individuals in authorized roles to\n change the auditing to be performed on all application components, based on all\n selectable event criteria within organization-defined time thresholds.","desc":"If authorized individuals do not have the ability to modify auditing\n parameters in response to a changing threat environment, the organization may\n not be able to effectively respond, and important forensic information may be\n lost.\n\n This requirement enables organizations to extend or limit auditing as\n necessary to meet organizational requirements. Auditing that is limited to\n conserve information system resources may be extended to address certain threat\n situations. In addition, auditing may be limited to a specific set of events to\n facilitate audit reduction, analysis, and reporting. Organizations can\n establish time thresholds in which audit actions are changed, for example, near\n real time, within minutes, or within hours.","descriptions":{"default":"If authorized individuals do not have the ability to modify auditing\n parameters in response to a changing threat environment, the organization may\n not be able to effectively respond, and important forensic information may be\n lost.\n\n This requirement enables organizations to extend or limit auditing as\n necessary to meet organizational requirements. Auditing that is limited to\n conserve information system resources may be extended to address certain threat\n situations. In addition, auditing may be limited to a specific set of events to\n facilitate audit reduction, analysis, and reporting. Organizations can\n establish time thresholds in which audit actions are changed, for example, near\n real time, within minutes, or within hours.","check":"The MongoDB auditing facility allows authorized administrators\n and users track system activity. Once auditing is configured and enabled,\n changes to the audit events and filters require restarting the mongod (and\n mongos, if applicable) instances. This can be done with zero down time by\n performing the modifications using a rolling maintenance approach (i.e., change\n the parameters on the secondaries, step down the primary such that one of the\n reconfigured secondaries becomes the primary then reconfigure the old primary).\n\n If replica sets or the rolling maintenance approach is not used for the\n procedure by the application owner, this is a finding.","fix":"Use the rolling maintenance procedure.\n\n For each member of a replica set, starting with a secondary member, perform the\n following sequence of events, ending with the primary:\n\n 1. Restart the mongod instance as a standalone.\n 2. Perform the configure auditing task on the standalone instance.\n 3. Restart the mongod instance as a member of the replica set."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000353-DB-000324","gid":"V-81901","rid":"SV-96615r1_rule","stig_id":"MD3X-00-000590","fix_id":"F-88751r1_fix","cci":["CCI-001914"],"nist":["AU-12 (3)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81901' do\n title \"MongoDB must provide the means for individuals in authorized roles to\n change the auditing to be performed on all application components, based on all\n selectable event criteria within organization-defined time thresholds.\"\n desc \"If authorized individuals do not have the ability to modify auditing\n parameters in response to a changing threat environment, the organization may\n not be able to effectively respond, and important forensic information may be\n lost.\n\n This requirement enables organizations to extend or limit auditing as\n necessary to meet organizational requirements. Auditing that is limited to\n conserve information system resources may be extended to address certain threat\n situations. In addition, auditing may be limited to a specific set of events to\n facilitate audit reduction, analysis, and reporting. Organizations can\n establish time thresholds in which audit actions are changed, for example, near\n real time, within minutes, or within hours.\n \"\n\n desc 'check', \"The MongoDB auditing facility allows authorized administrators\n and users track system activity. Once auditing is configured and enabled,\n changes to the audit events and filters require restarting the mongod (and\n mongos, if applicable) instances. This can be done with zero down time by\n performing the modifications using a rolling maintenance approach (i.e., change\n the parameters on the secondaries, step down the primary such that one of the\n reconfigured secondaries becomes the primary then reconfigure the old primary).\n\n If replica sets or the rolling maintenance approach is not used for the\n procedure by the application owner, this is a finding.\"\n desc 'fix', \"Use the rolling maintenance procedure.\n\n For each member of a replica set, starting with a secondary member, perform the\n following sequence of events, ending with the primary:\n\n 1. Restart the mongod instance as a standalone.\n 2. Perform the configure auditing task on the standalone instance.\n 3. Restart the mongod instance as a member of the replica set.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000353-DB-000324'\n tag \"gid\": 'V-81901'\n tag \"rid\": 'SV-96615r1_rule'\n tag \"stig_id\": 'MD3X-00-000590'\n tag \"fix_id\": 'F-88751r1_fix'\n tag \"cci\": ['CCI-001914']\n tag \"nist\": ['AU-12 (3)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to check if replica sets or the rolling maintenance approach is not used for changes to the audit events & filters' do\n skip 'A manual review is required to check if replica sets or the rolling maintenance approach is not used for changes to the audit events & filters'\n end\nend\n","source_location":{"ref":"./controls/V-81901.rb","line":1},"id":"V-81901"},{"title":"When invalid inputs are received, MongoDB must behave in a predictable\n and documented manner that reflects organizational and system objectives.","desc":"A common vulnerability is unplanned behavior when invalid inputs are\n received. This requirement guards against adverse or unintended system behavior\n caused by invalid inputs, where information system responses to the invalid\n input may be disruptive or cause the system to fail into an unsafe state.\n The behavior will be derived from the organizational and system\n requirements and includes, but is not limited to, notification of the\n appropriate personnel, creating an audit record, and rejecting invalid input.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"A common vulnerability is unplanned behavior when invalid inputs are\n received. This requirement guards against adverse or unintended system behavior\n caused by invalid inputs, where information system responses to the invalid\n input may be disruptive or cause the system to fail into an unsafe state.\n The behavior will be derived from the organizational and system\n requirements and includes, but is not limited to, notification of the\n appropriate personnel, creating an audit record, and rejecting invalid input.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"As a user with the \"dbAdminAnyDatabase\" role, execute the\n following on the database of interest:\n use myDB\n db.getCollectionInfos()\n Where \"myDB\" is the name of the database on which validator rules are to be\n inspected. This returns an array of documents containing all collections\n information within myDB. For each collection's information received.\n If the \"options\" sub-document within each does not contain a \"validator\"\n sub-document, this is a finding.","fix":"Document validation can be added at the time of creation of a\n collection. Existing collections can also be modified with document validation\n rules. Use the \"validator\" option to create or update a collection with the\n desired validation rules."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000447-DB-000393","gid":"V-81925","rid":"SV-96639r1_rule","stig_id":"MD3X-00-000780","fix_id":"F-88775r1_fix","cci":["CCI-002754"],"nist":["SI-10 (3)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81925' do\n title \"When invalid inputs are received, MongoDB must behave in a predictable\n and documented manner that reflects organizational and system objectives.\"\n desc \"A common vulnerability is unplanned behavior when invalid inputs are\n received. This requirement guards against adverse or unintended system behavior\n caused by invalid inputs, where information system responses to the invalid\n input may be disruptive or cause the system to fail into an unsafe state.\n The behavior will be derived from the organizational and system\n requirements and includes, but is not limited to, notification of the\n appropriate personnel, creating an audit record, and rejecting invalid input.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"As a user with the \\\"dbAdminAnyDatabase\\\" role, execute the\n following on the database of interest:\n use myDB\n db.getCollectionInfos()\n Where \\\"myDB\\\" is the name of the database on which validator rules are to be\n inspected. This returns an array of documents containing all collections\n information within myDB. For each collection's information received.\n If the \\\"options\\\" sub-document within each does not contain a \\\"validator\\\"\n sub-document, this is a finding.\"\n desc 'fix', \"Document validation can be added at the time of creation of a\n collection. Existing collections can also be modified with document validation\n rules. Use the \\\"validator\\\" option to create or update a collection with the\n desired validation rules.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000447-DB-000393'\n tag \"gid\": 'V-81925'\n tag \"rid\": 'SV-96639r1_rule'\n tag \"stig_id\": 'MD3X-00-000780'\n tag \"fix_id\": 'F-88775r1_fix'\n tag \"cci\": ['CCI-002754']\n tag \"nist\": ['SI-10 (3)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n validator_exception_dbs = %w(admin local config)\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n next if validator_exception_dbs.include?(db)\n\n db_command = \"db = db.getSiblingDB('#{db}');db.getCollectionInfos()\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Database: `#{db}`; Collection `#{entry['name']}`\" do\n subject { entry }\n its(%w(options validator)) { should_not be nil }\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81925.rb","line":1},"id":"V-81925"},{"title":"MongoDB must enforce access restrictions associated with changes to\n the configuration of MongoDB or database(s).","desc":"Failure to provide logical access restrictions associated with changes\n to configuration may have significant effects on the overall security of the\n system.\n\n When dealing with access restrictions pertaining to change control, it\n should be noted that any changes to the hardware, software, and/or firmware\n components of the information system can potentially have significant effects\n on the overall security of the system.\n\n Accordingly, only qualified and authorized individuals should be allowed to\n obtain access to system components for the purposes of initiating changes,\n including upgrades and modifications.","descriptions":{"default":"Failure to provide logical access restrictions associated with changes\n to configuration may have significant effects on the overall security of the\n system.\n\n When dealing with access restrictions pertaining to change control, it\n should be noted that any changes to the hardware, software, and/or firmware\n components of the information system can potentially have significant effects\n on the overall security of the system.\n\n Accordingly, only qualified and authorized individuals should be allowed to\n obtain access to system components for the purposes of initiating changes,\n including upgrades and modifications.","check":"Review the security configuration of the MongoDB database(s).\n\n If unauthorized users can start the mongod or mongos processes or edit the\n MongoDB configuration file (default location: /etc/mongod.conf), this is a\n finding.\n\n If MongoDB does not enforce access restrictions associated with changes to the\n configuration of the database(s), this is a finding.\n\n To assist in conducting reviews of permissions, the following MongoDB commands\n describe permissions of databases and users:\n\n Permissions of concern in this respect include the following, and possibly\n others:\n - any user with a role of userAdminAnyDatabase role or userAdmin role\n - any database or with a user have a role or privilege with \"C\" (create) or\n \"w\" (update) privileges that are not necessary\n\n MongoDB commands to view roles in a particular database:\n db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })","fix":"Prereq: To view a user's roles, must have the \"viewUser\"\n privilege.\n https://docs.mongodb.com/v3.4/reference/privilege-actions/\n\n Connect to MongoDB.\n\n For each database, identify the user's roles for the database.\n\n use \n db.getUser(\"[username]\")\n\n The server will return a document with the user's roles.\n\n To revoke a user's role from a database use the db.revokeRolesFromUser() method.\n https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/\n\n To grant a role to a user use the db.grantRolesToUser() method.\n https://docs.mongodb.com/v3.4/reference/method/db.grantRolesToUser/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000380-DB-000360","gid":"V-81911","rid":"SV-96625r1_rule","stig_id":"MD3X-00-000670","fix_id":"F-88761r1_fix","cci":["CCI-001813"],"nist":["CM-5 (1)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81911' do\n title \"MongoDB must enforce access restrictions associated with changes to\n the configuration of MongoDB or database(s).\"\n desc \"Failure to provide logical access restrictions associated with changes\n to configuration may have significant effects on the overall security of the\n system.\n\n When dealing with access restrictions pertaining to change control, it\n should be noted that any changes to the hardware, software, and/or firmware\n components of the information system can potentially have significant effects\n on the overall security of the system.\n\n Accordingly, only qualified and authorized individuals should be allowed to\n obtain access to system components for the purposes of initiating changes,\n including upgrades and modifications.\n \"\n\n desc 'check', \"Review the security configuration of the MongoDB database(s).\n\n If unauthorized users can start the mongod or mongos processes or edit the\n MongoDB configuration file (default location: /etc/mongod.conf), this is a\n finding.\n\n If MongoDB does not enforce access restrictions associated with changes to the\n configuration of the database(s), this is a finding.\n\n To assist in conducting reviews of permissions, the following MongoDB commands\n describe permissions of databases and users:\n\n Permissions of concern in this respect include the following, and possibly\n others:\n - any user with a role of userAdminAnyDatabase role or userAdmin role\n - any database or with a user have a role or privilege with \\\"C\\\" (create) or\n \\\"w\\\" (update) privileges that are not necessary\n\n MongoDB commands to view roles in a particular database:\n db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })\"\n desc 'fix', \"Prereq: To view a user's roles, must have the \\\"viewUser\\\"\n privilege.\n https://docs.mongodb.com/v3.4/reference/privilege-actions/\n\n Connect to MongoDB.\n\n For each database, identify the user's roles for the database.\n\n use \n db.getUser(\\\"[username]\\\")\n\n The server will return a document with the user's roles.\n\n To revoke a user's role from a database use the db.revokeRolesFromUser() method.\n https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/\n\n To grant a role to a user use the db.grantRolesToUser() method.\n https://docs.mongodb.com/v3.4/reference/method/db.grantRolesToUser/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000380-DB-000360'\n tag \"gid\": 'V-81911'\n tag \"rid\": 'SV-96625r1_rule'\n tag \"stig_id\": 'MD3X-00-000670'\n tag \"fix_id\": 'F-88761r1_fix'\n tag \"cci\": ['CCI-001813']\n tag \"nist\": ['CM-5 (1)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file' do\n skip 'Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file'\n end\n\n describe 'Manually verify enforces access restrictions associated with changes to the configuration of the database(s)' do\n skip 'Manually verify enforces access restrictions associated with changes to the configuration of the database(s)'\n end\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getUsers()\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n if entry['roles'].map { |x| x['role'] }.include?('userAdminAnyDatabase')\n describe \"Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdminAnyDatabase` role\" do\n skip\n end\n end\n next unless entry['roles'].map { |x| x['role'] }.include?('userAdmin')\n describe \"Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdmin` role\" do\n skip\n end\n end\n end\nend\n","source_location":{"ref":"./controls/V-81911.rb","line":1},"id":"V-81911"},{"title":"MongoDB must associate organization-defined types of security labels\n having organization-defined security label values with information in storage.","desc":"Without the association of security labels to information, there is no\n basis for MongoDB to make security-related access-control decisions.\n\n Security labels are abstractions representing the basic properties or\n characteristics of an entity (e.g., subjects and objects) with respect to\n safeguarding information.\n\n These labels are typically associated with internal data structures (e.g.,\n tables, rows) within the database and are used to enable the implementation of\n access control and flow control policies, reflect special dissemination,\n handling, or distribution instructions, or support other aspects of the\n information security policy.\n\n One example includes marking data as classified or FOUO. These security\n labels may be assigned manually or during data processing, but, either way, it\n is imperative these assignments are maintained while the data is in storage. If\n the security labels are lost when the data is stored, there is the risk of a\n data compromise.\n\n The mechanism used to support security labeling may be a feature of MongoDB\n product, a third-party product, or custom application code.","descriptions":{"default":"Without the association of security labels to information, there is no\n basis for MongoDB to make security-related access-control decisions.\n\n Security labels are abstractions representing the basic properties or\n characteristics of an entity (e.g., subjects and objects) with respect to\n safeguarding information.\n\n These labels are typically associated with internal data structures (e.g.,\n tables, rows) within the database and are used to enable the implementation of\n access control and flow control policies, reflect special dissemination,\n handling, or distribution instructions, or support other aspects of the\n information security policy.\n\n One example includes marking data as classified or FOUO. These security\n labels may be assigned manually or during data processing, but, either way, it\n is imperative these assignments are maintained while the data is in storage. If\n the security labels are lost when the data is stored, there is the risk of a\n data compromise.\n\n The mechanism used to support security labeling may be a feature of MongoDB\n product, a third-party product, or custom application code.","check":"MongoDB supports role-based access control at the collection\n level. If enabled, the database process should be started with\n \"security.authorization:enabled\" in the config file or with \"--auth\" in the\n command line.\n\n For documents that have been labeled (e.g., {\"tag\" : \"classified\"}),\n read-only views can be created and secured via access privileges such that a\n user can only view those documents that have a specific tag or tags (e.g., user\n x can only view records that are labeled with the tag of classified). Existing\n views can be listed using the db.getCollectionInfos() command for the selected\n database in mongo shell.\n\n If a view is not present for the collection requiring security labeling, this\n is a finding.\n\n MongoDB supports field-level redaction that allows the application to indicate\n to the database whether or not certain fields should be returned based on\n values in the field labels.\n\n If desired and aggregation queries in the application code are not using the\n $redact stage with appropriate logic, this is a finding.","fix":"Follow the documentation page to setup\n RBAC:https://docs.mongodb.com/manual/core/authorization/.\n\n For the required collections, create specific read-only views that allow access\n to only a subset of the data in a collection as documented here:\n https://docs.mongodb.com/manual/core/views/. Permissions on the view are\n specified separately from the permissions on the underlying collection.\n\n Use the \"$redact\" operator to restrict the contents of the documents based on\n information stored in the documents themselves as documented here:\n https://docs.mongodb.com/master/reference/operator/aggregation/redact/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000311-DB-000308","satisfies":["SRG-APP-000311-DB-000308","SRG-APP-000313-DB-000309","SRG-APP-000313-DB-000310"],"gid":"V-81897","rid":"SV-96611r1_rule","stig_id":"MD3X-00-000540","fix_id":"F-88747r1_fix","cci":["CCI-002262","CCI-002263","CCI-002264"],"nist":["AC-16 a"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81897' do\n title \"MongoDB must associate organization-defined types of security labels\n having organization-defined security label values with information in storage.\"\n desc \"Without the association of security labels to information, there is no\n basis for MongoDB to make security-related access-control decisions.\n\n Security labels are abstractions representing the basic properties or\n characteristics of an entity (e.g., subjects and objects) with respect to\n safeguarding information.\n\n These labels are typically associated with internal data structures (e.g.,\n tables, rows) within the database and are used to enable the implementation of\n access control and flow control policies, reflect special dissemination,\n handling, or distribution instructions, or support other aspects of the\n information security policy.\n\n One example includes marking data as classified or FOUO. These security\n labels may be assigned manually or during data processing, but, either way, it\n is imperative these assignments are maintained while the data is in storage. If\n the security labels are lost when the data is stored, there is the risk of a\n data compromise.\n\n The mechanism used to support security labeling may be a feature of MongoDB\n product, a third-party product, or custom application code.\n \"\n\n desc 'check', \"MongoDB supports role-based access control at the collection\n level. If enabled, the database process should be started with\n \\\"security.authorization:enabled\\\" in the config file or with \\\"--auth\\\" in the\n command line.\n\n For documents that have been labeled (e.g., {\\\"tag\\\" : \\\"classified\\\"}),\n read-only views can be created and secured via access privileges such that a\n user can only view those documents that have a specific tag or tags (e.g., user\n x can only view records that are labeled with the tag of classified). Existing\n views can be listed using the db.getCollectionInfos() command for the selected\n database in mongo shell.\n\n If a view is not present for the collection requiring security labeling, this\n is a finding.\n\n MongoDB supports field-level redaction that allows the application to indicate\n to the database whether or not certain fields should be returned based on\n values in the field labels.\n\n If desired and aggregation queries in the application code are not using the\n $redact stage with appropriate logic, this is a finding.\"\n desc 'fix', \"Follow the documentation page to setup\n RBAC:https://docs.mongodb.com/manual/core/authorization/.\n\n For the required collections, create specific read-only views that allow access\n to only a subset of the data in a collection as documented here:\n https://docs.mongodb.com/manual/core/views/. Permissions on the view are\n specified separately from the permissions on the underlying collection.\n\n Use the \\\"$redact\\\" operator to restrict the contents of the documents based on\n information stored in the documents themselves as documented here:\n https://docs.mongodb.com/master/reference/operator/aggregation/redact/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000311-DB-000308'\n tag \"satisfies\": %w(SRG-APP-000311-DB-000308 SRG-APP-000313-DB-000309\n SRG-APP-000313-DB-000310)\n tag \"gid\": 'V-81897'\n tag \"rid\": 'SV-96611r1_rule'\n tag \"stig_id\": 'MD3X-00-000540'\n tag \"fix_id\": 'F-88747r1_fix'\n tag \"cci\": %w(CCI-002262 CCI-002263 CCI-002264)\n tag \"nist\": ['AC-16 a']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure MongoDB associates organization-defined types of security labels\n having organization-defined security label values with information in storage.' do\n skip 'A manual review is required to ensure MongoDB associates organization-defined types of security labels\n having organization-defined security label values with information in storage.'\n end\nend\n","source_location":{"ref":"./controls/V-81897.rb","line":1},"id":"V-81897"},{"title":"MongoDB must uniquely identify and authenticate organizational users\n (or processes acting on behalf of organizational users).","desc":"To assure accountability and prevent unauthenticated access,\n organizational users must be identified and authenticated to prevent potential\n misuse and compromise of the system.\n\n Organizational users include organizational employees or individuals the\n organization deems to have equivalent status of employees (e.g., contractors).\n Organizational users (and any processes acting on behalf of users) must be\n uniquely identified and authenticated for all accesses, except the following:\n\n (i) Accesses explicitly identified and documented by the organization.\n Organizations document specific user actions that can be performed on the\n information system without identification or authentication; and\n (ii) Accesses that occur through authorized use of group authenticators\n without individual authentication. Organizations may require unique\n identification of individuals using shared accounts, for detailed\n accountability of individual activity.","descriptions":{"default":"To assure accountability and prevent unauthenticated access,\n organizational users must be identified and authenticated to prevent potential\n misuse and compromise of the system.\n\n Organizational users include organizational employees or individuals the\n organization deems to have equivalent status of employees (e.g., contractors).\n Organizational users (and any processes acting on behalf of users) must be\n uniquely identified and authenticated for all accesses, except the following:\n\n (i) Accesses explicitly identified and documented by the organization.\n Organizations document specific user actions that can be performed on the\n information system without identification or authentication; and\n (ii) Accesses that occur through authorized use of group authenticators\n without individual authentication. Organizations may require unique\n identification of individuals using shared accounts, for detailed\n accountability of individual activity.","check":"To view another user’s information, you must have the\n \"viewUser\" action on the other user’s database.\n\n For each database in the system, run the following command:\n\n db.getUsers()\n\n Ensure each user identified is a member of an appropriate organization that can\n access the database.\n\n If a user is found not be a member or an appropriate organization that can\n access the database, this is a finding.\n\n Verify that the MongoDB configuration file (default location: /etc/mongod.conf)\n contains the following:\n\n security:\n authorization: \"enabled\"\n\n If this parameter is not present, this is a finding.","fix":"Prereq: To drop a user from a database, must have the\n \"dropUser\" action on the database.\n\n For any user not a member of an appropriate organization and has access to a\n database in the system run the following command:\n\n // Change to the appropriate database\n use \n db.dropUser(, {w: \"majority\", wtimeout: 5000}\n\n If the MongoDB configuration file (default location: /etc/mongod.conf) does not\n contain\n\n security: authorization: \"enabled\"\n\n Edit the MongoDB configuration file, add these parameters, stop/start (restart)\n any mongod or mongos process using this MongoDB configuration file."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000148-DB-000103","gid":"V-81863","rid":"SV-96577r1_rule","stig_id":"MD3X-00-000310","fix_id":"F-88713r1_fix","cci":["CCI-000764"],"nist":["IA-2"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81863' do\n title \"MongoDB must uniquely identify and authenticate organizational users\n (or processes acting on behalf of organizational users).\"\n desc \"To assure accountability and prevent unauthenticated access,\n organizational users must be identified and authenticated to prevent potential\n misuse and compromise of the system.\n\n Organizational users include organizational employees or individuals the\n organization deems to have equivalent status of employees (e.g., contractors).\n Organizational users (and any processes acting on behalf of users) must be\n uniquely identified and authenticated for all accesses, except the following:\n\n (i) Accesses explicitly identified and documented by the organization.\n Organizations document specific user actions that can be performed on the\n information system without identification or authentication; and\n (ii) Accesses that occur through authorized use of group authenticators\n without individual authentication. Organizations may require unique\n identification of individuals using shared accounts, for detailed\n accountability of individual activity.\n \"\n\n desc 'check', \"To view another user’s information, you must have the\n \\\"viewUser\\\" action on the other user’s database.\n\n For each database in the system, run the following command:\n\n db.getUsers()\n\n Ensure each user identified is a member of an appropriate organization that can\n access the database.\n\n If a user is found not be a member or an appropriate organization that can\n access the database, this is a finding.\n\n Verify that the MongoDB configuration file (default location: /etc/mongod.conf)\n contains the following:\n\n security:\n authorization: \\\"enabled\\\"\n\n If this parameter is not present, this is a finding.\"\n desc 'fix', \"Prereq: To drop a user from a database, must have the\n \\\"dropUser\\\" action on the database.\n\n For any user not a member of an appropriate organization and has access to a\n database in the system run the following command:\n\n // Change to the appropriate database\n use \n db.dropUser(, {w: \\\"majority\\\", wtimeout: 5000}\n\n If the MongoDB configuration file (default location: /etc/mongod.conf) does not\n contain\n\n security: authorization: \\\"enabled\\\"\n\n Edit the MongoDB configuration file, add these parameters, stop/start (restart)\n any mongod or mongos process using this MongoDB configuration file.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000148-DB-000103'\n tag \"gid\": 'V-81863'\n tag \"rid\": 'SV-96577r1_rule'\n tag \"stig_id\": 'MD3X-00-000310'\n tag \"fix_id\": 'F-88713r1_fix'\n tag \"cci\": ['CCI-000764']\n tag \"nist\": ['IA-2']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to determine if a user is found not be a memer or an appropriate organization that can access the database.' do\n skip 'A manual review is required to determine if a user is found not be a memer or an appropriate organization that can access the database.'\n end\n\n describe yaml(input('mongod_conf')) do\n its(%w(security authorization)) { should cmp 'enabled' }\n end\nend\n","source_location":{"ref":"./controls/V-81863.rb","line":1},"id":"V-81863"},{"title":"MongoDB must provide non-privileged users with error messages that\n provide information necessary for corrective actions without revealing\n information that could be exploited by adversaries.","desc":"Any DBMS or associated application providing too much information in\n error messages on the screen or printout risks compromising the data and\n security of the system. The structure and content of error messages need to be\n carefully considered by the organization and development team.\n Databases can inadvertently provide a wealth of information to an attacker\n through improperly handled error messages. In addition to sensitive business or\n personal information, database errors can provide host names, IP addresses,\n user names, and other system information not required for troubleshooting but\n very useful to someone targeting the system.\n Carefully consider the structure/content of error messages. The extent to\n which information systems are able to identify and handle error conditions is\n guided by organizational policy and operational requirements. Information that\n could be exploited by adversaries includes, for example, logon attempts with\n passwords entered by mistake as the username, mission/business information that\n can be derived from (if not stated explicitly by) information recorded, and\n personal information, such as account numbers, social security numbers, and\n credit card numbers.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"Any DBMS or associated application providing too much information in\n error messages on the screen or printout risks compromising the data and\n security of the system. The structure and content of error messages need to be\n carefully considered by the organization and development team.\n Databases can inadvertently provide a wealth of information to an attacker\n through improperly handled error messages. In addition to sensitive business or\n personal information, database errors can provide host names, IP addresses,\n user names, and other system information not required for troubleshooting but\n very useful to someone targeting the system.\n Carefully consider the structure/content of error messages. The extent to\n which information systems are able to identify and handle error conditions is\n guided by organizational policy and operational requirements. Information that\n could be exploited by adversaries includes, for example, logon attempts with\n passwords entered by mistake as the username, mission/business information that\n can be derived from (if not stated explicitly by) information recorded, and\n personal information, such as account numbers, social security numbers, and\n credit card numbers.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"Check custom database code to verify that error messages do not\n contain information beyond what is needed for troubleshooting the issue.\n If custom database errors contain PII data, sensitive business data, or\n information useful for identifying the host system or database structure, this\n is a finding.\n When attempting to login with incorrect credentials, the user will receive an\n error message that the operation was unauthorized.\n If a user is attempting to perform an operation for which they do not have\n privileges, the database will return an error message that the operation is not\n authorized.","fix":"Configure custom database code and associated application code\n not to divulge sensitive information or information useful for system\n identification in error messages."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000266-DB-000162","gid":"V-81893","rid":"SV-96607r1_rule","stig_id":"MD3X-00-000520","fix_id":"F-88743r1_fix","cci":["CCI-001312"],"nist":["SI-11 a"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81893' do\n title \"MongoDB must provide non-privileged users with error messages that\n provide information necessary for corrective actions without revealing\n information that could be exploited by adversaries.\"\n desc \"Any DBMS or associated application providing too much information in\n error messages on the screen or printout risks compromising the data and\n security of the system. The structure and content of error messages need to be\n carefully considered by the organization and development team.\n Databases can inadvertently provide a wealth of information to an attacker\n through improperly handled error messages. In addition to sensitive business or\n personal information, database errors can provide host names, IP addresses,\n user names, and other system information not required for troubleshooting but\n very useful to someone targeting the system.\n Carefully consider the structure/content of error messages. The extent to\n which information systems are able to identify and handle error conditions is\n guided by organizational policy and operational requirements. Information that\n could be exploited by adversaries includes, for example, logon attempts with\n passwords entered by mistake as the username, mission/business information that\n can be derived from (if not stated explicitly by) information recorded, and\n personal information, such as account numbers, social security numbers, and\n credit card numbers.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"Check custom database code to verify that error messages do not\n contain information beyond what is needed for troubleshooting the issue.\n If custom database errors contain PII data, sensitive business data, or\n information useful for identifying the host system or database structure, this\n is a finding.\n When attempting to login with incorrect credentials, the user will receive an\n error message that the operation was unauthorized.\n If a user is attempting to perform an operation for which they do not have\n privileges, the database will return an error message that the operation is not\n authorized.\"\n desc 'fix', \"Configure custom database code and associated application code\n not to divulge sensitive information or information useful for system\n identification in error messages.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000266-DB-000162'\n tag \"gid\": 'V-81893'\n tag \"rid\": 'SV-96607r1_rule'\n tag \"stig_id\": 'MD3X-00-000520'\n tag \"fix_id\": 'F-88743r1_fix'\n tag \"cci\": ['CCI-001312']\n tag \"nist\": ['SI-11 a']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to check custom database code to verfiy that error messages do not contain information beyond what is needed for troubleshooting the issue.' do\n skip 'A manual review is required to check custom database code to verfiy that error messages do not contain information beyond what is needed for troubleshooting the issue.'\n end\nend\n","source_location":{"ref":"./controls/V-81893.rb","line":1},"id":"V-81893"},{"title":"MongoDB must provide a warning to appropriate support staff when\n allocated audit record storage volume reaches 75% of maximum audit record\n storage capacity.","desc":"Organizations are required to use a central log management system, so,\n under normal conditions, the audit space allocated to MongoDB on its own server\n will not be an issue. However, space will still be required on MongoDB server\n for audit records in transit, and, under abnormal conditions, this could fill\n up. Since a requirement exists to halt processing upon audit failure, a service\n outage would result.\n\n If support personnel are not notified immediately upon storage volume\n utilization reaching 75%, they are unable to plan for storage capacity\n expansion.\n\n The appropriate support staff include, at a minimum, the ISSO and the\n DBA/SA.","descriptions":{"default":"Organizations are required to use a central log management system, so,\n under normal conditions, the audit space allocated to MongoDB on its own server\n will not be an issue. However, space will still be required on MongoDB server\n for audit records in transit, and, under abnormal conditions, this could fill\n up. Since a requirement exists to halt processing upon audit failure, a service\n outage would result.\n\n If support personnel are not notified immediately upon storage volume\n utilization reaching 75%, they are unable to plan for storage capacity\n expansion.\n\n The appropriate support staff include, at a minimum, the ISSO and the\n DBA/SA.","check":"A MongoDB audit log that is configured to be stored in a file\n is identified in the MongoDB configuration file (default: /etc/mongod.conf)\n under the \"auditLog:\" key and subkey \"destination:\" where \"destination\"\n is \"file\".\n\n If this is the case then the \"AuditLog:\" subkey \"path:\" determines where\n (device/directory) that file will be located.\n\n View the mongodb configuration file (default location: /etc/mongod.conf) and\n identify how the \"auditlog.destination\" is configured.\n\n When the \"auditlog.destination\" is \"file\", this is a finding.","fix":"View the mongodb configuration file (default location:\n /etc/mongod.conf) and view the \"auditlog.path\" to identify the storage volume.\n\n Install MongoDB Ops Manager or other organization approved monitoring software.\n\n Configure the required alert in the monitoring software to send an alert where\n storage volume holding the auditLog file utilization reaches 75%."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000359-DB-000319","gid":"V-81907","rid":"SV-96621r1_rule","stig_id":"MD3X-00-000630","fix_id":"F-88757r2_fix","cci":["CCI-001855"],"nist":["AU-5 (1)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81907' do\n title \"MongoDB must provide a warning to appropriate support staff when\n allocated audit record storage volume reaches 75% of maximum audit record\n storage capacity.\"\n desc \"Organizations are required to use a central log management system, so,\n under normal conditions, the audit space allocated to MongoDB on its own server\n will not be an issue. However, space will still be required on MongoDB server\n for audit records in transit, and, under abnormal conditions, this could fill\n up. Since a requirement exists to halt processing upon audit failure, a service\n outage would result.\n\n If support personnel are not notified immediately upon storage volume\n utilization reaching 75%, they are unable to plan for storage capacity\n expansion.\n\n The appropriate support staff include, at a minimum, the ISSO and the\n DBA/SA.\n \"\n\n desc 'check', \"A MongoDB audit log that is configured to be stored in a file\n is identified in the MongoDB configuration file (default: /etc/mongod.conf)\n under the \\\"auditLog:\\\" key and subkey \\\"destination:\\\" where \\\"destination\\\"\n is \\\"file\\\".\n\n If this is the case then the \\\"AuditLog:\\\" subkey \\\"path:\\\" determines where\n (device/directory) that file will be located.\n\n View the mongodb configuration file (default location: /etc/mongod.conf) and\n identify how the \\\"auditlog.destination\\\" is configured.\n\n When the \\\"auditlog.destination\\\" is \\\"file\\\", this is a finding.\"\n desc 'fix', \"View the mongodb configuration file (default location:\n /etc/mongod.conf) and view the \\\"auditlog.path\\\" to identify the storage volume.\n\n Install MongoDB Ops Manager or other organization approved monitoring software.\n\n Configure the required alert in the monitoring software to send an alert where\n storage volume holding the auditLog file utilization reaches 75%.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000359-DB-000319'\n tag \"gid\": 'V-81907'\n tag \"rid\": 'SV-96621r1_rule'\n tag \"stig_id\": 'MD3X-00-000630'\n tag \"fix_id\": 'F-88757r2_fix'\n tag \"cci\": ['CCI-001855']\n tag \"nist\": ['AU-5 (1)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog destination)) { should_not cmp 'file' }\n its(%w(auditLog destination)) { should_not be_nil }\n end\nend\n","source_location":{"ref":"./controls/V-81907.rb","line":1},"id":"V-81907"},{"title":"Database software, including DBMS configuration files, must be stored\n in dedicated directories, or DASD pools, separate from the host OS and other\n applications.","desc":"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can potentially have significant effects\n on the overall security of the system.\n Multiple applications can provide a cumulative negative effect. A\n vulnerability and subsequent exploit to one application can lead to an exploit\n of other applications sharing the same security context. For example, an\n exploit to a web server process that leads to unauthorized administrative\n access to host system directories can most likely lead to a compromise of all\n applications hosted by the same system. Database software not installed using\n dedicated directories both threatens and is threatened by other hosted\n applications. Access controls defined for one application may by default\n provide access to the other application's database objects or directories. Any\n method that provides any level of separation of security context assists in the\n protection between applications.","descriptions":{"default":"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can potentially have significant effects\n on the overall security of the system.\n Multiple applications can provide a cumulative negative effect. A\n vulnerability and subsequent exploit to one application can lead to an exploit\n of other applications sharing the same security context. For example, an\n exploit to a web server process that leads to unauthorized administrative\n access to host system directories can most likely lead to a compromise of all\n applications hosted by the same system. Database software not installed using\n dedicated directories both threatens and is threatened by other hosted\n applications. Access controls defined for one application may by default\n provide access to the other application's database objects or directories. Any\n method that provides any level of separation of security context assists in the\n protection between applications.","check":"Review the MongoDB software library directory and note other\n root directories located on the same disk directory or any subdirectories.\n If any non-MongoDB software directories exist on the disk directory, examine or\n investigate their use. If any of the directories are used by other\n applications, including third-party applications that use the MongoDB this is a\n finding.\n Only applications that are required for the functioning and administration, not\n use, of the MongoDB should be located in the same disk directory as the MongoDB\n software libraries.\n If other applications are located in the same directory as the MongoDB database\n this is a finding.","fix":"Install all applications on directories separate from the MongoDB\n software library directory. Relocate any directories or reinstall other\n application software that currently shares the MongoDB software library\n directory."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000133-DB-000199","gid":"V-81855","rid":"SV-96569r1_rule","stig_id":"MD3X-00-000260","fix_id":"F-88705r1_fix","cci":["CCI-001499"],"nist":["CM-5 (6)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81855' do\n title \"Database software, including DBMS configuration files, must be stored\n in dedicated directories, or DASD pools, separate from the host OS and other\n applications.\"\n desc \"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can potentially have significant effects\n on the overall security of the system.\n Multiple applications can provide a cumulative negative effect. A\n vulnerability and subsequent exploit to one application can lead to an exploit\n of other applications sharing the same security context. For example, an\n exploit to a web server process that leads to unauthorized administrative\n access to host system directories can most likely lead to a compromise of all\n applications hosted by the same system. Database software not installed using\n dedicated directories both threatens and is threatened by other hosted\n applications. Access controls defined for one application may by default\n provide access to the other application's database objects or directories. Any\n method that provides any level of separation of security context assists in the\n protection between applications.\n \"\n\n desc 'check', \"Review the MongoDB software library directory and note other\n root directories located on the same disk directory or any subdirectories.\n If any non-MongoDB software directories exist on the disk directory, examine or\n investigate their use. If any of the directories are used by other\n applications, including third-party applications that use the MongoDB this is a\n finding.\n Only applications that are required for the functioning and administration, not\n use, of the MongoDB should be located in the same disk directory as the MongoDB\n software libraries.\n If other applications are located in the same directory as the MongoDB database\n this is a finding.\"\n desc 'fix', \"Install all applications on directories separate from the MongoDB\n software library directory. Relocate any directories or reinstall other\n application software that currently shares the MongoDB software library\n directory.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000133-DB-000199'\n tag \"gid\": 'V-81855'\n tag \"rid\": 'SV-96569r1_rule'\n tag \"stig_id\": 'MD3X-00-000260'\n tag \"fix_id\": 'F-88705r1_fix'\n tag \"cci\": ['CCI-001499']\n tag \"nist\": ['CM-5 (6)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n if virtualization.system.eql?('docker')\n impact 0.0\n desc 'caveat', 'This is Not Applicable since the MongoDB is installed within a Docker container so it is separate from the host OS'\n else\n describe \"This test requires a Manual Review: Ensure all database software,\n including DBMS configuration files, is stored in dedicated directories, or\n DASD pools, separate from the host OS and other applications.\" do\n skip \"This test requires a Manual Review: Ensure all database software,\n including DBMS configuration files, is stored in dedicated directories, or\n DASD pools, separate from the host OS and other applications.\"\n end\n end\nend\n","source_location":{"ref":"./controls/V-81855.rb","line":1},"id":"V-81855"},{"title":"MongoDB must prohibit user installation of logic modules (stored\n procedures, functions, triggers, views, etc.) without explicit privileged\n status.","desc":"Allowing regular users to install software, without explicit\n privileges, creates the risk that untested or potentially malicious software\n will be installed on the system. Explicit privileges (escalated or\n administrative privileges) provide the regular user with explicit capabilities\n and control that exceed the rights of a regular user.\n\n DBMS functionality and the nature and requirements of databases will vary;\n so while users are not permitted to install unapproved software, there may be\n instances where the organization allows the user to install approved software\n packages such as from an approved software repository. The requirements for\n production servers will be more restrictive than those used for development and\n research.\n\n MongoDB must enforce software installation by users based upon what types\n of software installations are permitted (e.g., updates and security patches to\n existing software) and what types of installations are prohibited (e.g.,\n software whose pedigree with regard to being potentially malicious is unknown\n or suspect) by the organization).\n\n In the case of a database management system, this requirement covers stored\n procedures, functions, triggers, views, etc.","descriptions":{"default":"Allowing regular users to install software, without explicit\n privileges, creates the risk that untested or potentially malicious software\n will be installed on the system. Explicit privileges (escalated or\n administrative privileges) provide the regular user with explicit capabilities\n and control that exceed the rights of a regular user.\n\n DBMS functionality and the nature and requirements of databases will vary;\n so while users are not permitted to install unapproved software, there may be\n instances where the organization allows the user to install approved software\n packages such as from an approved software repository. The requirements for\n production servers will be more restrictive than those used for development and\n research.\n\n MongoDB must enforce software installation by users based upon what types\n of software installations are permitted (e.g., updates and security patches to\n existing software) and what types of installations are prohibited (e.g.,\n software whose pedigree with regard to being potentially malicious is unknown\n or suspect) by the organization).\n\n In the case of a database management system, this requirement covers stored\n procedures, functions, triggers, views, etc.","check":"If MongoDB supports only software development, experimentation,\n and/or developer-level testing (that is, excluding production systems,\n integration testing, stress testing, and user acceptance testing), this is not\n a finding.\n\n Review the MongoDB security settings with respect to non-administrative users'\n ability to create, alter, or replace functions or views.\n\n These MongoDB commands can help with showing existing roles and permissions of\n users of the databases.\n\n db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })\n\n If any such permissions exist and are not documented and approved, this is a\n finding.","fix":"Revoke any roles with unnecessary privileges to privileged\n functionality by executing the revoke command.\n\n Revoke any unnecessary privileges from any roles by executing the revoke\n command.\n\n Create, as needed, new role(s) with associated privileges."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000378-DB-000365","gid":"V-81909","rid":"SV-96623r1_rule","stig_id":"MD3X-00-000650","fix_id":"F-88759r1_fix","cci":["CCI-001812"],"nist":["CM-11 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81909' do\n title \"MongoDB must prohibit user installation of logic modules (stored\n procedures, functions, triggers, views, etc.) without explicit privileged\n status.\"\n desc \"Allowing regular users to install software, without explicit\n privileges, creates the risk that untested or potentially malicious software\n will be installed on the system. Explicit privileges (escalated or\n administrative privileges) provide the regular user with explicit capabilities\n and control that exceed the rights of a regular user.\n\n DBMS functionality and the nature and requirements of databases will vary;\n so while users are not permitted to install unapproved software, there may be\n instances where the organization allows the user to install approved software\n packages such as from an approved software repository. The requirements for\n production servers will be more restrictive than those used for development and\n research.\n\n MongoDB must enforce software installation by users based upon what types\n of software installations are permitted (e.g., updates and security patches to\n existing software) and what types of installations are prohibited (e.g.,\n software whose pedigree with regard to being potentially malicious is unknown\n or suspect) by the organization).\n\n In the case of a database management system, this requirement covers stored\n procedures, functions, triggers, views, etc.\n \"\n\n desc 'check', \"If MongoDB supports only software development, experimentation,\n and/or developer-level testing (that is, excluding production systems,\n integration testing, stress testing, and user acceptance testing), this is not\n a finding.\n\n Review the MongoDB security settings with respect to non-administrative users'\n ability to create, alter, or replace functions or views.\n\n These MongoDB commands can help with showing existing roles and permissions of\n users of the databases.\n\n db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })\n\n If any such permissions exist and are not documented and approved, this is a\n finding.\"\n desc 'fix', \"Revoke any roles with unnecessary privileges to privileged\n functionality by executing the revoke command.\n\n Revoke any unnecessary privileges from any roles by executing the revoke\n command.\n\n Create, as needed, new role(s) with associated privileges.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000378-DB-000365'\n tag \"gid\": 'V-81909'\n tag \"rid\": 'SV-96623r1_rule'\n tag \"stig_id\": 'MD3X-00-000650'\n tag \"fix_id\": 'F-88759r1_fix'\n tag \"cci\": ['CCI-001812']\n tag \"nist\": ['CM-11 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getRoles({rolesInfo: 1,showPrivileges:true,showBuiltinRoles: true})\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Manually verify privileges for Role: `#{entry['role']}` within Database: `#{db}`\n Privileges: #{entry['privileges']}\" do\n skip\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81909.rb","line":1},"id":"V-81909"},{"title":"If DBMS authentication, using passwords, is employed, MongoDB must\n enforce the DoD standards for password complexity and lifetime.","desc":"OS/enterprise authentication and identification must be used\n (SQL2-00-023600). Native DBMS authentication may be used only when\n circumstances make it unavoidable; and must be documented and AO-approved.\n\n The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is not\n possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, the DoD standards for password complexity and lifetime must\n be implemented. DBMS products that can inherit the rules for these from the\n operating system or access control program (e.g., Microsoft Active Directory)\n must be configured to do so. For other DBMSs, the rules must be enforced using\n available configuration parameters or custom code.","descriptions":{"default":"OS/enterprise authentication and identification must be used\n (SQL2-00-023600). Native DBMS authentication may be used only when\n circumstances make it unavoidable; and must be documented and AO-approved.\n\n The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is not\n possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, the DoD standards for password complexity and lifetime must\n be implemented. DBMS products that can inherit the rules for these from the\n operating system or access control program (e.g., Microsoft Active Directory)\n must be configured to do so. For other DBMSs, the rules must be enforced using\n available configuration parameters or custom code.","check":"If MongoDB is using Native LDAP authentication where the LDAP\n server is configured to enforce password complexity and lifetime, this is not a\n finding.\n\n If MongoDB is using Kerberos authentication where Kerberos is configured to\n enforce password complexity and lifetime, this is not a finding.\n\n If MongoDB is configured for SCRAM-SHA1, MONGODB-CR, LDAP Proxy authentication,\n this is a finding.\n\n See: https://docs.mongodb.com/v3.4/core/authentication/#authentication-methods","fix":"Either configure MongoDB for Native LDAP authentication where\n LDAP is configured to enforce password complexity and lifetime.\n OR\n Configure MongoDB Kerberos authentication where Kerberos is configured to\n enforce password complexity and lifetime."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000164-DB-000401","gid":"V-81865","rid":"SV-96579r1_rule","stig_id":"MD3X-00-000320","fix_id":"F-88715r1_fix","cci":["CCI-000192"],"nist":["IA-5 (1) (a)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81865' do\n title \"If DBMS authentication, using passwords, is employed, MongoDB must\n enforce the DoD standards for password complexity and lifetime.\"\n desc \"OS/enterprise authentication and identification must be used\n (SQL2-00-023600). Native DBMS authentication may be used only when\n circumstances make it unavoidable; and must be documented and AO-approved.\n\n The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is not\n possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, the DoD standards for password complexity and lifetime must\n be implemented. DBMS products that can inherit the rules for these from the\n operating system or access control program (e.g., Microsoft Active Directory)\n must be configured to do so. For other DBMSs, the rules must be enforced using\n available configuration parameters or custom code.\n \"\n\n desc 'check', \"If MongoDB is using Native LDAP authentication where the LDAP\n server is configured to enforce password complexity and lifetime, this is not a\n finding.\n\n If MongoDB is using Kerberos authentication where Kerberos is configured to\n enforce password complexity and lifetime, this is not a finding.\n\n If MongoDB is configured for SCRAM-SHA1, MONGODB-CR, LDAP Proxy authentication,\n this is a finding.\n\n See: https://docs.mongodb.com/v3.4/core/authentication/#authentication-methods\"\n desc 'fix', \"Either configure MongoDB for Native LDAP authentication where\n LDAP is configured to enforce password complexity and lifetime.\n OR\n Configure MongoDB Kerberos authentication where Kerberos is configured to\n enforce password complexity and lifetime.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000164-DB-000401'\n tag \"gid\": 'V-81865'\n tag \"rid\": 'SV-96579r1_rule'\n tag \"stig_id\": 'MD3X-00-000320'\n tag \"fix_id\": 'F-88715r1_fix'\n tag \"cci\": ['CCI-000192']\n tag \"nist\": ['IA-5 (1) (a)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'MongoDB Server should be configured with a non-default authentication Mechanism' do\n subject { processes('mongod') }\n its('commands.join') { should match /authenticationMechanisms/ }\n end\n\n describe 'MongoDB Server authentication Mechanism' do\n subject { processes('mongod').commands.join }\n it { should_not match /SCRAM-SHA1|MONGODB-CR|PLAIN/ }\n end\nend\n","source_location":{"ref":"./controls/V-81865.rb","line":1},"id":"V-81865"},{"title":"If passwords are used for authentication, MongoDB must store only\n hashed, salted representations of passwords.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n In such cases, database passwords stored in clear text, using reversible\n encryption, or using unsalted hashes would be vulnerable to unauthorized\n disclosure. Database passwords must always be in the form of one-way, salted\n hashes when stored internally or externally to MongoDB.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n In such cases, database passwords stored in clear text, using reversible\n encryption, or using unsalted hashes would be vulnerable to unauthorized\n disclosure. Database passwords must always be in the form of one-way, salted\n hashes when stored internally or externally to MongoDB.","check":"MongoDB supports x.509 certificate authentication for use with\n a secure TLS/SSL connection.\n\n The x.509 client authentication allows clients to authenticate to servers with\n certificates rather than with a username and password.\n\n If X.509 authentication is not used, a SCRAM-SHA-1 authentication protocol is\n also available. The SCRAM-SHA-1 protocol uses one-way, salted hash functions\n for passwords as documented here:\n https://docs.mongodb.com/v3.4/core/security-scram-sha-1/\n\n To authenticate with a client certificate, you must first add a MongoDB user\n that corresponds to the client certificate. See Add x.509 Certificate subject\n as a User as documented here:\n https://docs.mongodb.com/v3.4/tutorial/configure-x509-client-authentication/\n\n To authenticate, use the db.auth() method in the $external database, specifying\n \"MONGODB-X509\" for the mechanism field, and the user that corresponds to the\n client certificate for the user field.\n\n If the mechanism field is not set to \"MONGODB-X509\", this is a finding.","fix":"Do the following:\n - Create local CA and signing keys.\n - Generate and sign server certificates for member authentication.\n - Generate and sign client certificates for client authentication.\n - Start MongoDB cluster in non-auth mode.\n - Set up replica set and initial users.\n - Restart MongoDB replica set in X.509 mode using server certificates.\n\n Example shown here for x.509 Authentication:\n https://www.mongodb.com/blog/post/secure-mongodb-with-x-509-authentication\n\n Additionally, SSL/TLS must be on as documented here:\n https://docs.mongodb.com/v3.4/tutorial/configure-ssl/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000171-DB-000074","gid":"V-81867","rid":"SV-96581r1_rule","stig_id":"MD3X-00-000330","fix_id":"F-88717r1_fix","cci":["CCI-000196"],"nist":["IA-5 (1) (c)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81867' do\n title \"If passwords are used for authentication, MongoDB must store only\n hashed, salted representations of passwords.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n In such cases, database passwords stored in clear text, using reversible\n encryption, or using unsalted hashes would be vulnerable to unauthorized\n disclosure. Database passwords must always be in the form of one-way, salted\n hashes when stored internally or externally to MongoDB.\n \"\n\n desc 'check', \"MongoDB supports x.509 certificate authentication for use with\n a secure TLS/SSL connection.\n\n The x.509 client authentication allows clients to authenticate to servers with\n certificates rather than with a username and password.\n\n If X.509 authentication is not used, a SCRAM-SHA-1 authentication protocol is\n also available. The SCRAM-SHA-1 protocol uses one-way, salted hash functions\n for passwords as documented here:\n https://docs.mongodb.com/v3.4/core/security-scram-sha-1/\n\n To authenticate with a client certificate, you must first add a MongoDB user\n that corresponds to the client certificate. See Add x.509 Certificate subject\n as a User as documented here:\n https://docs.mongodb.com/v3.4/tutorial/configure-x509-client-authentication/\n\n To authenticate, use the db.auth() method in the $external database, specifying\n \\\"MONGODB-X509\\\" for the mechanism field, and the user that corresponds to the\n client certificate for the user field.\n\n If the mechanism field is not set to \\\"MONGODB-X509\\\", this is a finding.\"\n desc 'fix', \"Do the following:\n - Create local CA and signing keys.\n - Generate and sign server certificates for member authentication.\n - Generate and sign client certificates for client authentication.\n - Start MongoDB cluster in non-auth mode.\n - Set up replica set and initial users.\n - Restart MongoDB replica set in X.509 mode using server certificates.\n\n Example shown here for x.509 Authentication:\n https://www.mongodb.com/blog/post/secure-mongodb-with-x-509-authentication\n\n Additionally, SSL/TLS must be on as documented here:\n https://docs.mongodb.com/v3.4/tutorial/configure-ssl/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000171-DB-000074'\n tag \"gid\": 'V-81867'\n tag \"rid\": 'SV-96581r1_rule'\n tag \"stig_id\": 'MD3X-00-000330'\n tag \"fix_id\": 'F-88717r1_fix'\n tag \"cci\": ['CCI-000196']\n tag \"nist\": ['IA-5 (1) (c)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security authorization)) { should cmp 'enabled' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(security clusterAuthMode)) { should cmp 'x509' }\n end\nend\n","source_location":{"ref":"./controls/V-81867.rb","line":1},"id":"V-81867"},{"title":"MongoDB and associated applications must reserve the use of dynamic\n code execution for situations that require it.","desc":"With respect to database management systems, one class of threat is\n known as SQL Injection, or more generally, code injection. It takes advantage\n of the dynamic execution capabilities of various programming languages,\n including dialects of SQL. In such cases, the attacker deduces the manner in\n which SQL statements are being processed, either from inside knowledge or by\n observing system behavior in response to invalid inputs. When the attacker\n identifies scenarios where SQL queries are being assembled by application code\n (which may be within the database or separate from it) and executed\n dynamically, the attacker is then able to craft input strings that subvert the\n intent of the query. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n The principal protection against code injection is not to use dynamic\n execution except where it provides necessary functionality that cannot be\n utilized otherwise. Use strongly typed data items rather than general-purpose\n strings as input parameters to task-specific, pre-compiled stored procedures\n and functions (and triggers).\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"With respect to database management systems, one class of threat is\n known as SQL Injection, or more generally, code injection. It takes advantage\n of the dynamic execution capabilities of various programming languages,\n including dialects of SQL. In such cases, the attacker deduces the manner in\n which SQL statements are being processed, either from inside knowledge or by\n observing system behavior in response to invalid inputs. When the attacker\n identifies scenarios where SQL queries are being assembled by application code\n (which may be within the database or separate from it) and executed\n dynamically, the attacker is then able to craft input strings that subvert the\n intent of the query. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n The principal protection against code injection is not to use dynamic\n execution except where it provides necessary functionality that cannot be\n utilized otherwise. Use strongly typed data items rather than general-purpose\n strings as input parameters to task-specific, pre-compiled stored procedures\n and functions (and triggers).\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"MongoDB operations permit arbitrary JavaScript expressions to\n be run directly on the server.\n\n If the following parameter is not present or not set as show below in the\n MongoDB configuration file (default location: /etc/mongod.conf), this is a\n finding.\n\n security:\n javascriptEnabled: \"false\"","fix":"Disable the \"javascriptEnabled\" option.\n\n Edit the MongoDB configuration file (default location: /etc/mongod.conf\" to\n include the following:\n\n security:\n javascriptEnabled: false"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000251-DB-000391","satisfies":["SRG-APP-000251-DB-000391","SRG-APP-000251-DB-000392"],"gid":"V-81891","rid":"SV-96605r1_rule","stig_id":"MD3X-00-000500","fix_id":"F-88741r1_fix","cci":["CCI-001310"],"nist":["SI-10"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81891' do\n title \"MongoDB and associated applications must reserve the use of dynamic\n code execution for situations that require it.\"\n desc \"With respect to database management systems, one class of threat is\n known as SQL Injection, or more generally, code injection. It takes advantage\n of the dynamic execution capabilities of various programming languages,\n including dialects of SQL. In such cases, the attacker deduces the manner in\n which SQL statements are being processed, either from inside knowledge or by\n observing system behavior in response to invalid inputs. When the attacker\n identifies scenarios where SQL queries are being assembled by application code\n (which may be within the database or separate from it) and executed\n dynamically, the attacker is then able to craft input strings that subvert the\n intent of the query. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n The principal protection against code injection is not to use dynamic\n execution except where it provides necessary functionality that cannot be\n utilized otherwise. Use strongly typed data items rather than general-purpose\n strings as input parameters to task-specific, pre-compiled stored procedures\n and functions (and triggers).\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"MongoDB operations permit arbitrary JavaScript expressions to\n be run directly on the server.\n\n If the following parameter is not present or not set as show below in the\n MongoDB configuration file (default location: /etc/mongod.conf), this is a\n finding.\n\n security:\n javascriptEnabled: \\\"false\\\"\"\n desc 'fix', \"Disable the \\\"javascriptEnabled\\\" option.\n\n Edit the MongoDB configuration file (default location: /etc/mongod.conf\\\" to\n include the following:\n\n security:\n javascriptEnabled: false\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000251-DB-000391'\n tag \"satisfies\": %w(SRG-APP-000251-DB-000391 SRG-APP-000251-DB-000392)\n tag \"gid\": 'V-81891'\n tag \"rid\": 'SV-96605r1_rule'\n tag \"stig_id\": 'MD3X-00-000500'\n tag \"fix_id\": 'F-88741r1_fix'\n tag \"cci\": ['CCI-001310']\n tag \"nist\": ['SI-10']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security javascriptEnabled)) { should cmp 'false' }\n end\nend\n","source_location":{"ref":"./controls/V-81891.rb","line":1},"id":"V-81891"},{"title":"MongoDB must be configured in accordance with the security\n configuration settings based on DoD security configuration and implementation\n guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.","desc":"Configuring MongoDB to implement organization-wide security\n implementation guides and security checklists ensures compliance with federal\n standards and establishes a common security baseline across DoD that reflects\n the most restrictive security posture consistent with operational requirements.\n\n In addition to this SRG, sources of guidance on security and information\n assurance exist. These include NSA configuration guides, CTOs, DTMs, and IAVMs.\n MongoDB must be configured in compliance with guidance from all such relevant\n sources.","descriptions":{"default":"Configuring MongoDB to implement organization-wide security\n implementation guides and security checklists ensures compliance with federal\n standards and establishes a common security baseline across DoD that reflects\n the most restrictive security posture consistent with operational requirements.\n\n In addition to this SRG, sources of guidance on security and information\n assurance exist. These include NSA configuration guides, CTOs, DTMs, and IAVMs.\n MongoDB must be configured in compliance with guidance from all such relevant\n sources.","check":"Review the MongoDB documentation and configuration to determine\n it is configured in accordance with DoD security configuration and\n implementation guidance, including STIGs, NSA configuration guides, CTOs, DTMs,\n and IAVMs.\n\n If the MongoDB is not configured in accordance with security configuration\n settings, this is a finding.","fix":"Configure MongoDB in accordance with security configuration\n settings by reviewing the Operation System and MongoDB documentation and\n applying the necessary configuration parameters to meet the configurations\n required by the STIG, NSA configuration guidelines, CTOs, DTMs, and IAVMs."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000516-DB-000363","gid":"V-81929","rid":"SV-96643r1_rule","stig_id":"MD3X-00-001100","fix_id":"F-88779r1_fix","cci":["CCI-000366"],"nist":["CM-6 b"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81929' do\n title \"MongoDB must be configured in accordance with the security\n configuration settings based on DoD security configuration and implementation\n guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.\"\n desc \"Configuring MongoDB to implement organization-wide security\n implementation guides and security checklists ensures compliance with federal\n standards and establishes a common security baseline across DoD that reflects\n the most restrictive security posture consistent with operational requirements.\n\n In addition to this SRG, sources of guidance on security and information\n assurance exist. These include NSA configuration guides, CTOs, DTMs, and IAVMs.\n MongoDB must be configured in compliance with guidance from all such relevant\n sources.\n \"\n\n desc 'check', \"Review the MongoDB documentation and configuration to determine\n it is configured in accordance with DoD security configuration and\n implementation guidance, including STIGs, NSA configuration guides, CTOs, DTMs,\n and IAVMs.\n\n If the MongoDB is not configured in accordance with security configuration\n settings, this is a finding.\"\n desc 'fix', \"Configure MongoDB in accordance with security configuration\n settings by reviewing the Operation System and MongoDB documentation and\n applying the necessary configuration parameters to meet the configurations\n required by the STIG, NSA configuration guidelines, CTOs, DTMs, and IAVMs.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000516-DB-000363'\n tag \"gid\": 'V-81929'\n tag \"rid\": 'SV-96643r1_rule'\n tag \"stig_id\": 'MD3X-00-001100'\n tag \"fix_id\": 'F-88779r1_fix'\n tag \"cci\": ['CCI-000366']\n tag \"nist\": ['CM-6 b']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure that MongoDB is configured in accordance with the security\n configuration settings based on DoD security configuration and implementation\n guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.' do\n skip 'A manual review is required to ensure that MongoDB is configured in accordance with the security\n configuration settings based on DoD security configuration and implementation\n guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.'\n end\nend\n","source_location":{"ref":"./controls/V-81929.rb","line":1},"id":"V-81929"},{"title":"MongoDB must maintain the confidentiality and integrity of information\n during reception.","desc":"Information can be either unintentionally or maliciously disclosed or\n modified during reception, including, for example, during aggregation, at\n protocol transformation points, and during packing/unpacking. These\n unauthorized disclosures or modifications compromise the confidentiality or\n integrity of the information.\n\n This requirement applies only to those applications that are either\n distributed or can allow access to data nonlocally. Use of this requirement\n will be limited to situations where the data owner has a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process.\n\n When receiving data, MongoDB, associated applications, and infrastructure\n must leverage protection mechanisms.","descriptions":{"default":"Information can be either unintentionally or maliciously disclosed or\n modified during reception, including, for example, during aggregation, at\n protocol transformation points, and during packing/unpacking. These\n unauthorized disclosures or modifications compromise the confidentiality or\n integrity of the information.\n\n This requirement applies only to those applications that are either\n distributed or can allow access to data nonlocally. Use of this requirement\n will be limited to situations where the data owner has a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process.\n\n When receiving data, MongoDB, associated applications, and infrastructure\n must leverage protection mechanisms.","check":"If the data owner does not have a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process, this is not a finding.\n\n If such strict requirement for ensure data integrity and confidentially is\n present, inspect the MongoDB configuration file (default location:\n /etc/mongod.conf) for the following entries:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n If net.ssl.mode is not set to \"requireSSL\", this is a finding.","fix":"Obtain a certificate from a valid DoD certificate authority to be\n used for encrypted data transmission.\n\n Modify the MongoDB configuration file (default location: /etc/mongod.conf) with\n the network configuration options.\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n Set \"net.ssl.mode\" to the \"requireSSL\".\n Set \"net.ssl.KeyFile\" to the full path of the certificate (.pem) file.\n\n Start/stop (restart) all mongod or mongos instances using the MongoDB\n configuration file (default location: /etc/mongod.conf)."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000442-DB-000379","gid":"V-81923","rid":"SV-96637r1_rule","stig_id":"MD3X-00-000770","fix_id":"F-88773r2_fix","cci":["CCI-002422"],"nist":["SC-8 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81923' do\n title \"MongoDB must maintain the confidentiality and integrity of information\n during reception.\"\n desc \"Information can be either unintentionally or maliciously disclosed or\n modified during reception, including, for example, during aggregation, at\n protocol transformation points, and during packing/unpacking. These\n unauthorized disclosures or modifications compromise the confidentiality or\n integrity of the information.\n\n This requirement applies only to those applications that are either\n distributed or can allow access to data nonlocally. Use of this requirement\n will be limited to situations where the data owner has a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process.\n\n When receiving data, MongoDB, associated applications, and infrastructure\n must leverage protection mechanisms.\n \"\n\n desc 'check', \"If the data owner does not have a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process, this is not a finding.\n\n If such strict requirement for ensure data integrity and confidentially is\n present, inspect the MongoDB configuration file (default location:\n /etc/mongod.conf) for the following entries:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n If net.ssl.mode is not set to \\\"requireSSL\\\", this is a finding.\"\n desc 'fix', \"Obtain a certificate from a valid DoD certificate authority to be\n used for encrypted data transmission.\n\n Modify the MongoDB configuration file (default location: /etc/mongod.conf) with\n the network configuration options.\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n Set \\\"net.ssl.mode\\\" to the \\\"requireSSL\\\".\n Set \\\"net.ssl.KeyFile\\\" to the full path of the certificate (.pem) file.\n\n Start/stop (restart) all mongod or mongos instances using the MongoDB\n configuration file (default location: /etc/mongod.conf).\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000442-DB-000379'\n tag \"gid\": 'V-81923'\n tag \"rid\": 'SV-96637r1_rule'\n tag \"stig_id\": 'MD3X-00-000770'\n tag \"fix_id\": 'F-88773r2_fix'\n tag \"cci\": ['CCI-002422']\n tag \"nist\": ['SC-8 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl mode)) { should cmp 'requireSSL' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl PEMKeyFile)) { should_not be nil }\n end\nend\n","source_location":{"ref":"./controls/V-81923.rb","line":1},"id":"V-81923"},{"title":"MongoDB must enforce authorized access to all PKI private keys\n stored/utilized by MongoDB.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n PKI certificate-based authentication is performed by requiring the certificate\n holder to cryptographically prove possession of the corresponding private key.\n If the private key is stolen, an attacker can use the private key(s) to\n impersonate the certificate holder. In cases where MongoDB-stored private keys\n are used to authenticate MongoDB to the system’s clients, loss of the\n corresponding private keys would allow an attacker to successfully perform\n undetected man in the middle attacks against MongoDB system and its clients.\n Both the holder of a digital certificate and the issuing authority must\n take careful measures to protect the corresponding private key. Private keys\n should always be generated and protected in FIPS 140-2 validated cryptographic\n modules.\n All access to the private key(s) of MongoDB must be restricted to\n authorized and authenticated users. If unauthorized users have access to one or\n more of MongoDB's private keys, an attacker could gain access to the key(s) and\n use them to impersonate the database on the network or otherwise perform\n unauthorized actions.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n PKI certificate-based authentication is performed by requiring the certificate\n holder to cryptographically prove possession of the corresponding private key.\n If the private key is stolen, an attacker can use the private key(s) to\n impersonate the certificate holder. In cases where MongoDB-stored private keys\n are used to authenticate MongoDB to the system’s clients, loss of the\n corresponding private keys would allow an attacker to successfully perform\n undetected man in the middle attacks against MongoDB system and its clients.\n Both the holder of a digital certificate and the issuing authority must\n take careful measures to protect the corresponding private key. Private keys\n should always be generated and protected in FIPS 140-2 validated cryptographic\n modules.\n All access to the private key(s) of MongoDB must be restricted to\n authorized and authenticated users. If unauthorized users have access to one or\n more of MongoDB's private keys, an attacker could gain access to the key(s) and\n use them to impersonate the database on the network or otherwise perform\n unauthorized actions.","check":"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), review the following parameters:\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n CAFile: /etc/ssl/mongodbca.pem\n Verify ownership, group ownership, and permissions on the file given for\n PEMKeyFile (default 'mongodb.pem').\n Run following command and review its output:\n ls -al /etc/mongod.conf\n typical output:\n -rw------- 1 mongod mongod 566 Apr 26 20:20 /etc/mongod.conf\n If the user owner is not \"mongod\", this is a finding.\n If the group owner is not \"mongod\", this is a finding.\n If the file is more permissive than \"600\", this is a finding.\n Verify ownership, group ownership, and permissions on the file given for CAFile\n (default 'ca.pem').\n If the user owner is not \"mongod\", this is a finding.\n If the group owner is not \"mongod\", this is a finding.\n IF the file is more permissive than \"600\", this is a finding.","fix":"Run these commands:\n \"chown mongod:mongod /etc/ssl/mongodb.pem\"\n \"chmod 600 /etc/ssl/mongodb.pem\"\n \"chown mongod:mongod /etc/ssl/mongodbca.pem\"\n \"chmod 600 /etc/ssl/mongodbca.pem\""},"impact":0.7,"refs":[],"tags":{"severity":"high","gtitle":"SRG-APP-000176-DB-000068","gid":"V-81871","rid":"SV-96585r1_rule","stig_id":"MD3X-00-000360","fix_id":"F-88721r1_fix","cci":["CCI-000186"],"nist":["IA-5 (2) (b)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81871' do\n title \"MongoDB must enforce authorized access to all PKI private keys\n stored/utilized by MongoDB.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n PKI certificate-based authentication is performed by requiring the certificate\n holder to cryptographically prove possession of the corresponding private key.\n If the private key is stolen, an attacker can use the private key(s) to\n impersonate the certificate holder. In cases where MongoDB-stored private keys\n are used to authenticate MongoDB to the system’s clients, loss of the\n corresponding private keys would allow an attacker to successfully perform\n undetected man in the middle attacks against MongoDB system and its clients.\n Both the holder of a digital certificate and the issuing authority must\n take careful measures to protect the corresponding private key. Private keys\n should always be generated and protected in FIPS 140-2 validated cryptographic\n modules.\n All access to the private key(s) of MongoDB must be restricted to\n authorized and authenticated users. If unauthorized users have access to one or\n more of MongoDB's private keys, an attacker could gain access to the key(s) and\n use them to impersonate the database on the network or otherwise perform\n unauthorized actions.\n \"\n\n desc 'check', \"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), review the following parameters:\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n CAFile: /etc/ssl/mongodbca.pem\n Verify ownership, group ownership, and permissions on the file given for\n PEMKeyFile (default 'mongodb.pem').\n Run following command and review its output:\n ls -al /etc/mongod.conf\n typical output:\n -rw------- 1 mongod mongod 566 Apr 26 20:20 /etc/mongod.conf\n If the user owner is not \\\"mongod\\\", this is a finding.\n If the group owner is not \\\"mongod\\\", this is a finding.\n If the file is more permissive than \\\"600\\\", this is a finding.\n Verify ownership, group ownership, and permissions on the file given for CAFile\n (default 'ca.pem').\n If the user owner is not \\\"mongod\\\", this is a finding.\n If the group owner is not \\\"mongod\\\", this is a finding.\n IF the file is more permissive than \\\"600\\\", this is a finding.\"\n desc 'fix', \"Run these commands:\n \\\"chown mongod:mongod /etc/ssl/mongodb.pem\\\"\n \\\"chmod 600 /etc/ssl/mongodb.pem\\\"\n \\\"chown mongod:mongod /etc/ssl/mongodbca.pem\\\"\n \\\"chmod 600 /etc/ssl/mongodbca.pem\\\"\"\n\n impact 0.7\n tag \"severity\": 'high'\n tag \"gtitle\": 'SRG-APP-000176-DB-000068'\n tag \"gid\": 'V-81871'\n tag \"rid\": 'SV-96585r1_rule'\n tag \"stig_id\": 'MD3X-00-000360'\n tag \"fix_id\": 'F-88721r1_fix'\n tag \"cci\": ['CCI-000186']\n tag \"nist\": ['IA-5 (2) (b)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongod_pem = yaml(input('mongod_conf'))['net', 'ssl', 'PEMKeyFile']\n mongod_cafile = yaml(input('mongod_conf'))['net', 'ssl', 'CAFile']\n mongodb_service_account = input('mongodb_service_account')\n mongodb_service_group = input('mongodb_service_group')\n\n describe file(mongod_pem) do\n it { should exist }\n end\n\n describe file(mongod_pem) do\n it { should_not be_more_permissive_than('0600') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\n\n describe file(mongod_cafile) do\n it { should exist }\n end\n\n describe file(mongod_cafile) do\n it { should_not be_more_permissive_than('0600') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\nend\n","source_location":{"ref":"./controls/V-81871.rb","line":1},"id":"V-81871"},{"title":"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.","desc":"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.","descriptions":{"default":"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.","check":"Review the system documentation to determine the required\n levels of protection for DBMS server securables by type of login. Review the\n permissions actually in place on the server. If the actual permissions do not\n match the documented requirements, this is a finding.\n\n MongoDB commands to view roles in a particular database:\n\n db.getRoles(\n {\n rolesInfo: 1,\n showPrivileges:true,\n showBuiltinRoles: true\n }\n )","fix":"Use createRole(), updateRole(), dropRole(), grantRole()\n statements to add and remove permissions on server-level securables, bringing\n them into line with the documented requirements.\n\n MongoDB commands for role management can be found here:\n https://docs.mongodb.com/v3.4/reference/method/js-role-management/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000033-DB-000084","gid":"V-81845","rid":"SV-96559r1_rule","stig_id":"MD3X-00-000020","fix_id":"F-88695r2_fix","cci":["CCI-000213"],"nist":["AC-3"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81845' do\n title \"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.\"\n desc \"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.\"\n\n desc 'check', \"Review the system documentation to determine the required\n levels of protection for DBMS server securables by type of login. Review the\n permissions actually in place on the server. If the actual permissions do not\n match the documented requirements, this is a finding.\n\n MongoDB commands to view roles in a particular database:\n\n db.getRoles(\n {\n rolesInfo: 1,\n showPrivileges:true,\n showBuiltinRoles: true\n }\n )\"\n desc 'fix', \"Use createRole(), updateRole(), dropRole(), grantRole()\n statements to add and remove permissions on server-level securables, bringing\n them into line with the documented requirements.\n\n MongoDB commands for role management can be found here:\n https://docs.mongodb.com/v3.4/reference/method/js-role-management/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000033-DB-000084'\n tag \"gid\": 'V-81845'\n tag \"rid\": 'SV-96559r1_rule'\n tag \"stig_id\": 'MD3X-00-000020'\n tag \"fix_id\": 'F-88695r2_fix'\n tag \"cci\": ['CCI-000213']\n tag \"nist\": ['AC-3']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getRoles({rolesInfo: 1,showPrivileges:true,showBuiltinRoles: true})\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Manually verify privileges for Role: `#{entry['role']}` within Database: `#{db}`\n Privileges: #{entry['privileges']}\" do\n skip\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81845.rb","line":1},"id":"V-81845"},{"title":"MongoDB must protect its audit features from unauthorized access.","desc":"Protecting audit data also includes identifying and protecting the\n tools used to view and manipulate log data.\n\n Depending upon the log format and application, system and application log\n tools may provide the only means to manipulate and manage application and\n system log data. It is, therefore, imperative that access to audit tools be\n controlled and protected from unauthorized access.\n\n Applications providing tools to interface with audit data will leverage\n user permissions and roles identifying the user accessing the tools and the\n corresponding rights the user enjoys in order make access decisions regarding\n the access to audit tools.\n\n Audit tools include, but are not limited to, OS-provided audit tools,\n vendor-provided audit tools, and open source audit tools needed to successfully\n view and manipulate audit information system activity and records.\n\n If an attacker were to gain access to audit tools, he could analyze audit\n logs for system weaknesses or weaknesses in the auditing itself. An attacker\n could also manipulate logs to hide evidence of malicious activity.","descriptions":{"default":"Protecting audit data also includes identifying and protecting the\n tools used to view and manipulate log data.\n\n Depending upon the log format and application, system and application log\n tools may provide the only means to manipulate and manage application and\n system log data. It is, therefore, imperative that access to audit tools be\n controlled and protected from unauthorized access.\n\n Applications providing tools to interface with audit data will leverage\n user permissions and roles identifying the user accessing the tools and the\n corresponding rights the user enjoys in order make access decisions regarding\n the access to audit tools.\n\n Audit tools include, but are not limited to, OS-provided audit tools,\n vendor-provided audit tools, and open source audit tools needed to successfully\n view and manipulate audit information system activity and records.\n\n If an attacker were to gain access to audit tools, he could analyze audit\n logs for system weaknesses or weaknesses in the auditing itself. An attacker\n could also manipulate logs to hide evidence of malicious activity.","check":"Verify User ownership, Group ownership, and permissions on the\n “\":\n\n (default name and location is '/etc/mongod.conf')\n\n (The name and location for the MongoDB configuration file will vary according\n to local circumstances.)\n\n Using the default name and location the command would be:\n\n > ls –ald /etc/mongod.conf\n\n If the User owner is not \"mongod\", this is a finding.\n\n If the Group owner is not \"mongod\", this is a finding.\n\n If the filename is more permissive than \"700\", this is a finding.","fix":"Run these commands:\n\n \"chown mongod \"\n \"chgrp mongod \"\n \"chmod 700 <\"\n\n (The name and location for the MongoDB configuration file will vary according\n to local circumstances. The default name and location is '/etc/mongod.conf'.)\n\n Using the default name and location the commands would be:\n\n > chown mongod /etc/mongod.conf\n > chgrp mongod /etc/mongod.conf\n > chmod 700 /etc/mongod.conf"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000121-DB-000202","satisfies":["SRG-APP-000121-DB-000202","SRG-APP-000122-DB-000203","SRG-APP-000122-DB-000204"],"gid":"V-81851","rid":"SV-96565r1_rule","stig_id":"MD3X-00-000220","fix_id":"F-88701r1_fix","cci":["CCI-001493","CCI-001494","CCI-001495"],"nist":["AU-9"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81851' do\n title 'MongoDB must protect its audit features from unauthorized access.'\n desc \"Protecting audit data also includes identifying and protecting the\n tools used to view and manipulate log data.\n\n Depending upon the log format and application, system and application log\n tools may provide the only means to manipulate and manage application and\n system log data. It is, therefore, imperative that access to audit tools be\n controlled and protected from unauthorized access.\n\n Applications providing tools to interface with audit data will leverage\n user permissions and roles identifying the user accessing the tools and the\n corresponding rights the user enjoys in order make access decisions regarding\n the access to audit tools.\n\n Audit tools include, but are not limited to, OS-provided audit tools,\n vendor-provided audit tools, and open source audit tools needed to successfully\n view and manipulate audit information system activity and records.\n\n If an attacker were to gain access to audit tools, he could analyze audit\n logs for system weaknesses or weaknesses in the auditing itself. An attacker\n could also manipulate logs to hide evidence of malicious activity.\n \"\n\n desc 'check', \"Verify User ownership, Group ownership, and permissions on the\n “\\\":\n\n (default name and location is '/etc/mongod.conf')\n\n (The name and location for the MongoDB configuration file will vary according\n to local circumstances.)\n\n Using the default name and location the command would be:\n\n > ls –ald /etc/mongod.conf\n\n If the User owner is not \\\"mongod\\\", this is a finding.\n\n If the Group owner is not \\\"mongod\\\", this is a finding.\n\n If the filename is more permissive than \\\"700\\\", this is a finding.\"\n desc 'fix', \"Run these commands:\n\n \\\"chown mongod \\\"\n \\\"chgrp mongod \\\"\n \\\"chmod 700 <\\\"\n\n (The name and location for the MongoDB configuration file will vary according\n to local circumstances. The default name and location is '/etc/mongod.conf'.)\n\n Using the default name and location the commands would be:\n\n > chown mongod /etc/mongod.conf\n > chgrp mongod /etc/mongod.conf\n > chmod 700 /etc/mongod.conf\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000121-DB-000202'\n tag \"satisfies\": %w(SRG-APP-000121-DB-000202 SRG-APP-000122-DB-000203\n SRG-APP-000122-DB-000204)\n tag \"gid\": 'V-81851'\n tag \"rid\": 'SV-96565r1_rule'\n tag \"stig_id\": 'MD3X-00-000220'\n tag \"fix_id\": 'F-88701r1_fix'\n tag \"cci\": %w(CCI-001493 CCI-001494 CCI-001495)\n tag \"nist\": ['AU-9']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongodb_service_account = input('mongodb_service_account')\n mongodb_service_group = input('mongodb_service_group')\n\n describe file(input('mongod_conf')) do\n it { should_not be_more_permissive_than('0700') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\nend\n","source_location":{"ref":"./controls/V-81851.rb","line":1},"id":"V-81851"},{"title":"MongoDB must map the PKI-authenticated identity to an associated user\n account.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n Once a PKI certificate has been validated, it must be mapped to a DBMS user\n account for the authenticated identity to be meaningful to MongoDB and useful\n for authorization decisions.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n Once a PKI certificate has been validated, it must be mapped to a DBMS user\n account for the authenticated identity to be meaningful to MongoDB and useful\n for authorization decisions.","check":"To authenticate with a client certificate, you must first add\n the value of the subject from the client certificate as a MongoDB user.\n\n Each unique x.509 client certificate corresponds to a single MongoDB user; i.e.\n you cannot use a single client certificate to authenticate more than one\n MongoDB user.\n\n Login to MongoDB and run the following command:\n\n use $external\n db.getUsers()\n\n If the output does not contain a Relative Distinguished Name (RDN) for an\n authorized user, this is a finding.\n\n If the output shows a Relative Distinguished Name (RDN) for users that are not\n authorized, this is a finding.","fix":"Add x.509 Certificate subject as an authorized user.\n\n To authenticate with a client certificate, you must first add the value of the\n subject from the client certificate as a MongoDB user.\n\n Each unique x.509 client certificate corresponds to a single MongoDB user; i.e.\n you cannot use a single client certificate to authenticate more than one\n MongoDB user.\n\n Note: The RDNs in the subject string must be compatible with the RFC2253\n standard.\n\n Retrieve the RFC2253 formatted subject from the client certificate with the\n following command:\n openssl x509 -in -inform PEM -subject -nameopt RFC2253\n\n The command returns the subject string as well as certificate:\n subject= CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry\n -----BEGIN CERTIFICATE-----\n # ...\n -----END CERTIFICATE-----\n\n Add the RFC2253 compliant value of the subject as a user. Omit spaces as needed.\n\n For example, in the mongo shell, to add the user with both the \"readWrite\"\n role in the test database and the \"userAdminAnyDatabase\" role which is\n defined only in the admin database:\n db.getSiblingDB(\"$external\").runCommand(\n {\n createUser:\n \"CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry\",\n roles: [\n { role: 'readWrite', db: 'test' },\n { role: 'userAdminAnyDatabase', db: 'admin' }\n ],\n writeConcern: { w: \"majority\" , wtimeout: 5000 }\n }\n )\n\n In the above example, to add the user with the \"readWrite\" role in the test\n database, the role specification document specified \"test\" in the \"db\"\n field. To add \"userAdminAnyDatabase\" role for the user, the above example\n specified \"admin\" in the \"db\" field.\n\n Note: Some roles are defined only in the admin database, including:\n clusterAdmin, readAnyDatabase, readWriteAnyDatabase, dbAdminAnyDatabase, and\n userAdminAnyDatabase. To add a user with these roles, specify \"admin\" in the\n \"db\" field. See Manage Users and Roles for details on adding a user with\n roles.\n\n To remove a user that is not authorized run the following command:\n\n use $external\n db.dropUser(\"\")"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000177-DB-000069","gid":"V-81873","rid":"SV-96587r1_rule","stig_id":"MD3X-00-000370","fix_id":"F-88723r1_fix","cci":["CCI-000187"],"nist":["IA-5 (2) (c)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81873' do\n title \"MongoDB must map the PKI-authenticated identity to an associated user\n account.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n Once a PKI certificate has been validated, it must be mapped to a DBMS user\n account for the authenticated identity to be meaningful to MongoDB and useful\n for authorization decisions.\"\n\n desc 'check', \"To authenticate with a client certificate, you must first add\n the value of the subject from the client certificate as a MongoDB user.\n\n Each unique x.509 client certificate corresponds to a single MongoDB user; i.e.\n you cannot use a single client certificate to authenticate more than one\n MongoDB user.\n\n Login to MongoDB and run the following command:\n\n use $external\n db.getUsers()\n\n If the output does not contain a Relative Distinguished Name (RDN) for an\n authorized user, this is a finding.\n\n If the output shows a Relative Distinguished Name (RDN) for users that are not\n authorized, this is a finding.\"\n desc 'fix', \"Add x.509 Certificate subject as an authorized user.\n\n To authenticate with a client certificate, you must first add the value of the\n subject from the client certificate as a MongoDB user.\n\n Each unique x.509 client certificate corresponds to a single MongoDB user; i.e.\n you cannot use a single client certificate to authenticate more than one\n MongoDB user.\n\n Note: The RDNs in the subject string must be compatible with the RFC2253\n standard.\n\n Retrieve the RFC2253 formatted subject from the client certificate with the\n following command:\n openssl x509 -in -inform PEM -subject -nameopt RFC2253\n\n The command returns the subject string as well as certificate:\n subject= CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry\n -----BEGIN CERTIFICATE-----\n # ...\n -----END CERTIFICATE-----\n\n Add the RFC2253 compliant value of the subject as a user. Omit spaces as needed.\n\n For example, in the mongo shell, to add the user with both the \\\"readWrite\\\"\n role in the test database and the \\\"userAdminAnyDatabase\\\" role which is\n defined only in the admin database:\n db.getSiblingDB(\\\"$external\\\").runCommand(\n {\n createUser:\n \\\"CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry\\\",\n roles: [\n { role: 'readWrite', db: 'test' },\n { role: 'userAdminAnyDatabase', db: 'admin' }\n ],\n writeConcern: { w: \\\"majority\\\" , wtimeout: 5000 }\n }\n )\n\n In the above example, to add the user with the \\\"readWrite\\\" role in the test\n database, the role specification document specified \\\"test\\\" in the \\\"db\\\"\n field. To add \\\"userAdminAnyDatabase\\\" role for the user, the above example\n specified \\\"admin\\\" in the \\\"db\\\" field.\n\n Note: Some roles are defined only in the admin database, including:\n clusterAdmin, readAnyDatabase, readWriteAnyDatabase, dbAdminAnyDatabase, and\n userAdminAnyDatabase. To add a user with these roles, specify \\\"admin\\\" in the\n \\\"db\\\" field. See Manage Users and Roles for details on adding a user with\n roles.\n\n To remove a user that is not authorized run the following command:\n\n use $external\n db.dropUser(\\\"\\\")\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000177-DB-000069'\n tag \"gid\": 'V-81873'\n tag \"rid\": 'SV-96587r1_rule'\n tag \"stig_id\": 'MD3X-00-000370'\n tag \"fix_id\": 'F-88723r1_fix'\n tag \"cci\": ['CCI-000187']\n tag \"nist\": ['IA-5 (2) (c)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure MongoDB maps the PKI-authenticated identity to an associated user\n account' do\n skip 'A manual review is required to ensure MongoDB maps the PKI-authenticated identity to an associated user\n account'\n end\nend\n","source_location":{"ref":"./controls/V-81873.rb","line":1},"id":"V-81873"},{"title":"MongoDB must check the validity of all data inputs except those\n specifically identified by the organization.","desc":"Invalid user input occurs when a user inserts data or characters into\n an application's data entry fields and the application is unprepared to process\n that data. This results in unanticipated application behavior, potentially\n leading to an application or information system compromise. Invalid user input\n is one of the primary methods employed when attempting to compromise an\n application.\n\n With respect to database management systems, one class of threat is known\n as SQL Injection, or more generally, code injection. It takes advantage of the\n dynamic execution capabilities of various programming languages, including\n dialects of SQL. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n Even when no such hijacking takes place, invalid input that gets recorded\n in the database, whether accidental or malicious, reduces the reliability and\n usability of the system. Available protections include data types, referential\n constraints, uniqueness constraints, range checking, and application-specific\n logic. Application-specific logic can be implemented within the database in\n stored procedures and triggers, where appropriate.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"Invalid user input occurs when a user inserts data or characters into\n an application's data entry fields and the application is unprepared to process\n that data. This results in unanticipated application behavior, potentially\n leading to an application or information system compromise. Invalid user input\n is one of the primary methods employed when attempting to compromise an\n application.\n\n With respect to database management systems, one class of threat is known\n as SQL Injection, or more generally, code injection. It takes advantage of the\n dynamic execution capabilities of various programming languages, including\n dialects of SQL. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n Even when no such hijacking takes place, invalid input that gets recorded\n in the database, whether accidental or malicious, reduces the reliability and\n usability of the system. Available protections include data types, referential\n constraints, uniqueness constraints, range checking, and application-specific\n logic. Application-specific logic can be implemented within the database in\n stored procedures and triggers, where appropriate.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"As a client program assembles a query in MongoDB, it builds a\n BSON object, not a string. Thus traditional SQL injection attacks are not a\n problem. However, MongoDB operations permit arbitrary JavaScript expressions to\n be run directly on the server.\n\n If the \"security.javascriptEnabled\" option is set to \"true\" in the config\n file, this is a finding.\n\n Starting with MongoDB 3.2, database-level document validation can be configured\n for specific collections. Configured validation rules for the selected database\n can be viewed via the db.getSisterDB(\"database_name\").getCollectionInfos()\n command in mongo shell.\n\n If validation is desired, but no rules are set, the valdiationAction is not\n \"error\" or the \"bypassDocumentValidation\" option is used for write commands\n on the application side, this is a finding.","fix":"Disable the javascriptEnabled option in the config file.\n\n security:\n javascriptEnabled: false\n\n If document validation is needed, it should be configured according to the\n documentation page at\n https://docs.mongodb.com/manual/core/document-validation/."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000251-DB-000160","gid":"V-81889","rid":"SV-96603r1_rule","stig_id":"MD3X-00-000490","fix_id":"F-88739r1_fix","cci":["CCI-001310"],"nist":["SI-10"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81889' do\n title \"MongoDB must check the validity of all data inputs except those\n specifically identified by the organization.\"\n desc \"Invalid user input occurs when a user inserts data or characters into\n an application's data entry fields and the application is unprepared to process\n that data. This results in unanticipated application behavior, potentially\n leading to an application or information system compromise. Invalid user input\n is one of the primary methods employed when attempting to compromise an\n application.\n\n With respect to database management systems, one class of threat is known\n as SQL Injection, or more generally, code injection. It takes advantage of the\n dynamic execution capabilities of various programming languages, including\n dialects of SQL. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n Even when no such hijacking takes place, invalid input that gets recorded\n in the database, whether accidental or malicious, reduces the reliability and\n usability of the system. Available protections include data types, referential\n constraints, uniqueness constraints, range checking, and application-specific\n logic. Application-specific logic can be implemented within the database in\n stored procedures and triggers, where appropriate.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"As a client program assembles a query in MongoDB, it builds a\n BSON object, not a string. Thus traditional SQL injection attacks are not a\n problem. However, MongoDB operations permit arbitrary JavaScript expressions to\n be run directly on the server.\n\n If the \\\"security.javascriptEnabled\\\" option is set to \\\"true\\\" in the config\n file, this is a finding.\n\n Starting with MongoDB 3.2, database-level document validation can be configured\n for specific collections. Configured validation rules for the selected database\n can be viewed via the db.getSisterDB(\\\"database_name\\\").getCollectionInfos()\n command in mongo shell.\n\n If validation is desired, but no rules are set, the valdiationAction is not\n \\\"error\\\" or the \\\"bypassDocumentValidation\\\" option is used for write commands\n on the application side, this is a finding.\"\n desc 'fix', \"Disable the javascriptEnabled option in the config file.\n\n security:\n javascriptEnabled: false\n\n If document validation is needed, it should be configured according to the\n documentation page at\n https://docs.mongodb.com/manual/core/document-validation/.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000251-DB-000160'\n tag \"gid\": 'V-81889'\n tag \"rid\": 'SV-96603r1_rule'\n tag \"stig_id\": 'MD3X-00-000490'\n tag \"fix_id\": 'F-88739r1_fix'\n tag \"cci\": ['CCI-001310']\n tag \"nist\": ['SI-10']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security javascriptEnabled)) { should cmp 'false' }\n end\nend\n","source_location":{"ref":"./controls/V-81889.rb","line":1},"id":"V-81889"},{"title":"MongoDB must uniquely identify and authenticate non-organizational\n users (or processes acting on behalf of non-organizational users).","desc":"Non-organizational users include all information system users other\n than organizational users, which include organizational employees or\n individuals the organization deems to have equivalent status of employees\n (e.g., contractors, guest researchers, individuals from allied nations).\n\n Non-organizational users must be uniquely identified and authenticated for\n all accesses other than those accesses explicitly identified and documented by\n the organization when related to the use of anonymous access, such as accessing\n a web server.\n\n Accordingly, a risk assessment is used in determining the authentication\n needs of the organization.\n\n Scalability, practicality, and security are simultaneously considered in\n balancing the need to ensure ease of use for access to federal information and\n information systems with the need to protect and adequately mitigate risk to\n organizational operations, organizational assets, individuals, other\n organizations, and the Nation.","descriptions":{"default":"Non-organizational users include all information system users other\n than organizational users, which include organizational employees or\n individuals the organization deems to have equivalent status of employees\n (e.g., contractors, guest researchers, individuals from allied nations).\n\n Non-organizational users must be uniquely identified and authenticated for\n all accesses other than those accesses explicitly identified and documented by\n the organization when related to the use of anonymous access, such as accessing\n a web server.\n\n Accordingly, a risk assessment is used in determining the authentication\n needs of the organization.\n\n Scalability, practicality, and security are simultaneously considered in\n balancing the need to ensure ease of use for access to federal information and\n information systems with the need to protect and adequately mitigate risk to\n organizational operations, organizational assets, individuals, other\n organizations, and the Nation.","check":"MongoDB grants access to data and commands through role-based\n authorization and provides built-in roles that provide the different levels of\n access commonly needed in a database system. You can additionally create\n user-defined roles.\n\n Check a user's role to ensure correct privileges for the function:\n\n Prereq: To view a user's roles, you must have the \"viewUser\" privilege.\n\n Connect to MongoDB.\n\n For each database in the system, identify the user's roles for the database:\n\n use \n db.getUser(\"[username]\")\n\n The server will return a document with the user's roles.\n\n View a role's privileges:\n\n Prereq: To view a user's roles, you must have the \"viewUser\" privilege.\n\n For each database, identify the privileges granted by a role:\n\n use \n db.getRole( \"read\", { showPrivileges: true } )\n\n The server will return a document with the \"privileges\" and\n \"inheritedPrivileges\" arrays. The \"privileges returned document lists the\n privileges directly specified by the role and excludes those privileges\n inherited from other roles. The \"inheritedPrivileges\" returned document lists\n all privileges granted by this role, both directly specified and inherited. If\n the role does not inherit from other roles, the two fields are the same.\n\n If a user has a role with inappropriate privileges, this is a finding.","fix":"Prereq: To view a user's roles, must have the \"viewUser\"\n privilege.\n\n Connect to MongoDB.\n\n For each database, identify the user's roles for the database.\n\n use \n db.getUser(\"[username]\")\n\n The server will return a document with the user's roles.\n\n To revoke a user's role from a database use the db.revokeRolesFromUser() method.\n\n To grant a role to a user use the db.grantRolesToUser() method."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000180-DB-000115","satisfies":["SRG-APP-000180-DB-000115","SRG-APP-000211-DB-000122","SRG-APP-000211-DB-000124"],"gid":"V-81877","rid":"SV-96591r1_rule","stig_id":"MD3X-00-000390","fix_id":"F-88727r2_fix","cci":["CCI-000804","CCI-001082","CCI-001084"],"nist":["IA-8","SC-2","SC-3"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81877' do\n title \"MongoDB must uniquely identify and authenticate non-organizational\n users (or processes acting on behalf of non-organizational users).\"\n desc \"Non-organizational users include all information system users other\n than organizational users, which include organizational employees or\n individuals the organization deems to have equivalent status of employees\n (e.g., contractors, guest researchers, individuals from allied nations).\n\n Non-organizational users must be uniquely identified and authenticated for\n all accesses other than those accesses explicitly identified and documented by\n the organization when related to the use of anonymous access, such as accessing\n a web server.\n\n Accordingly, a risk assessment is used in determining the authentication\n needs of the organization.\n\n Scalability, practicality, and security are simultaneously considered in\n balancing the need to ensure ease of use for access to federal information and\n information systems with the need to protect and adequately mitigate risk to\n organizational operations, organizational assets, individuals, other\n organizations, and the Nation.\n \"\n\n desc 'check', \"MongoDB grants access to data and commands through role-based\n authorization and provides built-in roles that provide the different levels of\n access commonly needed in a database system. You can additionally create\n user-defined roles.\n\n Check a user's role to ensure correct privileges for the function:\n\n Prereq: To view a user's roles, you must have the \\\"viewUser\\\" privilege.\n\n Connect to MongoDB.\n\n For each database in the system, identify the user's roles for the database:\n\n use \n db.getUser(\\\"[username]\\\")\n\n The server will return a document with the user's roles.\n\n View a role's privileges:\n\n Prereq: To view a user's roles, you must have the \\\"viewUser\\\" privilege.\n\n For each database, identify the privileges granted by a role:\n\n use \n db.getRole( \\\"read\\\", { showPrivileges: true } )\n\n The server will return a document with the \\\"privileges\\\" and\n \\\"inheritedPrivileges\\\" arrays. The \\\"privileges returned document lists the\n privileges directly specified by the role and excludes those privileges\n inherited from other roles. The \\\"inheritedPrivileges\\\" returned document lists\n all privileges granted by this role, both directly specified and inherited. If\n the role does not inherit from other roles, the two fields are the same.\n\n If a user has a role with inappropriate privileges, this is a finding.\"\n desc 'fix', \"Prereq: To view a user's roles, must have the \\\"viewUser\\\"\n privilege.\n\n Connect to MongoDB.\n\n For each database, identify the user's roles for the database.\n\n use \n db.getUser(\\\"[username]\\\")\n\n The server will return a document with the user's roles.\n\n To revoke a user's role from a database use the db.revokeRolesFromUser() method.\n\n To grant a role to a user use the db.grantRolesToUser() method.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000180-DB-000115'\n tag \"satisfies\": %w(SRG-APP-000180-DB-000115 SRG-APP-000211-DB-000122\n SRG-APP-000211-DB-000124)\n tag \"gid\": 'V-81877'\n tag \"rid\": 'SV-96591r1_rule'\n tag \"stig_id\": 'MD3X-00-000390'\n tag \"fix_id\": 'F-88727r2_fix'\n tag \"cci\": %w(CCI-000804 CCI-001082 CCI-001084)\n tag \"nist\": %w(IA-8 SC-2 SC-3)\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getUsers()\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Manually verify roles for User: `#{entry['user']}` within Database: `#{entry['db']}`\n Roles: #{entry['roles']}\" do\n skip\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81877.rb","line":1},"id":"V-81877"},{"title":"MongoDB must implement cryptographic mechanisms to prevent\n unauthorized modification of organization-defined information at rest (to\n include, at a minimum, PII and classified information) on organization-defined\n information system components.","desc":"DBMSs handling data requiring \"data at rest\" protections must employ\n cryptographic mechanisms to prevent unauthorized disclosure and modification of\n the information at rest. These cryptographic mechanisms may be native to\n MongoDB or implemented via additional software or operating system/file system\n settings, as appropriate to the situation.\n\n Selection of a cryptographic mechanism is based on the need to protect the\n integrity of organizational information. The strength of the mechanism is\n commensurate with the security category and/or classification of the\n information. Organizations have the flexibility to either encrypt all\n information on storage devices (i.e., full disk encryption) or encrypt specific\n data structures (e.g., files, records, or fields).\n\n The decision whether and what to encrypt rests with the data owner and is\n also influenced by the physical measures taken to secure the equipment and\n media on which the information resides.","descriptions":{"default":"DBMSs handling data requiring \"data at rest\" protections must employ\n cryptographic mechanisms to prevent unauthorized disclosure and modification of\n the information at rest. These cryptographic mechanisms may be native to\n MongoDB or implemented via additional software or operating system/file system\n settings, as appropriate to the situation.\n\n Selection of a cryptographic mechanism is based on the need to protect the\n integrity of organizational information. The strength of the mechanism is\n commensurate with the security category and/or classification of the\n information. Organizations have the flexibility to either encrypt all\n information on storage devices (i.e., full disk encryption) or encrypt specific\n data structures (e.g., files, records, or fields).\n\n The decision whether and what to encrypt rests with the data owner and is\n also influenced by the physical measures taken to secure the equipment and\n media on which the information resides.","check":"Review the documentation and/or specification for the\n organization-defined information.\n\n If any data is PII, classified or is deemed by the organization to be encrypted\n at rest, this is a finding.\n\n Verify the mongod command line contain the following options:\n\n --enableEncryption\n --kmipServerName \n --kmipPort \n --kmipServerCAFile ca.pem\n --kmipClientCertificateFile client.pem\n\n If these above options are not part of the mongod command line, this is a\n finding.\n\n Items in the <> above and starting with kmip* are specific to the KMIP\n appliance and need to be set according to the KMIP appliance configuration.","fix":"Configure MongoDB to use the Encrypted Storage Engine and a KMIP\n appliance as documented here:\n\n https://docs.mongodb.com/v3.4/core/security-encryption-at-rest/\n https://docs.mongodb.com/v3.4/tutorial/configure-encryption/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000428-DB-000386","satisfies":["SRG-APP-000428-DB-000386","SRG-APP-000429-DB-000387"],"gid":"V-81919","rid":"SV-96633r1_rule","stig_id":"MD3X-00-000740","fix_id":"F-88769r1_fix","cci":["CCI-002475"],"nist":["SC-28 (1)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81919' do\n title \"MongoDB must implement cryptographic mechanisms to prevent\n unauthorized modification of organization-defined information at rest (to\n include, at a minimum, PII and classified information) on organization-defined\n information system components.\"\n desc \"DBMSs handling data requiring \\\"data at rest\\\" protections must employ\n cryptographic mechanisms to prevent unauthorized disclosure and modification of\n the information at rest. These cryptographic mechanisms may be native to\n MongoDB or implemented via additional software or operating system/file system\n settings, as appropriate to the situation.\n\n Selection of a cryptographic mechanism is based on the need to protect the\n integrity of organizational information. The strength of the mechanism is\n commensurate with the security category and/or classification of the\n information. Organizations have the flexibility to either encrypt all\n information on storage devices (i.e., full disk encryption) or encrypt specific\n data structures (e.g., files, records, or fields).\n\n The decision whether and what to encrypt rests with the data owner and is\n also influenced by the physical measures taken to secure the equipment and\n media on which the information resides.\n\n \"\n\n desc 'check', \"Review the documentation and/or specification for the\n organization-defined information.\n\n If any data is PII, classified or is deemed by the organization to be encrypted\n at rest, this is a finding.\n\n Verify the mongod command line contain the following options:\n\n --enableEncryption\n --kmipServerName \n --kmipPort \n --kmipServerCAFile ca.pem\n --kmipClientCertificateFile client.pem\n\n If these above options are not part of the mongod command line, this is a\n finding.\n\n Items in the <> above and starting with kmip* are specific to the KMIP\n appliance and need to be set according to the KMIP appliance configuration.\"\n desc 'fix', \"Configure MongoDB to use the Encrypted Storage Engine and a KMIP\n appliance as documented here:\n\n https://docs.mongodb.com/v3.4/core/security-encryption-at-rest/\n https://docs.mongodb.com/v3.4/tutorial/configure-encryption/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000428-DB-000386'\n tag \"satisfies\": %w(SRG-APP-000428-DB-000386 SRG-APP-000429-DB-000387)\n tag \"gid\": 'V-81919'\n tag \"rid\": 'SV-96633r1_rule'\n tag \"stig_id\": 'MD3X-00-000740'\n tag \"fix_id\": 'F-88769r1_fix'\n tag \"cci\": ['CCI-002475']\n tag \"nist\": ['SC-28 (1)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe.one do\n describe yaml(input('mongod_conf')) do\n its(%w(security kmip serverName)) { should_not be_nil }\n its(%w(security kmip port)) { should_not be_nil }\n its(%w(security kmip port)) { should_not be_nil }\n its(%w(security kmip serverCAFile)) { should_not be_nil }\n its(%w(security kmip clientCertificateFile)) { should_not be_nil }\n its(%w(security enableEncryption)) { should cmp 'true' }\n end\n describe processes('mongod') do\n its('commands.join') { should match /--enableEncryption/ }\n its('commands.join') { should match /--kmipServerName/ }\n its('commands.join') { should match /--kmipPort/ }\n its('commands.join') { should match /--kmipServerCAFile/ }\n its('commands.join') { should match /--kmipClientCertificateFile/ }\n end\n end\nend\n","source_location":{"ref":"./controls/V-81919.rb","line":1},"id":"V-81919"},{"title":"MongoDB must fail to a secure state if system initialization fails,\n shutdown fails, or aborts fail.","desc":"Failure to a known state can address safety or security in accordance\n with the mission/business needs of the organization.\n\n Failure to a known secure state helps prevent a loss of confidentiality,\n integrity, or availability in the event of a failure of the information system\n or a component of the system.\n\n Failure to a known safe state helps prevent systems from failing to a state\n that may cause loss of data or unauthorized access to system resources. Systems\n that fail suddenly and with no incorporated failure state planning may leave\n the hosting system available but with a reduced security protection capability.\n Preserving information system state data also facilitates system restart and\n return to the operational mode of the organization with less disruption of\n mission/business processes.\n\n Databases must fail to a known consistent state. Transactions must be\n successfully completed or rolled back.\n\n In general, security mechanisms should be designed so that a failure will\n follow the same execution path as disallowing the operation. For example,\n application security methods, such as isAuthorized(), isAuthenticated(), and\n validate(), should all return false if there is an exception during processing.\n If security controls can throw exceptions, they must be very clear about\n exactly what that condition means.\n\n Abort refers to stopping a program or function before it has finished\n naturally. The term abort refers to both requested and unexpected terminations.","descriptions":{"default":"Failure to a known state can address safety or security in accordance\n with the mission/business needs of the organization.\n\n Failure to a known secure state helps prevent a loss of confidentiality,\n integrity, or availability in the event of a failure of the information system\n or a component of the system.\n\n Failure to a known safe state helps prevent systems from failing to a state\n that may cause loss of data or unauthorized access to system resources. Systems\n that fail suddenly and with no incorporated failure state planning may leave\n the hosting system available but with a reduced security protection capability.\n Preserving information system state data also facilitates system restart and\n return to the operational mode of the organization with less disruption of\n mission/business processes.\n\n Databases must fail to a known consistent state. Transactions must be\n successfully completed or rolled back.\n\n In general, security mechanisms should be designed so that a failure will\n follow the same execution path as disallowing the operation. For example,\n application security methods, such as isAuthorized(), isAuthenticated(), and\n validate(), should all return false if there is an exception during processing.\n If security controls can throw exceptions, they must be very clear about\n exactly what that condition means.\n\n Abort refers to stopping a program or function before it has finished\n naturally. The term abort refers to both requested and unexpected terminations.","check":"Journaling is enabled by default in 64-bit systems.\n\n With journaling enabled, if mongod stops unexpectedly, the program can recover\n everything written to the journal.\n\n MongoDB will re-apply the write operations on restart and maintain a consistent\n state. By default, the greatest extent of lost writes, i.e., those not made to\n the journal, are those made in the last 100 milliseconds, plus the time it\n takes to perform the actual journal writes.\n\n Verify the mongod process startup options.\n\n If the mongod process was started with the \"--nojournal\" option, this is a\n finding.","fix":"Modify the mongod startup command-line options by removing the\n \"--nojournal\" option.\n\n Edit the MongoDB database configuration file (default location:\n /etc/mongod.conf) to ensure it contains the following parameter setting:\n\n storage:\n journal:\n enabled: true\n\n Stop/start (restart) any or all mongod processes."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000225-DB-000153","satisfies":["SRG-APP-000225-DB-000153","SRG-APP-000226-DB-000147"],"gid":"V-81881","rid":"SV-96595r1_rule","stig_id":"MD3X-00-000420","fix_id":"F-88731r1_fix","cci":["CCI-001190","CCI-001665"],"nist":["SC-24"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81881' do\n title \"MongoDB must fail to a secure state if system initialization fails,\n shutdown fails, or aborts fail.\"\n desc \"Failure to a known state can address safety or security in accordance\n with the mission/business needs of the organization.\n\n Failure to a known secure state helps prevent a loss of confidentiality,\n integrity, or availability in the event of a failure of the information system\n or a component of the system.\n\n Failure to a known safe state helps prevent systems from failing to a state\n that may cause loss of data or unauthorized access to system resources. Systems\n that fail suddenly and with no incorporated failure state planning may leave\n the hosting system available but with a reduced security protection capability.\n Preserving information system state data also facilitates system restart and\n return to the operational mode of the organization with less disruption of\n mission/business processes.\n\n Databases must fail to a known consistent state. Transactions must be\n successfully completed or rolled back.\n\n In general, security mechanisms should be designed so that a failure will\n follow the same execution path as disallowing the operation. For example,\n application security methods, such as isAuthorized(), isAuthenticated(), and\n validate(), should all return false if there is an exception during processing.\n If security controls can throw exceptions, they must be very clear about\n exactly what that condition means.\n\n Abort refers to stopping a program or function before it has finished\n naturally. The term abort refers to both requested and unexpected terminations.\n \"\n\n desc 'check', \"Journaling is enabled by default in 64-bit systems.\n\n With journaling enabled, if mongod stops unexpectedly, the program can recover\n everything written to the journal.\n\n MongoDB will re-apply the write operations on restart and maintain a consistent\n state. By default, the greatest extent of lost writes, i.e., those not made to\n the journal, are those made in the last 100 milliseconds, plus the time it\n takes to perform the actual journal writes.\n\n Verify the mongod process startup options.\n\n If the mongod process was started with the \\\"--nojournal\\\" option, this is a\n finding.\"\n desc 'fix', \"Modify the mongod startup command-line options by removing the\n \\\"--nojournal\\\" option.\n\n Edit the MongoDB database configuration file (default location:\n /etc/mongod.conf) to ensure it contains the following parameter setting:\n\n storage:\n journal:\n enabled: true\n\n Stop/start (restart) any or all mongod processes.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000225-DB-000153'\n tag \"satisfies\": %w(SRG-APP-000225-DB-000153 SRG-APP-000226-DB-000147)\n tag \"gid\": 'V-81881'\n tag \"rid\": 'SV-96595r1_rule'\n tag \"stig_id\": 'MD3X-00-000420'\n tag \"fix_id\": 'F-88731r1_fix'\n tag \"cci\": %w(CCI-001190 CCI-001665)\n tag \"nist\": ['SC-24']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(storage journal enabled)) { should cmp 'true' }\n end\n\n describe processes('mongod') do\n its('commands.join') { should_not match /--nojournal/ }\n end\nend\n","source_location":{"ref":"./controls/V-81881.rb","line":1},"id":"V-81881"},{"title":"MongoDB must require users to reauthenticate when organization-defined\n circumstances or situations require reauthentication.","desc":"The DoD standard for authentication of an interactive user is the\n presentation of a Common Access Card (CAC) or other physical token bearing a\n valid, current, DoD-issued Public Key Infrastructure (PKI) certificate, coupled\n with a Personal Identification Number (PIN) to be entered by the user at the\n beginning of each session and whenever reauthentication is required.\n\n Without reauthentication, users may access resources or perform tasks for\n which they do not have authorization.\n\n When applications provide the capability to change security roles or\n escalate the functional capability of the application, it is critical the user\n reauthenticate.\n\n In addition to the reauthentication requirements associated with session\n locks, organizations may require reauthentication of individuals and/or devices\n in other situations, including (but not limited to) the following circumstances:\n\n (i) When authenticators change;\n (ii) When roles change;\n (iii) When security categories of information systems change;\n (iv) When the execution of privileged functions occurs;\n (v) After a fixed period of time; or\n (vi) Periodically.\n\n Within the DoD, the minimum circumstances requiring reauthentication are\n privilege escalation and role changes.","descriptions":{"default":"The DoD standard for authentication of an interactive user is the\n presentation of a Common Access Card (CAC) or other physical token bearing a\n valid, current, DoD-issued Public Key Infrastructure (PKI) certificate, coupled\n with a Personal Identification Number (PIN) to be entered by the user at the\n beginning of each session and whenever reauthentication is required.\n\n Without reauthentication, users may access resources or perform tasks for\n which they do not have authorization.\n\n When applications provide the capability to change security roles or\n escalate the functional capability of the application, it is critical the user\n reauthenticate.\n\n In addition to the reauthentication requirements associated with session\n locks, organizations may require reauthentication of individuals and/or devices\n in other situations, including (but not limited to) the following circumstances:\n\n (i) When authenticators change;\n (ii) When roles change;\n (iii) When security categories of information systems change;\n (iv) When the execution of privileged functions occurs;\n (v) After a fixed period of time; or\n (vi) Periodically.\n\n Within the DoD, the minimum circumstances requiring reauthentication are\n privilege escalation and role changes.","check":"If organization-defined circumstances or situations require\n reauthentication, and these situations are not configured to terminate existing\n logins to require reauthentication, this is a finding.","fix":"Determine the organization-defined circumstances or situations\n that require reauthentication and ensure that the mongod and mongos processes\n are stopped/started (restart)."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000389-DB-000372","gid":"V-81913","rid":"SV-96627r1_rule","stig_id":"MD3X-00-000700","fix_id":"F-88763r1_fix","cci":["CCI-002038"],"nist":["IA-11"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81913' do\n title \"MongoDB must require users to reauthenticate when organization-defined\n circumstances or situations require reauthentication.\"\n desc \"The DoD standard for authentication of an interactive user is the\n presentation of a Common Access Card (CAC) or other physical token bearing a\n valid, current, DoD-issued Public Key Infrastructure (PKI) certificate, coupled\n with a Personal Identification Number (PIN) to be entered by the user at the\n beginning of each session and whenever reauthentication is required.\n\n Without reauthentication, users may access resources or perform tasks for\n which they do not have authorization.\n\n When applications provide the capability to change security roles or\n escalate the functional capability of the application, it is critical the user\n reauthenticate.\n\n In addition to the reauthentication requirements associated with session\n locks, organizations may require reauthentication of individuals and/or devices\n in other situations, including (but not limited to) the following circumstances:\n\n (i) When authenticators change;\n (ii) When roles change;\n (iii) When security categories of information systems change;\n (iv) When the execution of privileged functions occurs;\n (v) After a fixed period of time; or\n (vi) Periodically.\n\n Within the DoD, the minimum circumstances requiring reauthentication are\n privilege escalation and role changes.\n \"\n\n desc 'check', \"If organization-defined circumstances or situations require\n reauthentication, and these situations are not configured to terminate existing\n logins to require reauthentication, this is a finding.\"\n desc 'fix', \"Determine the organization-defined circumstances or situations\n that require reauthentication and ensure that the mongod and mongos processes\n are stopped/started (restart).\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000389-DB-000372'\n tag \"gid\": 'V-81913'\n tag \"rid\": 'SV-96627r1_rule'\n tag \"stig_id\": 'MD3X-00-000700'\n tag \"fix_id\": 'F-88763r1_fix'\n tag \"cci\": ['CCI-002038']\n tag \"nist\": ['IA-11']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure MongoDB requires users to reauthenticate when organization-defined\n circumstances or situations require reauthentication.' do\n skip 'A manual review is required to ensure MongoDB requires users to reauthenticate when organization-defined\n circumstances or situations require reauthentication.'\n end\nend\n","source_location":{"ref":"./controls/V-81913.rb","line":1},"id":"V-81913"},{"title":"MongoDB must maintain the authenticity of communications sessions by\n 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\n the adversary guessing at valid session identifiers based on patterns in\n identifiers already known.\n\n The preferred technique for thwarting guesses at Session IDs is the\n generation of unique session identifiers using a FIPS 140-2 approved random\n number generator.\n\n However, it is recognized that available DBMS products do not all implement\n the preferred technique yet may have other protections against session\n hijacking. Therefore, other techniques are acceptable, provided they are\n demonstrated to be effective.","descriptions":{"default":"One class of man-in-the-middle, or session hijacking, attack involves\n the adversary guessing at valid session identifiers based on patterns in\n identifiers already known.\n\n The preferred technique for thwarting guesses at Session IDs is the\n generation of unique session identifiers using a FIPS 140-2 approved random\n number generator.\n\n However, it is recognized that available DBMS products do not all implement\n the preferred technique yet may have other protections against session\n hijacking. Therefore, other techniques are acceptable, provided they are\n demonstrated to be effective.","check":"Check the MongoDB configuration file (default location:\n /etc/mongod.conf).\n\n The following should be set:\n\n net:\n ssl:\n mode: requireSSL\n\n If this is not found in the MongoDB configuration file, this is a finding.","fix":"Follow the documentation guide at\n https://docs.mongodb.com/v3.4/tutorial/configure-ssl/.\n\n Stop/start (restart) and mongod or mongos using the MongoDB configuration file."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000224-DB-000384","gid":"V-81879","rid":"SV-96593r1_rule","stig_id":"MD3X-00-000410","fix_id":"F-88729r1_fix","cci":["CCI-001188"],"nist":["SC-23 (3)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81879' do\n title \"MongoDB must maintain the authenticity of communications sessions by\n guarding against man-in-the-middle attacks that guess at Session ID values.\"\n desc \"One class of man-in-the-middle, or session hijacking, attack involves\n the adversary guessing at valid session identifiers based on patterns in\n identifiers already known.\n\n The preferred technique for thwarting guesses at Session IDs is the\n generation of unique session identifiers using a FIPS 140-2 approved random\n number generator.\n\n However, it is recognized that available DBMS products do not all implement\n the preferred technique yet may have other protections against session\n hijacking. Therefore, other techniques are acceptable, provided they are\n demonstrated to be effective.\n \"\n\n desc 'check', \"Check the MongoDB configuration file (default location:\n /etc/mongod.conf).\n\n The following should be set:\n\n net:\n ssl:\n mode: requireSSL\n\n If this is not found in the MongoDB configuration file, this is a finding.\"\n desc 'fix', \"Follow the documentation guide at\n https://docs.mongodb.com/v3.4/tutorial/configure-ssl/.\n\n Stop/start (restart) and mongod or mongos using the MongoDB configuration file.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000224-DB-000384'\n tag \"gid\": 'V-81879'\n tag \"rid\": 'SV-96593r1_rule'\n tag \"stig_id\": 'MD3X-00-000410'\n tag \"fix_id\": 'F-88729r1_fix'\n tag \"cci\": ['CCI-001188']\n tag \"nist\": ['SC-23 (3)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl mode)) { should cmp 'requireSSL' }\n end\nend\n","source_location":{"ref":"./controls/V-81879.rb","line":1},"id":"V-81879"},{"title":"MongoDB must enforce discretionary access control policies, as defined\n by the data owner, over defined subjects and objects.","desc":"Discretionary Access Control (DAC) is based on the notion that\n individual users are \"owners\" of objects and therefore have discretion over\n who should be authorized to access the object and in which mode (e.g., read or\n write). Ownership is usually acquired as a consequence of creating the object\n or via specified ownership assignment. DAC allows the owner to determine who\n will have access to objects they control. An example of DAC includes\n user-controlled table permissions.\n\n When discretionary access control policies are implemented, subjects are\n not constrained with regard to what actions they can take with information for\n which they have already been granted access. Thus, subjects that have been\n granted access to information are not prevented from passing (i.e., the\n subjects have the discretion to pass) the information to other subjects or\n objects.\n\n A subject that is constrained in its operation by Mandatory Access Control\n policies is still able to operate under the less rigorous constraints of this\n requirement. Thus, while Mandatory Access Control imposes constraints\n preventing a subject from passing information to another subject operating at a\n different sensitivity level, this requirement permits the subject to pass the\n information to any subject at the same sensitivity level.\n\n The policy is bounded by the information system boundary. Once the\n information is passed outside of the control of the information system,\n additional means may be required to ensure the constraints remain in effect.\n While the older, more traditional definitions of discretionary access control\n require identity-based access control, that limitation is not required for this\n use of discretionary access control.","descriptions":{"default":"Discretionary Access Control (DAC) is based on the notion that\n individual users are \"owners\" of objects and therefore have discretion over\n who should be authorized to access the object and in which mode (e.g., read or\n write). Ownership is usually acquired as a consequence of creating the object\n or via specified ownership assignment. DAC allows the owner to determine who\n will have access to objects they control. An example of DAC includes\n user-controlled table permissions.\n\n When discretionary access control policies are implemented, subjects are\n not constrained with regard to what actions they can take with information for\n which they have already been granted access. Thus, subjects that have been\n granted access to information are not prevented from passing (i.e., the\n subjects have the discretion to pass) the information to other subjects or\n objects.\n\n A subject that is constrained in its operation by Mandatory Access Control\n policies is still able to operate under the less rigorous constraints of this\n requirement. Thus, while Mandatory Access Control imposes constraints\n preventing a subject from passing information to another subject operating at a\n different sensitivity level, this requirement permits the subject to pass the\n information to any subject at the same sensitivity level.\n\n The policy is bounded by the information system boundary. Once the\n information is passed outside of the control of the information system,\n additional means may be required to ensure the constraints remain in effect.\n While the older, more traditional definitions of discretionary access control\n require identity-based access control, that limitation is not required for this\n use of discretionary access control.","check":"Review the system documentation to obtain the definition of the\n database/DBMS functionality considered privileged in the context of the system\n in question.\n\n If any functionality considered privileged has access privileges granted to\n non-privileged users, this is a finding.","fix":"Revoke any roles with unnecessary privileges to privileged\n functionality by executing the revoke command as documented here:\n https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/\n\n Revoke any unnecessary privileges from any roles by executing the revoke\n command as document here:\n https://docs.mongodb.com/v3.4/reference/method/db.revokePrivilegesFromRole/\n\n If a new role with associated privileges needs to be created, follow the\n documentation here:\n https://docs.mongodb.com/v3.4/reference/command/createRole/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000328-DB-000301","satisfies":["SRG-APP-000328-DB-000301","SRG-APP-000340-DB-000304"],"gid":"V-81899","rid":"SV-96613r1_rule","stig_id":"MD3X-00-000570","fix_id":"F-88749r1_fix","cci":["CCI-002165","CCI-002235"],"nist":["AC-3 (4)","AC-6 (10)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81899' do\n title \"MongoDB must enforce discretionary access control policies, as defined\n by the data owner, over defined subjects and objects.\"\n desc \"Discretionary Access Control (DAC) is based on the notion that\n individual users are \\\"owners\\\" of objects and therefore have discretion over\n who should be authorized to access the object and in which mode (e.g., read or\n write). Ownership is usually acquired as a consequence of creating the object\n or via specified ownership assignment. DAC allows the owner to determine who\n will have access to objects they control. An example of DAC includes\n user-controlled table permissions.\n\n When discretionary access control policies are implemented, subjects are\n not constrained with regard to what actions they can take with information for\n which they have already been granted access. Thus, subjects that have been\n granted access to information are not prevented from passing (i.e., the\n subjects have the discretion to pass) the information to other subjects or\n objects.\n\n A subject that is constrained in its operation by Mandatory Access Control\n policies is still able to operate under the less rigorous constraints of this\n requirement. Thus, while Mandatory Access Control imposes constraints\n preventing a subject from passing information to another subject operating at a\n different sensitivity level, this requirement permits the subject to pass the\n information to any subject at the same sensitivity level.\n\n The policy is bounded by the information system boundary. Once the\n information is passed outside of the control of the information system,\n additional means may be required to ensure the constraints remain in effect.\n While the older, more traditional definitions of discretionary access control\n require identity-based access control, that limitation is not required for this\n use of discretionary access control.\n \"\n\n desc 'check', \"Review the system documentation to obtain the definition of the\n database/DBMS functionality considered privileged in the context of the system\n in question.\n\n If any functionality considered privileged has access privileges granted to\n non-privileged users, this is a finding.\"\n desc 'fix', \"Revoke any roles with unnecessary privileges to privileged\n functionality by executing the revoke command as documented here:\n https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/\n\n Revoke any unnecessary privileges from any roles by executing the revoke\n command as document here:\n https://docs.mongodb.com/v3.4/reference/method/db.revokePrivilegesFromRole/\n\n If a new role with associated privileges needs to be created, follow the\n documentation here:\n https://docs.mongodb.com/v3.4/reference/command/createRole/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000328-DB-000301'\n tag \"satisfies\": %w(SRG-APP-000328-DB-000301 SRG-APP-000340-DB-000304)\n tag \"gid\": 'V-81899'\n tag \"rid\": 'SV-96613r1_rule'\n tag \"stig_id\": 'MD3X-00-000570'\n tag \"fix_id\": 'F-88749r1_fix'\n tag \"cci\": %w(CCI-002165 CCI-002235)\n tag \"nist\": ['AC-3 (4)', 'AC-6 (10)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to determine if any functionality considered privileged has access privileges granted to non-privileged users' do\n skip 'A manual review is required to determine if any functionality considered privileged has access privileges granted to non-privileged users'\n end\nend\n","source_location":{"ref":"./controls/V-81899.rb","line":1},"id":"V-81899"},{"title":"Unused database components, DBMS software, and database objects must\n be removed.","desc":"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.","descriptions":{"default":"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.","check":"Review the list of components and features installed with the\n MongoDB database.\n\n If unused components are installed and are not documented and authorized, this\n is a finding.\n\n RPM can also be used to check to see what is installed:\n\n yum list installed | grep mongodb\n\n This returns MongoDB database packages that have been installed.\n\n If any packages displayed by this command are not being used, this is a\n finding.","fix":"On data-bearing nodes and arbiter nodes, the\n mongodb-enterprise-tools, mongodb-enterprise-shell and\n mongodb-enterprise-mongos can be removed (or not installed).\n\n On applications servers that typically run the mongos process when connecting\n to a shared cluster, the only package required is the mongodb-enterprise-mongos\n package."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000141-DB-000091","gid":"V-81859","rid":"SV-96573r1_rule","stig_id":"MD3X-00-000280","fix_id":"F-88709r1_fix","cci":["CCI-000381"],"nist":["CM-7 a"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81859' do\n title \"Unused database components, DBMS software, and database objects must\n be removed.\"\n desc \"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.\n \"\n\n desc 'check', \"Review the list of components and features installed with the\n MongoDB database.\n\n If unused components are installed and are not documented and authorized, this\n is a finding.\n\n RPM can also be used to check to see what is installed:\n\n yum list installed | grep mongodb\n\n This returns MongoDB database packages that have been installed.\n\n If any packages displayed by this command are not being used, this is a\n finding.\"\n desc 'fix', \"On data-bearing nodes and arbiter nodes, the\n mongodb-enterprise-tools, mongodb-enterprise-shell and\n mongodb-enterprise-mongos can be removed (or not installed).\n\n On applications servers that typically run the mongos process when connecting\n to a shared cluster, the only package required is the mongodb-enterprise-mongos\n package.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000141-DB-000091'\n tag \"gid\": 'V-81859'\n tag \"rid\": 'SV-96573r1_rule'\n tag \"stig_id\": 'MD3X-00-000280'\n tag \"fix_id\": 'F-88709r1_fix'\n tag \"cci\": ['CCI-000381']\n tag \"nist\": ['CM-7 a']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n approved_mongo_packages = input('approved_mongo_packages')\n\n dpkg_packages = packages(/mongodb/).names\n if dpkg_packages.empty?\n describe 'There are no mongo database packages installed, therefore for this control is NA' do\n skip 'There are no mongo database packages installed, therefore for this control is NA'\n end\n else\n dpkg_packages.each do |package|\n describe \"The installed mongodb package: #{package}\" do\n subject { package }\n it { should be_in approved_mongo_packages }\n end\n end\n end\nend\n","source_location":{"ref":"./controls/V-81859.rb","line":1},"id":"V-81859"},{"title":"MongoDB must maintain the confidentiality and integrity of information\n during preparation for transmission.","desc":"Information can be either unintentionally or maliciously disclosed or\n modified during preparation for transmission, including, for example, during\n aggregation, at protocol transformation points, and during packing/unpacking.\n These unauthorized disclosures or modifications compromise the confidentiality\n or integrity of the information.\n\n Use of this requirement will be limited to situations where the data owner\n has a strict requirement for ensuring data integrity and confidentiality is\n maintained at every step of the data transfer and handling process.\n\n When transmitting data, MongoDB, associated applications, and\n infrastructure must leverage transmission protection mechanisms.","descriptions":{"default":"Information can be either unintentionally or maliciously disclosed or\n modified during preparation for transmission, including, for example, during\n aggregation, at protocol transformation points, and during packing/unpacking.\n These unauthorized disclosures or modifications compromise the confidentiality\n or integrity of the information.\n\n Use of this requirement will be limited to situations where the data owner\n has a strict requirement for ensuring data integrity and confidentiality is\n maintained at every step of the data transfer and handling process.\n\n When transmitting data, MongoDB, associated applications, and\n infrastructure must leverage transmission protection mechanisms.","check":"Review the system information/specification for information\n indicating a strict requirement for data integrity and confidentiality when\n data is being prepared to be transmitted.\n\n If such information is absent therein, this is not a finding.\n\n If such information is present, inspect the MongoDB configuration file (default\n location: /etc/mongod.conf) for the following entries:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n If net.ssl.mode is not set to \"requireSSL\", this is a finding.","fix":"Stop the MongoDB instance if it is running. Obtain a certificate\n from a valid DoD certificate authority to be used for encrypted data\n transmission. Modify the MongoDB configuration file with ssl configuration\n options such as:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n Set \"net.ssl.mode\" to the \"requireSSL\".\n Set \"net.ssl.KeyFile\" to the full path of the certificate (.pem) file.\n\n Start/stop (restart) all mongod or mongos instances using the MongoDB\n configuration file (default location: /etc/mongod.conf)."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000441-DB-000378","gid":"V-81921","rid":"SV-96635r1_rule","stig_id":"MD3X-00-000760","fix_id":"F-88771r1_fix","cci":["CCI-002420"],"nist":["SC-8 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81921' do\n title \"MongoDB must maintain the confidentiality and integrity of information\n during preparation for transmission.\"\n desc \"Information can be either unintentionally or maliciously disclosed or\n modified during preparation for transmission, including, for example, during\n aggregation, at protocol transformation points, and during packing/unpacking.\n These unauthorized disclosures or modifications compromise the confidentiality\n or integrity of the information.\n\n Use of this requirement will be limited to situations where the data owner\n has a strict requirement for ensuring data integrity and confidentiality is\n maintained at every step of the data transfer and handling process.\n\n When transmitting data, MongoDB, associated applications, and\n infrastructure must leverage transmission protection mechanisms.\n \"\n\n desc 'check', \"Review the system information/specification for information\n indicating a strict requirement for data integrity and confidentiality when\n data is being prepared to be transmitted.\n\n If such information is absent therein, this is not a finding.\n\n If such information is present, inspect the MongoDB configuration file (default\n location: /etc/mongod.conf) for the following entries:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n If net.ssl.mode is not set to \\\"requireSSL\\\", this is a finding.\"\n desc 'fix', \"Stop the MongoDB instance if it is running. Obtain a certificate\n from a valid DoD certificate authority to be used for encrypted data\n transmission. Modify the MongoDB configuration file with ssl configuration\n options such as:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n Set \\\"net.ssl.mode\\\" to the \\\"requireSSL\\\".\n Set \\\"net.ssl.KeyFile\\\" to the full path of the certificate (.pem) file.\n\n Start/stop (restart) all mongod or mongos instances using the MongoDB\n configuration file (default location: /etc/mongod.conf).\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000441-DB-000378'\n tag \"gid\": 'V-81921'\n tag \"rid\": 'SV-96635r1_rule'\n tag \"stig_id\": 'MD3X-00-000760'\n tag \"fix_id\": 'F-88771r1_fix'\n tag \"cci\": ['CCI-002420']\n tag \"nist\": ['SC-8 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl mode)) { should cmp 'requireSSL' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl PEMKeyFile)) { should_not be nil }\n end\nend\n","source_location":{"ref":"./controls/V-81921.rb","line":1},"id":"V-81921"},{"title":"MongoDB must use NIST FIPS 140-2-validated cryptographic modules for\n cryptographic operations.","desc":"Use of weak or not validated cryptographic algorithms undermines the\n purposes of utilizing encryption and digital signatures to protect data. Weak\n algorithms can be easily broken and not validated cryptographic modules may not\n implement algorithms correctly. Unapproved cryptographic modules or algorithms\n should not be relied on for authentication, confidentiality, or integrity. Weak\n cryptography could allow an attacker to gain access to and modify data stored\n in the database as well as the administration settings of MongoDB.\n\n Applications, including DBMSs, utilizing cryptography are required to use\n approved NIST FIPS 140-2-validated cryptographic modules that meet the\n requirements of applicable federal laws, Executive Orders, directives,\n policies, regulations, standards, and guidance.\n\n The security functions validated as part of FIPS 140-2 for cryptographic\n modules are described in FIPS 140-2 Annex A.\n\n NSA Type-X (where X=1, 2, 3, 4) products are NSA-certified, hardware-based\n encryption modules.","descriptions":{"default":"Use of weak or not validated cryptographic algorithms undermines the\n purposes of utilizing encryption and digital signatures to protect data. Weak\n algorithms can be easily broken and not validated cryptographic modules may not\n implement algorithms correctly. Unapproved cryptographic modules or algorithms\n should not be relied on for authentication, confidentiality, or integrity. Weak\n cryptography could allow an attacker to gain access to and modify data stored\n in the database as well as the administration settings of MongoDB.\n\n Applications, including DBMSs, utilizing cryptography are required to use\n approved NIST FIPS 140-2-validated cryptographic modules that meet the\n requirements of applicable federal laws, Executive Orders, directives,\n policies, regulations, standards, and guidance.\n\n The security functions validated as part of FIPS 140-2 for cryptographic\n modules are described in FIPS 140-2 Annex A.\n\n NSA Type-X (where X=1, 2, 3, 4) products are NSA-certified, hardware-based\n encryption modules.","check":"If MongoDB is deployed in a classified environment:\n\n In the MongoDB database configuration file (default location:\n /etc/mongod.conf), search for and review the following parameters:\n\n net:\n ssl:\n FIPSMode: true\n\n If this parameter is not present in the configuration file, this is a finding.\n\n If \"FIPSMode\" is set to \"false\", this is a finding.\n\n Check the server log file for a message that FIPS is active:\n Search the log for the following text \"\"FIPS 140-2 mode activated\"\".\n\n If this text is not found, this is a finding.\n\n Verify that FIPS has been enabled at the operating system. The following will\n return \"1\" if FIPS is enabled:\n cat /proc/sys/crypto/fips_enabled\n\n If the above command does not return \"1\", this is a finding.","fix":"Enable FIPS 140-2 mode for MongoDB Enterprise.\n\n Edit the MongoDB database configuration file (default location:\n /etc/mongod.conf) to contain the following parameter setting:\n\n net:\n ssl:\n FIPSMode: true\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\n\n For the operating system finding, please refer to the appropriate operating\n system documentation for the procedure to install, configure, and test FIPS\n mode."},"impact":0.7,"refs":[],"tags":{"severity":"high","gtitle":"SRG-APP-000179-DB-000114","satisfies":["SRG-APP-000179-DB-000114","SRG-APP-000514-DB-000381","SRG-APP-000514-DB-000382","SRG-APP-000514-DB-000383","SRG-APP-000416-DB-000380"],"gid":"V-81875","rid":"SV-96589r1_rule","stig_id":"MD3X-00-000380","fix_id":"F-88725r1_fix","cci":["CCI-000803","CCI-002450"],"nist":["IA-7","SC-13"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81875' do\n title \"MongoDB must use NIST FIPS 140-2-validated cryptographic modules for\n cryptographic operations.\"\n desc \"Use of weak or not validated cryptographic algorithms undermines the\n purposes of utilizing encryption and digital signatures to protect data. Weak\n algorithms can be easily broken and not validated cryptographic modules may not\n implement algorithms correctly. Unapproved cryptographic modules or algorithms\n should not be relied on for authentication, confidentiality, or integrity. Weak\n cryptography could allow an attacker to gain access to and modify data stored\n in the database as well as the administration settings of MongoDB.\n\n Applications, including DBMSs, utilizing cryptography are required to use\n approved NIST FIPS 140-2-validated cryptographic modules that meet the\n requirements of applicable federal laws, Executive Orders, directives,\n policies, regulations, standards, and guidance.\n\n The security functions validated as part of FIPS 140-2 for cryptographic\n modules are described in FIPS 140-2 Annex A.\n\n NSA Type-X (where X=1, 2, 3, 4) products are NSA-certified, hardware-based\n encryption modules.\n \"\n\n desc 'check', \"If MongoDB is deployed in a classified environment:\n\n In the MongoDB database configuration file (default location:\n /etc/mongod.conf), search for and review the following parameters:\n\n net:\n ssl:\n FIPSMode: true\n\n If this parameter is not present in the configuration file, this is a finding.\n\n If \\\"FIPSMode\\\" is set to \\\"false\\\", this is a finding.\n\n Check the server log file for a message that FIPS is active:\n Search the log for the following text \\\"\\\"FIPS 140-2 mode activated\\\"\\\".\n\n If this text is not found, this is a finding.\n\n Verify that FIPS has been enabled at the operating system. The following will\n return \\\"1\\\" if FIPS is enabled:\n cat /proc/sys/crypto/fips_enabled\n\n If the above command does not return \\\"1\\\", this is a finding.\"\n desc 'fix', \"Enable FIPS 140-2 mode for MongoDB Enterprise.\n\n Edit the MongoDB database configuration file (default location:\n /etc/mongod.conf) to contain the following parameter setting:\n\n net:\n ssl:\n FIPSMode: true\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\n\n For the operating system finding, please refer to the appropriate operating\n system documentation for the procedure to install, configure, and test FIPS\n mode.\"\n\n impact 0.7\n tag \"severity\": 'high'\n tag \"gtitle\": 'SRG-APP-000179-DB-000114'\n tag \"satisfies\": %w(SRG-APP-000179-DB-000114 SRG-APP-000514-DB-000381\n SRG-APP-000514-DB-000382 SRG-APP-000514-DB-000383\n SRG-APP-000416-DB-000380)\n tag \"gid\": 'V-81875'\n tag \"rid\": 'SV-96589r1_rule'\n tag \"stig_id\": 'MD3X-00-000380'\n tag \"fix_id\": 'F-88725r1_fix'\n tag \"cci\": %w(CCI-000803 CCI-002450)\n tag \"nist\": %w(IA-7 SC-13)\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n if input('is_sensitive')\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl FIPSMode)) { should cmp 'true' }\n end\n else\n describe 'The system is not a classified environment, therefore for this control is NA' do\n skip 'The system is not a classified environment, therefore for this control is NA'\n end\n end\nend\n","source_location":{"ref":"./controls/V-81875.rb","line":1},"id":"V-81875"},{"title":"MongoDB must obscure feedback of authentication information during the\n authentication process to protect the information from possible\n exploitation/use by unauthorized individuals.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n\n Normally, with PKI authentication, the interaction with the user for\n authentication will be handled by a software component separate from MongoDB,\n such as ActivIdentity ActivClient. However, in cases where MongoDB controls the\n interaction, this requirement applies.\n\n To prevent the compromise of authentication information such as passwords\n and PINs during the authentication process, the feedback from the system must\n not provide any information that would allow an unauthorized user to compromise\n the authentication mechanism.\n\n Obfuscation of user-provided authentication secrets when typed into the\n system is a method used in addressing this risk.\n\n Displaying asterisks when a user types in a password or a smart card PIN is\n an example of obscuring feedback of authentication secrets.\n\n This calls for review of applications, which will require collaboration\n with the application developers. It is recognized that in many cases, the\n database administrator (DBA) is organizationally separate from the application\n developers, and may have limited, if any, access to source code. Nevertheless,\n protections of this type are so important to the secure operation of databases\n that they must not be ignored. At a minimum, the DBA must attempt to obtain\n assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n\n Normally, with PKI authentication, the interaction with the user for\n authentication will be handled by a software component separate from MongoDB,\n such as ActivIdentity ActivClient. However, in cases where MongoDB controls the\n interaction, this requirement applies.\n\n To prevent the compromise of authentication information such as passwords\n and PINs during the authentication process, the feedback from the system must\n not provide any information that would allow an unauthorized user to compromise\n the authentication mechanism.\n\n Obfuscation of user-provided authentication secrets when typed into the\n system is a method used in addressing this risk.\n\n Displaying asterisks when a user types in a password or a smart card PIN is\n an example of obscuring feedback of authentication secrets.\n\n This calls for review of applications, which will require collaboration\n with the application developers. It is recognized that in many cases, the\n database administrator (DBA) is organizationally separate from the application\n developers, and may have limited, if any, access to source code. Nevertheless,\n protections of this type are so important to the secure operation of databases\n that they must not be ignored. At a minimum, the DBA must attempt to obtain\n assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"For the MongoDB command-line tools \"mongo shell\",\n \"mongodump\", \"mongorestore\", \"mongoimport\", \"mongoexport\", which cannot\n be configured not to accept a plain-text password, and any other essential tool\n with the same limitation, verify that the system documentation explains the\n need for the tool, who uses it, and any relevant mitigations and that AO\n approval has been obtained.\n\n If it is not documented, this is a finding.\n\n Request evidence that all users of these MongoDB command-line tools are trained\n in the use of the \"-p\" option plain-text password option and how to keep the\n password protected from unauthorized viewing/capture and that they adhere to\n this practice.\n\n If evidence of training does not exist, this is a finding.","fix":"For the \"mongo shell\", \"mongodump\", \"mongorestore\",\n \"mongoimport\", \"mongoexport\", which can accept a plain-text password, and\n any other essential tool with the same limitation:\n\n Document the need for it, who uses it, and any relevant mitigations, and obtain\n AO approval.\n\n Train all users of the tool in the nature of using the plain-text password\n option and in how to keep the password protected from unauthorized\n viewing/capture and document they have been trained."},"impact":0.7,"refs":[],"tags":{"severity":"high","gtitle":"SRG-APP-000178-DB-000083","gid":"V-81927","rid":"SV-96641r1_rule","stig_id":"MD3X-00-000800","fix_id":"F-88777r1_fix","cci":["CCI-000206"],"nist":["IA-6"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81927' do\n title \"MongoDB must obscure feedback of authentication information during the\n authentication process to protect the information from possible\n exploitation/use by unauthorized individuals.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n\n Normally, with PKI authentication, the interaction with the user for\n authentication will be handled by a software component separate from MongoDB,\n such as ActivIdentity ActivClient. However, in cases where MongoDB controls the\n interaction, this requirement applies.\n\n To prevent the compromise of authentication information such as passwords\n and PINs during the authentication process, the feedback from the system must\n not provide any information that would allow an unauthorized user to compromise\n the authentication mechanism.\n\n Obfuscation of user-provided authentication secrets when typed into the\n system is a method used in addressing this risk.\n\n Displaying asterisks when a user types in a password or a smart card PIN is\n an example of obscuring feedback of authentication secrets.\n\n This calls for review of applications, which will require collaboration\n with the application developers. It is recognized that in many cases, the\n database administrator (DBA) is organizationally separate from the application\n developers, and may have limited, if any, access to source code. Nevertheless,\n protections of this type are so important to the secure operation of databases\n that they must not be ignored. At a minimum, the DBA must attempt to obtain\n assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"For the MongoDB command-line tools \\\"mongo shell\\\",\n \\\"mongodump\\\", \\\"mongorestore\\\", \\\"mongoimport\\\", \\\"mongoexport\\\", which cannot\n be configured not to accept a plain-text password, and any other essential tool\n with the same limitation, verify that the system documentation explains the\n need for the tool, who uses it, and any relevant mitigations and that AO\n approval has been obtained.\n\n If it is not documented, this is a finding.\n\n Request evidence that all users of these MongoDB command-line tools are trained\n in the use of the \\\"-p\\\" option plain-text password option and how to keep the\n password protected from unauthorized viewing/capture and that they adhere to\n this practice.\n\n If evidence of training does not exist, this is a finding.\"\n desc 'fix', \"For the \\\"mongo shell\\\", \\\"mongodump\\\", \\\"mongorestore\\\",\n \\\"mongoimport\\\", \\\"mongoexport\\\", which can accept a plain-text password, and\n any other essential tool with the same limitation:\n\n Document the need for it, who uses it, and any relevant mitigations, and obtain\n AO approval.\n\n Train all users of the tool in the nature of using the plain-text password\n option and in how to keep the password protected from unauthorized\n viewing/capture and document they have been trained.\"\n\n impact 0.7\n tag \"severity\": 'high'\n tag \"gtitle\": 'SRG-APP-000178-DB-000083'\n tag \"gid\": 'V-81927'\n tag \"rid\": 'SV-96641r1_rule'\n tag \"stig_id\": 'MD3X-00-000800'\n tag \"fix_id\": 'F-88777r1_fix'\n tag \"cci\": ['CCI-000206']\n tag \"nist\": ['IA-6']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n tools = %w(mongo mongodump mongorestore mongoimport mongoexport)\n\n installed_tools = []\n\n tools.each do |tool|\n if command(tool).exist?\n installed_tools << tool\n end\n end\n\n describe \"Manually review that the use presence of tools `#{installed_tools}.to_s` is authorized and the users have the required training.\" do\n skip\n end\nend\n","source_location":{"ref":"./controls/V-81927.rb","line":1},"id":"V-81927"},{"title":"MongoDB must provide audit record generation for DoD-defined auditable\n events within all DBMS/database components.","desc":"MongoDB must provide audit record generation capability for\n DoD-defined auditable events within all DBMS/database components.","descriptions":{"default":"MongoDB must provide audit record generation capability for\n DoD-defined auditable events within all DBMS/database components.","check":"Check the MongoDB configuration file (default location:\n '/etc/mongod.conf)' for a key named 'auditLog:'.\n\n Example shown below:\n\n auditLog:\n destination: syslog\n\n If an \"auditLog:\" key is not present, this is a finding indicating that\n auditing is not turned on.\n\n If the \"auditLog:\" key is present and contains a subkey of \"filter:\" with\n an associated filter value string, this is a finding.\n\n The site auditing policy must be reviewed to determine if the \"filter:\" being\n applied meets the site auditing requirements. If not, then the filter being\n applied will need to be modified to comply.\n\n Example show below:\n\n auditLog:\n destination: syslog\n filter: '{ atype: { $in: [ \"createCollection\", \"dropCollection\" ] } }'","fix":"If the \"auditLog\" setting was not present in the MongoDB\n configuration file (default location: '/etc/mongod.conf)' edit this file and\n add a configured \"auditLog\" setting:\n\n auditLog:\n destination: syslog\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\n\n If the \"auditLog\" setting was present and contained a \"filter:\" parameter,\n ensure the \"filter:\" expression does not prevent the auditing of events that\n should be audited or remove the \"filter:\" parameter to enable auditing all\n events."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000089-DB-000064","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-000093-DB-000052","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"],"gid":"V-81847","rid":"SV-96561r1_rule","stig_id":"MD3X-00-000040","fix_id":"F-88697r1_fix","cci":["CCI-000130","CCI-000131","CCI-000132","CCI-000133","CCI-000134","CCI-000135","CCI-000140","CCI-000166","CCI-000171","CCI-000172","CCI-001462","CCI-001464","CCI-001487","CCI-001814","CCI-001844","CCI-001851","CCI-001858"],"nist":["AU-3","AU-3","AU-3","AU-3","AU-3","AU-3 (1)","AU-5 b","AU-10","AU-12 b","AU-12 c","AU-14 (2)","AU-14 (1)","AU-3","CM-5 (1)","AU-3 (2)","AU-4 (1)","AU-5 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81847' do\n title \"MongoDB must provide audit record generation for DoD-defined auditable\n events within all DBMS/database components.\"\n desc \"MongoDB must provide audit record generation capability for\n DoD-defined auditable events within all DBMS/database components.\n \"\n desc 'check', \"Check the MongoDB configuration file (default location:\n '/etc/mongod.conf)' for a key named 'auditLog:'.\n\n Example shown below:\n\n auditLog:\n destination: syslog\n\n If an \\\"auditLog:\\\" key is not present, this is a finding indicating that\n auditing is not turned on.\n\n If the \\\"auditLog:\\\" key is present and contains a subkey of \\\"filter:\\\" with\n an associated filter value string, this is a finding.\n\n The site auditing policy must be reviewed to determine if the \\\"filter:\\\" being\n applied meets the site auditing requirements. If not, then the filter being\n applied will need to be modified to comply.\n\n Example show below:\n\n auditLog:\n destination: syslog\n filter: '{ atype: { $in: [ \\\"createCollection\\\", \\\"dropCollection\\\" ] } }'\"\n desc 'fix', \"If the \\\"auditLog\\\" setting was not present in the MongoDB\n configuration file (default location: '/etc/mongod.conf)' edit this file and\n add a configured \\\"auditLog\\\" setting:\n\n auditLog:\n destination: syslog\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\n\n If the \\\"auditLog\\\" setting was present and contained a \\\"filter:\\\" parameter,\n ensure the \\\"filter:\\\" expression does not prevent the auditing of events that\n should be audited or remove the \\\"filter:\\\" parameter to enable auditing all\n events.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000089-DB-000064'\n tag \"satisfies\": %w(SRG-APP-000089-DB-000064 SRG-APP-000080-DB-000063\n SRG-APP-000090-DB-000065 SRG-APP-000091-DB-000066\n SRG-APP-000091-DB-000325 SRG-APP-000092-DB-000208\n SRG-APP-000093-DB-000052 SRG-APP-000095-DB-000039\n SRG-APP-000096-DB-000040 SRG-APP-000097-DB-000041\n SRG-APP-000098-DB-000042 SRG-APP-000099-DB-000043\n SRG-APP-000100-DB-000201 SRG-APP-000101-DB-000044\n SRG-APP-000109-DB-000049 SRG-APP-000356-DB-000315\n SRG-APP-000360-DB-000320 SRG-APP-000381-DB-000361\n SRG-APP-000492-DB-000332 SRG-APP-000492-DB-000333\n SRG-APP-000494-DB-000344 SRG-APP-000494-DB-000345\n SRG-APP-000495-DB-000326 SRG-APP-000495-DB-000327\n SRG-APP-000495-DB-000328 SRG-APP-000495-DB-000329\n SRG-APP-000496-DB-000334 SRG-APP-000496-DB-000335\n SRG-APP-000498-DB-000346 SRG-APP-000498-DB-000347\n SRG-APP-000499-DB-000330 SRG-APP-000499-DB-000331\n SRG-APP-000501-DB-000336 SRG-APP-000501-DB-000337\n SRG-APP-000502-DB-000348 SRG-APP-000502-DB-000349\n SRG-APP-000503-DB-000350 SRG-APP-000503-DB-000351\n SRG-APP-000504-DB-000354 SRG-APP-000504-DB-000355\n SRG-APP-000505-DB-000352 SRG-APP-000506-DB-000353\n SRG-APP-000507-DB-000356 SRG-APP-000507-DB-000357\n SRG-APP-000508-DB-000358 SRG-APP-000515-DB-000318)\n tag \"gid\": 'V-81847'\n tag \"rid\": 'SV-96561r1_rule'\n tag \"stig_id\": 'MD3X-00-000040'\n tag \"fix_id\": 'F-88697r1_fix'\n tag \"cci\": %w(CCI-000130 CCI-000131 CCI-000132 CCI-000133\n CCI-000134 CCI-000135 CCI-000140 CCI-000166 CCI-000171\n CCI-000172 CCI-001462 CCI-001464 CCI-001487 CCI-001814\n CCI-001844 CCI-001851 CCI-001858)\n tag \"nist\": ['AU-3', 'AU-3', 'AU-3', 'AU-3', 'AU-3', 'AU-3 (1)', 'AU-5 b',\n 'AU-10', 'AU-12 b', 'AU-12 c', 'AU-14 (2)', 'AU-14 (1)', 'AU-3', 'CM-5 (1)',\n 'AU-3 (2)', 'AU-4 (1)', 'AU-5 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog destination)) { should cmp 'syslog' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog filter)) { should be_nil }\n end\nend\n","source_location":{"ref":"./controls/V-81847.rb","line":1},"id":"V-81847"},{"title":"MongoDB must protect the confidentiality and integrity of all\n information at rest.","desc":"This control is intended to address the confidentiality and integrity\n of information at rest in non-mobile devices and covers user information and\n system information. Information at rest refers to the state of information when\n it is located on a secondary storage device (e.g., disk drive, tape drive)\n within an organizational information system. Applications and application users\n generate information throughout the course of their application use.\n\n User data generated, as well as application-specific configuration data,\n needs to be protected. Organizations may choose to employ different mechanisms\n to achieve confidentiality and integrity protections, as appropriate.\n\n If the confidentiality and integrity of application data is not protected,\n the data will be open to compromise and unauthorized modification.","descriptions":{"default":"This control is intended to address the confidentiality and integrity\n of information at rest in non-mobile devices and covers user information and\n system information. Information at rest refers to the state of information when\n it is located on a secondary storage device (e.g., disk drive, tape drive)\n within an organizational information system. Applications and application users\n generate information throughout the course of their application use.\n\n User data generated, as well as application-specific configuration data,\n needs to be protected. Organizations may choose to employ different mechanisms\n to achieve confidentiality and integrity protections, as appropriate.\n\n If the confidentiality and integrity of application data is not protected,\n the data will be open to compromise and unauthorized modification.","check":"If the MongoDB Encrypted Storage Engines is being used, ensure\n that the \"security.enableEncryption\" option is set to \"true\" in the MongoDB\n configuration file (default location: /etc/mongod.conf) or that MongoDB was\n started with the \"--enableEncryption\" command line option.\n\n Check the MongoDB configuration file (default location: /etc/mongod.conf).\n\n If the following parameter is not present, this is a finding.\n\n security:\n enableEncryption: \"true\"\n\n If any mongod process is started with \"--enableEncryption false\", this is a\n finding.","fix":"Ensure that the MongoDB Configuration file (default location:\n /etc/mongod.conf) has the following set:\n\n security:\n enableEncryption: \"true\"\n\n Ensure that any mongod process that contains the option \"--enableEcryption\"\n has \"true\" as its parameter value (e.g., \"--enableEncryption\n true\").\n\n Stop/start (restart) and mongod process using either the MongoDB configuration\n file or that contains the \"--enableEncryption\" option."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000231-DB-000154","gid":"V-81883","rid":"SV-96597r1_rule","stig_id":"MD3X-00-000440","fix_id":"F-88733r1_fix","cci":["CCI-001199"],"nist":["SC-28"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81883' do\n title \"MongoDB must protect the confidentiality and integrity of all\n information at rest.\"\n desc \"This control is intended to address the confidentiality and integrity\n of information at rest in non-mobile devices and covers user information and\n system information. Information at rest refers to the state of information when\n it is located on a secondary storage device (e.g., disk drive, tape drive)\n within an organizational information system. Applications and application users\n generate information throughout the course of their application use.\n\n User data generated, as well as application-specific configuration data,\n needs to be protected. Organizations may choose to employ different mechanisms\n to achieve confidentiality and integrity protections, as appropriate.\n\n If the confidentiality and integrity of application data is not protected,\n the data will be open to compromise and unauthorized modification.\n \"\n\n desc 'check', \"If the MongoDB Encrypted Storage Engines is being used, ensure\n that the \\\"security.enableEncryption\\\" option is set to \\\"true\\\" in the MongoDB\n configuration file (default location: /etc/mongod.conf) or that MongoDB was\n started with the \\\"--enableEncryption\\\" command line option.\n\n Check the MongoDB configuration file (default location: /etc/mongod.conf).\n\n If the following parameter is not present, this is a finding.\n\n security:\n enableEncryption: \\\"true\\\"\n\n If any mongod process is started with \\\"--enableEncryption false\\\", this is a\n finding.\"\n desc 'fix', \"Ensure that the MongoDB Configuration file (default location:\n /etc/mongod.conf) has the following set:\n\n security:\n enableEncryption: \\\"true\\\"\n\n Ensure that any mongod process that contains the option \\\"--enableEcryption\\\"\n has \\\"true\\\" as its parameter value (e.g., \\\"--enableEncryption\n true\\\").\n\n Stop/start (restart) and mongod process using either the MongoDB configuration\n file or that contains the \\\"--enableEncryption\\\" option.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000231-DB-000154'\n tag \"gid\": 'V-81883'\n tag \"rid\": 'SV-96597r1_rule'\n tag \"stig_id\": 'MD3X-00-000440'\n tag \"fix_id\": 'F-88733r1_fix'\n tag \"cci\": ['CCI-001199']\n tag \"nist\": ['SC-28']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe.one do\n describe yaml(input('mongod_conf')) do\n its(%w(security enableEncryption)) { should cmp 'true' }\n end\n describe processes('mongod') do\n its('commands.join') { should match /--enableEncryption true/ }\n end\n end\n\n describe processes('mongod') do\n its('commands.join') { should_not match /--enableEncryption false/ }\n end\nend\n","source_location":{"ref":"./controls/V-81883.rb","line":1},"id":"V-81883"},{"title":"MongoDB must utilize centralized management of the content captured in\n audit records generated by all components of MongoDB.","desc":"Without the ability to centrally manage the content captured in the\n audit records, identification, troubleshooting, and correlation of suspicious\n behavior would be difficult and could lead to a delayed or incomplete analysis\n of an ongoing attack.\n\n The content captured in audit records must be managed from a central\n location (necessitating automation). Centralized management of audit records\n and logs provides for efficiency in maintenance and management of records, as\n well as the backup and archiving of those records.\n\n MongoDB may write audit records to database tables, to files in the file\n system, to other kinds of local repository, or directly to a centralized log\n management system. Whatever the method used, it must be compatible with\n off-loading the records to the centralized system.","descriptions":{"default":"Without the ability to centrally manage the content captured in the\n audit records, identification, troubleshooting, and correlation of suspicious\n behavior would be difficult and could lead to a delayed or incomplete analysis\n of an ongoing attack.\n\n The content captured in audit records must be managed from a central\n location (necessitating automation). Centralized management of audit records\n and logs provides for efficiency in maintenance and management of records, as\n well as the backup and archiving of those records.\n\n MongoDB may write audit records to database tables, to files in the file\n system, to other kinds of local repository, or directly to a centralized log\n management system. Whatever the method used, it must be compatible with\n off-loading the records to the centralized system.","check":"MongoDB can be configured to write audit events to the syslog\n in Linux, but this is not available in Windows. Audit events can also be\n written to a file in either JSON on BSON format. Through the use of third-party\n tools or via syslog directly, audit records can be pushed to a centralized log\n management system.\n\n If a centralized tool for log management is not installed and configured to\n collect audit logs or syslogs, this is a finding.","fix":"Install a centralized syslog collecting tool and configured it as\n instructed in its documentation.\n\n To enable auditing and print audit events to the syslog in JSON format, specify\n the syslog for the --auditDestination setting:\n mongod --dbpath /data/db --auditDestination syslog\n\n Alternatively, these options can also be specified in the configuration file:\n storage:\n dbPath: /data/db\n auditLog:\n destination: syslog"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000356-DB-000314","gid":"V-81903","rid":"SV-96617r1_rule","stig_id":"MD3X-00-000600","fix_id":"F-88753r1_fix","cci":["CCI-001844"],"nist":["AU-3 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81903' do\n title \"MongoDB must utilize centralized management of the content captured in\n audit records generated by all components of MongoDB.\"\n desc \"Without the ability to centrally manage the content captured in the\n audit records, identification, troubleshooting, and correlation of suspicious\n behavior would be difficult and could lead to a delayed or incomplete analysis\n of an ongoing attack.\n\n The content captured in audit records must be managed from a central\n location (necessitating automation). Centralized management of audit records\n and logs provides for efficiency in maintenance and management of records, as\n well as the backup and archiving of those records.\n\n MongoDB may write audit records to database tables, to files in the file\n system, to other kinds of local repository, or directly to a centralized log\n management system. Whatever the method used, it must be compatible with\n off-loading the records to the centralized system.\n \"\n\n desc 'check', \"MongoDB can be configured to write audit events to the syslog\n in Linux, but this is not available in Windows. Audit events can also be\n written to a file in either JSON on BSON format. Through the use of third-party\n tools or via syslog directly, audit records can be pushed to a centralized log\n management system.\n\n If a centralized tool for log management is not installed and configured to\n collect audit logs or syslogs, this is a finding.\"\n desc 'fix', \"Install a centralized syslog collecting tool and configured it as\n instructed in its documentation.\n\n To enable auditing and print audit events to the syslog in JSON format, specify\n the syslog for the --auditDestination setting:\n mongod --dbpath /data/db --auditDestination syslog\n\n Alternatively, these options can also be specified in the configuration file:\n storage:\n dbPath: /data/db\n auditLog:\n destination: syslog\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000356-DB-000314'\n tag \"gid\": 'V-81903'\n tag \"rid\": 'SV-96617r1_rule'\n tag \"stig_id\": 'MD3X-00-000600'\n tag \"fix_id\": 'F-88753r1_fix'\n tag \"cci\": ['CCI-001844']\n tag \"nist\": ['AU-3 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe.one do\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog destination)) { should cmp 'syslog' }\n end\n describe processes('mongod') do\n its('commands.join') { should match /--auditDestination syslog/ }\n end\n end\nend\n","source_location":{"ref":"./controls/V-81903.rb","line":1},"id":"V-81903"},{"title":"Unused database components that are integrated in MongoDB and cannot\n be uninstalled must be disabled.","desc":"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.\n\n Unused, unnecessary DBMS components increase the attack vector for MongoDB\n by introducing additional targets for attack. By minimizing the services and\n applications installed on the system, the number of potential vulnerabilities\n is reduced. Components of the system that are unused and cannot be uninstalled\n must be disabled. The techniques available for disabling components will vary\n by DBMS product, OS, and the nature of the component and may include DBMS\n configuration settings, OS service settings, OS file access security, and DBMS\n user/role permissions.","descriptions":{"default":"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.\n\n Unused, unnecessary DBMS components increase the attack vector for MongoDB\n by introducing additional targets for attack. By minimizing the services and\n applications installed on the system, the number of potential vulnerabilities\n is reduced. Components of the system that are unused and cannot be uninstalled\n must be disabled. The techniques available for disabling components will vary\n by DBMS product, OS, and the nature of the component and may include DBMS\n configuration settings, OS service settings, OS file access security, and DBMS\n user/role permissions.","check":"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), review the following parameters:\n\n net:\n http:\n enabled: true\n JSONPEnabled: true\n RESTInterfaceEnabled: true\n\n If any of the are \"True\" or \"Enabled\", this is a finding.","fix":"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), ensure the following parameters either:\n\n Does not exist in the file\n OR\n Are set to \"false\" as shown below:\n\n http:\n enabled: false\n JSONPEnabled: false\n RESTInterfaceEnabled: false"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000141-DB-000092","satisfies":["SRG-APP-000141-DB-000092","SRG-APP-000142-DB-000094"],"gid":"V-81861","rid":"SV-96575r1_rule","stig_id":"MD3X-00-000290","fix_id":"F-88711r1_fix","cci":["CCI-000381","CCI-000382"],"nist":["CM-7 a","CM-7 b"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81861' do\n title \"Unused database components that are integrated in MongoDB and cannot\n be uninstalled must be disabled.\"\n desc \"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.\n\n Unused, unnecessary DBMS components increase the attack vector for MongoDB\n by introducing additional targets for attack. By minimizing the services and\n applications installed on the system, the number of potential vulnerabilities\n is reduced. Components of the system that are unused and cannot be uninstalled\n must be disabled. The techniques available for disabling components will vary\n by DBMS product, OS, and the nature of the component and may include DBMS\n configuration settings, OS service settings, OS file access security, and DBMS\n user/role permissions.\n \"\n\n desc 'check', \"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), review the following parameters:\n\n net:\n http:\n enabled: true\n JSONPEnabled: true\n RESTInterfaceEnabled: true\n\n If any of the are \\\"True\\\" or \\\"Enabled\\\", this is a finding.\"\n desc 'fix', \"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), ensure the following parameters either:\n\n Does not exist in the file\n OR\n Are set to \\\"false\\\" as shown below:\n\n http:\n enabled: false\n JSONPEnabled: false\n RESTInterfaceEnabled: false\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000141-DB-000092'\n tag \"satisfies\": %w(SRG-APP-000141-DB-000092 SRG-APP-000142-DB-000094)\n tag \"gid\": 'V-81861'\n tag \"rid\": 'SV-96575r1_rule'\n tag \"stig_id\": 'MD3X-00-000290'\n tag \"fix_id\": 'F-88711r1_fix'\n tag \"cci\": %w(CCI-000381 CCI-000382)\n tag \"nist\": ['CM-7 a', 'CM-7 b']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_conf_file = input('mongod_conf').to_s\n describe.one do\n describe yaml(mongo_conf_file) do\n its(%w(net http enabled)) { should cmp 'false' }\n end\n describe yaml(mongo_conf_file) do\n its(%w(net http enabled)) { should be_nil }\n end\n end\n\n describe.one do\n describe yaml(mongo_conf_file) do\n its(%w(net http JSONPEnabled)) { should cmp 'false' }\n end\n describe yaml(mongo_conf_file) do\n its(%w(net http JSONPEnabled)) { should be_nil }\n end\n end\n\n describe.one do\n describe yaml(mongo_conf_file) do\n its(%w(net http RESTInterfaceEnabled)) { should cmp 'false' }\n end\n describe yaml(mongo_conf_file) do\n its(%w(net http RESTInterfaceEnabled)) { should be_nil }\n end\n end\nend\n","source_location":{"ref":"./controls/V-81861.rb","line":1},"id":"V-81861"},{"title":"MongoDB must reveal detailed error messages only to the ISSO, ISSM,\n SA, and DBA.","desc":"If MongoDB provides too much information in error logs and\n administrative messages to the screen, this could lead to compromise. The\n structure and content of error messages need to be carefully considered by the\n organization and development team. The extent to which the information system\n is able to identify and handle error conditions is guided by organizational\n policy and operational requirements.\n\n Some default DBMS error messages can contain information that could aid an\n attacker in, among others things, identifying the database type, host address,\n or state of the database. Custom errors may contain sensitive customer\n information.\n\n It is important that detailed error messages be visible only to those who\n are authorized to view them; that general users receive only generalized\n acknowledgment that errors have occurred; and that these generalized messages\n appear only when relevant to the user's task. For example, a message along the\n lines of, \"An error has occurred. Unable to save your changes. If this problem\n persists, contact your help desk\" would be relevant. A message such as\n \"Warning: your transaction generated a large number of page splits\" would\n likely not be relevant.\n\n Administrative users authorized to review detailed error messages typically\n are the ISSO, ISSM, SA, and DBA. Other individuals or roles may be specified\n according to organization-specific needs, with appropriate approval.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"If MongoDB provides too much information in error logs and\n administrative messages to the screen, this could lead to compromise. The\n structure and content of error messages need to be carefully considered by the\n organization and development team. The extent to which the information system\n is able to identify and handle error conditions is guided by organizational\n policy and operational requirements.\n\n Some default DBMS error messages can contain information that could aid an\n attacker in, among others things, identifying the database type, host address,\n or state of the database. Custom errors may contain sensitive customer\n information.\n\n It is important that detailed error messages be visible only to those who\n are authorized to view them; that general users receive only generalized\n acknowledgment that errors have occurred; and that these generalized messages\n appear only when relevant to the user's task. For example, a message along the\n lines of, \"An error has occurred. Unable to save your changes. If this problem\n persists, contact your help desk\" would be relevant. A message such as\n \"Warning: your transaction generated a large number of page splits\" would\n likely not be relevant.\n\n Administrative users authorized to review detailed error messages typically\n are the ISSO, ISSM, SA, and DBA. Other individuals or roles may be specified\n according to organization-specific needs, with appropriate approval.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"A mongod or mongos running with\n \"security.redactClientLogData\" redacts any message accompanying a given log\n event before logging.\n\n This prevents the mongod or mongos from writing potentially sensitive data\n stored on the database to the diagnostic log. Metadata such as error or\n operation codes, line numbers, and source file names are still visible in the\n logs.\n\n Verify that the MongoDB configuration file (default location: /etc/mongod.conf)\n contains the following:\n\n security:\n redactClientLogData: \"true\"\n\n If this parameter is not present, this is a finding.","fix":"Edit the MongoDB configuration file (default location:\n /etc/mongod.conf) and add the following parameter \"redactClientLogData\" in\n the security section of that file:\n\n security:\n redactClientLogData: \"true\"\n\n Stop/start (restart) any mongod or mongos using the MongoDB configuration file."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000267-DB-000163","gid":"V-81895","rid":"SV-96609r1_rule","stig_id":"MD3X-00-000530","fix_id":"F-88745r1_fix","cci":["CCI-001314"],"nist":["SI-11 b"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81895' do\n title \"MongoDB must reveal detailed error messages only to the ISSO, ISSM,\n SA, and DBA.\"\n desc \"If MongoDB provides too much information in error logs and\n administrative messages to the screen, this could lead to compromise. The\n structure and content of error messages need to be carefully considered by the\n organization and development team. The extent to which the information system\n is able to identify and handle error conditions is guided by organizational\n policy and operational requirements.\n\n Some default DBMS error messages can contain information that could aid an\n attacker in, among others things, identifying the database type, host address,\n or state of the database. Custom errors may contain sensitive customer\n information.\n\n It is important that detailed error messages be visible only to those who\n are authorized to view them; that general users receive only generalized\n acknowledgment that errors have occurred; and that these generalized messages\n appear only when relevant to the user's task. For example, a message along the\n lines of, \\\"An error has occurred. Unable to save your changes. If this problem\n persists, contact your help desk\\\" would be relevant. A message such as\n \\\"Warning: your transaction generated a large number of page splits\\\" would\n likely not be relevant.\n\n Administrative users authorized to review detailed error messages typically\n are the ISSO, ISSM, SA, and DBA. Other individuals or roles may be specified\n according to organization-specific needs, with appropriate approval.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"A mongod or mongos running with\n \\\"security.redactClientLogData\\\" redacts any message accompanying a given log\n event before logging.\n\n This prevents the mongod or mongos from writing potentially sensitive data\n stored on the database to the diagnostic log. Metadata such as error or\n operation codes, line numbers, and source file names are still visible in the\n logs.\n\n Verify that the MongoDB configuration file (default location: /etc/mongod.conf)\n contains the following:\n\n security:\n redactClientLogData: \\\"true\\\"\n\n If this parameter is not present, this is a finding.\"\n desc 'fix', \"Edit the MongoDB configuration file (default location:\n /etc/mongod.conf) and add the following parameter \\\"redactClientLogData\\\" in\n the security section of that file:\n\n security:\n redactClientLogData: \\\"true\\\"\n\n Stop/start (restart) any mongod or mongos using the MongoDB configuration file.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000267-DB-000163'\n tag \"gid\": 'V-81895'\n tag \"rid\": 'SV-96609r1_rule'\n tag \"stig_id\": 'MD3X-00-000530'\n tag \"fix_id\": 'F-88745r1_fix'\n tag \"cci\": ['CCI-001314']\n tag \"nist\": ['SI-11 b']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security redactClientLogData)) { should cmp 'true' }\n end\nend\n","source_location":{"ref":"./controls/V-81895.rb","line":1},"id":"V-81895"},{"title":"The role(s)/group(s) used to modify database structure (including but\n not necessarily limited to tables, indexes, storage, etc.) and logic modules\n (stored procedures, functions, triggers, links to software external to MongoDB,\n etc.) must be restricted to authorized users.","desc":"If MongoDB were to allow any user to make changes to database\n structure or logic, then those changes might be implemented without undergoing\n the appropriate testing and approvals that are part of a robust change\n management process.\n\n Accordingly, only qualified and authorized individuals must be allowed to\n obtain access to information system components for purposes of initiating\n changes, including upgrades and modifications.\n\n Unmanaged changes that occur to the database software libraries or\n configuration can lead to unauthorized or compromised installations.","descriptions":{"default":"If MongoDB were to allow any user to make changes to database\n structure or logic, then those changes might be implemented without undergoing\n the appropriate testing and approvals that are part of a robust change\n management process.\n\n Accordingly, only qualified and authorized individuals must be allowed to\n obtain access to information system components for purposes of initiating\n changes, including upgrades and modifications.\n\n Unmanaged changes that occur to the database software libraries or\n configuration can lead to unauthorized or compromised installations.","check":"Run the following command to get the roles from a MongoDB\n database.\n\n For each database in MongoDB:\n\n use \n db.getRoles(\n {\n rolesInfo: 1,\n showPrivileges:true,\n showBuiltinRoles: true\n }\n )\n\n Run the following command to the roles assigned to users:\n\n use admin\n db.system.users.find()\n\n Analyze the output and if any roles or users have unauthorized access, this is\n a finding.","fix":"Use the following commands to remove unauthorized access to a\n MongoDB database.\n\n db.revokePrivilegesFromRole()\n db. revokeRolesFromUser()\n\n MongoDB commands for role management can be found here:\n https://docs.mongodb.com/v3.4/reference/method/js-role-management/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000133-DB-000362","gid":"V-81857","rid":"SV-96571r1_rule","stig_id":"MD3X-00-000270","fix_id":"F-88707r1_fix","cci":["CCI-001499"],"nist":["CM-5 (6)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81857' do\n title \"The role(s)/group(s) used to modify database structure (including but\n not necessarily limited to tables, indexes, storage, etc.) and logic modules\n (stored procedures, functions, triggers, links to software external to MongoDB,\n etc.) must be restricted to authorized users.\"\n desc \"If MongoDB were to allow any user to make changes to database\n structure or logic, then those changes might be implemented without undergoing\n the appropriate testing and approvals that are part of a robust change\n management process.\n\n Accordingly, only qualified and authorized individuals must be allowed to\n obtain access to information system components for purposes of initiating\n changes, including upgrades and modifications.\n\n Unmanaged changes that occur to the database software libraries or\n configuration can lead to unauthorized or compromised installations.\n \"\n\n desc 'check', \"Run the following command to get the roles from a MongoDB\n database.\n\n For each database in MongoDB:\n\n use \n db.getRoles(\n {\n rolesInfo: 1,\n showPrivileges:true,\n showBuiltinRoles: true\n }\n )\n\n Run the following command to the roles assigned to users:\n\n use admin\n db.system.users.find()\n\n Analyze the output and if any roles or users have unauthorized access, this is\n a finding.\"\n desc 'fix', \"Use the following commands to remove unauthorized access to a\n MongoDB database.\n\n db.revokePrivilegesFromRole()\n db. revokeRolesFromUser()\n\n MongoDB commands for role management can be found here:\n https://docs.mongodb.com/v3.4/reference/method/js-role-management/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000133-DB-000362'\n tag \"gid\": 'V-81857'\n tag \"rid\": 'SV-96571r1_rule'\n tag \"stig_id\": 'MD3X-00-000270'\n tag \"fix_id\": 'F-88707r1_fix'\n tag \"cci\": ['CCI-001499']\n tag \"nist\": ['CM-5 (6)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getUsers()\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Manually verify roles for User: `#{entry['user']}` within Database: `#{entry['db']}`\n Roles: #{entry['roles']}\" do\n skip\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81857.rb","line":1},"id":"V-81857"},{"title":"MongoDB must prevent unauthorized and unintended information transfer\n via shared system resources.","desc":"The purpose of this control is to prevent information, including\n encrypted representations of information, produced by the actions of a prior\n user/role (or the actions of a process acting on behalf of a prior user/role)\n from being available to any current user/role (or current process) that obtains\n access to a shared system resource (e.g., registers, main memory, secondary\n storage) after the resource has been released back to the information system.\n Control of information in shared resources is also referred to as object reuse.","descriptions":{"default":"The purpose of this control is to prevent information, including\n encrypted representations of information, produced by the actions of a prior\n user/role (or the actions of a process acting on behalf of a prior user/role)\n from being available to any current user/role (or current process) that obtains\n access to a shared system resource (e.g., registers, main memory, secondary\n storage) after the resource has been released back to the information system.\n Control of information in shared resources is also referred to as object reuse.","check":"Verify the permissions for the following database files or\n directories:\n\n MongoDB default configuration file: \"/etc/mongod.conf\"\n MongoDB default data directory: \"/var/lib/mongo\"\n\n If the owner and group are not both \"mongod\", this is a finding.\n\n If the file permissions are more permissive than \"755\", this is a finding.","fix":"Correct the permission to the files and/or directories that are\n in violation.\n\n MongoDB Configuration file (default location):\n chown mongod:mongod /etc/mongod.conf\n chmod 755 /etc/mongod.conf\n\n MongoDB data file directory (default location):\n chown -R mongod:mongod/var/lib/mongo\n chmod -R 755/var/lib/mongo"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000243-DB-000373","satisfies":["SRG-APP-000243-DB-000373","SRG-APP-000243-DB-000374"],"gid":"V-81887","rid":"SV-96601r1_rule","stig_id":"MD3X-00-000470","fix_id":"F-88737r1_fix","cci":["CCI-001090"],"nist":["SC-4"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81887' do\n title \"MongoDB must prevent unauthorized and unintended information transfer\n via shared system resources.\"\n desc \"The purpose of this control is to prevent information, including\n encrypted representations of information, produced by the actions of a prior\n user/role (or the actions of a process acting on behalf of a prior user/role)\n from being available to any current user/role (or current process) that obtains\n access to a shared system resource (e.g., registers, main memory, secondary\n storage) after the resource has been released back to the information system.\n Control of information in shared resources is also referred to as object reuse.\n \"\n\n desc 'check', \"Verify the permissions for the following database files or\n directories:\n\n MongoDB default configuration file: \\\"/etc/mongod.conf\\\"\n MongoDB default data directory: \\\"/var/lib/mongo\\\"\n\n If the owner and group are not both \\\"mongod\\\", this is a finding.\n\n If the file permissions are more permissive than \\\"755\\\", this is a finding.\"\n desc 'fix', \"Correct the permission to the files and/or directories that are\n in violation.\n\n MongoDB Configuration file (default location):\n chown mongod:mongod /etc/mongod.conf\n chmod 755 /etc/mongod.conf\n\n MongoDB data file directory (default location):\n chown -R mongod:mongod/var/lib/mongo\n chmod -R 755/var/lib/mongo\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000243-DB-000373'\n tag \"satisfies\": %w(SRG-APP-000243-DB-000373 SRG-APP-000243-DB-000374)\n tag \"gid\": 'V-81887'\n tag \"rid\": 'SV-96601r1_rule'\n tag \"stig_id\": 'MD3X-00-000470'\n tag \"fix_id\": 'F-88737r1_fix'\n tag \"cci\": ['CCI-001090']\n tag \"nist\": ['SC-4']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongodb_service_account = input('mongodb_service_account')\n mongodb_service_group = input('mongodb_service_group')\n\n if file(input('mongod_conf')).exist?\n describe file(input('mongod_conf')) do\n it { should_not be_more_permissive_than('0755') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\n else\n describe 'This control must be reviewed manually because the configuration\n file is not found at the location specified.' do\n skip 'This control must be reviewed manually because the configuration\n file is not found at the location specified.'\n end\n end\n\n if file(input('mongo_data_dir')).exist?\n describe directory(input('mongo_data_dir')) do\n it { should_not be_more_permissive_than('0755') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\n else\n describe 'This control must be reviewed manually because the Mongodb data\n directory is not found at the location specified.' do\n skip 'This control must be reviewed manually because the Mongodb data\n directory is not found at the location specified.'\n end\n end\nend\n","source_location":{"ref":"./controls/V-81887.rb","line":1},"id":"V-81887"},{"title":"If passwords are used for authentication, MongoDB must transmit only\n encrypted representations of passwords.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, passwords need to be protected at all times, and encryption\n is the standard method for protecting passwords during transmission.\n\n DBMS passwords sent in clear text format across the network are vulnerable\n to discovery by unauthorized users. Disclosure of passwords may easily lead to\n unauthorized access to the database.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, passwords need to be protected at all times, and encryption\n is the standard method for protecting passwords during transmission.\n\n DBMS passwords sent in clear text format across the network are vulnerable\n to discovery by unauthorized users. Disclosure of passwords may easily lead to\n unauthorized access to the database.","check":"In the MongoDB database configuration file (default location:\n/etc/mongod.conf), review the following parameters:\n\nnet:\nssl:\nmode: requireSSL\nPEMKeyFile: /etc/ssl/mongodb.pem\nCAFile: /etc/ssl/mongodbca.pem\n\nIf the \"CAFile\" parameter is not present, this is a finding.\n\nIf the \"allowInvalidCertificates\" parameter is found, this is a finding.\n\nnet:\nssl:\nallowInvalidCertificates: true","fix":"In the MongoDB database configuration file (default location:\n /etc/mongod.conf) ensure the following parameters following parameter are set\n and configured correctly:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n CAFile: /etc/ssl/mongodbca.pem\n\n Remove any occurrence of the \"allowInvalidCertificates\" parameter:\n\n net:\n ssl:\n allowInvalidCertificates: true\n\n Stop/start (restart) the mongod or mongos instance using this configuration."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000172-DB-000075","satisfies":["SRG-APP-000172-DB-000075","SRG-APP-000175-DB-000067"],"gid":"V-81869","rid":"SV-96583r1_rule","stig_id":"MD3X-00-000340","fix_id":"F-88719r1_fix","cci":["CCI-000185","CCI-000197"],"nist":["IA-5 (2) (a)","IA-5 (1) (c)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81869' do\n title \"If passwords are used for authentication, MongoDB must transmit only\n encrypted representations of passwords.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, passwords need to be protected at all times, and encryption\n is the standard method for protecting passwords during transmission.\n\n DBMS passwords sent in clear text format across the network are vulnerable\n to discovery by unauthorized users. Disclosure of passwords may easily lead to\n unauthorized access to the database.\n \"\n\n desc 'check', \"In the MongoDB database configuration file (default location:\n/etc/mongod.conf), review the following parameters:\n\nnet:\nssl:\nmode: requireSSL\nPEMKeyFile: /etc/ssl/mongodb.pem\nCAFile: /etc/ssl/mongodbca.pem\n\nIf the \\\"CAFile\\\" parameter is not present, this is a finding.\n\nIf the \\\"allowInvalidCertificates\\\" parameter is found, this is a finding.\n\nnet:\nssl:\nallowInvalidCertificates: true\"\n desc 'fix', \"In the MongoDB database configuration file (default location:\n /etc/mongod.conf) ensure the following parameters following parameter are set\n and configured correctly:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n CAFile: /etc/ssl/mongodbca.pem\n\n Remove any occurrence of the \\\"allowInvalidCertificates\\\" parameter:\n\n net:\n ssl:\n allowInvalidCertificates: true\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000172-DB-000075'\n tag \"satisfies\": %w(SRG-APP-000172-DB-000075 SRG-APP-000175-DB-000067)\n tag \"gid\": 'V-81869'\n tag \"rid\": 'SV-96583r1_rule'\n tag \"stig_id\": 'MD3X-00-000340'\n tag \"fix_id\": 'F-88719r1_fix'\n tag \"cci\": %w(CCI-000185 CCI-000197)\n tag \"nist\": ['IA-5 (2) (a)', 'IA-5 (1) (c)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe.one do\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl allowInvalidCertificates)) { should be nil }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl allowInvalidCertificates)) { should be false }\n end\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl mode)) { should cmp 'requireSSL' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl PEMKeyFile)) { should cmp '/etc/ssl/mongodb.pem' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl CAFile)) { should cmp '/etc/ssl/mongodbca.pem' }\n end\nend\n","source_location":{"ref":"./controls/V-81869.rb","line":1},"id":"V-81869"},{"title":"The audit information produced by MongoDB must be protected from\n unauthorized read access.","desc":"If audit data were to become compromised, then competent forensic\n analysis and discovery of the true source of potentially malicious system\n activity is difficult, if not impossible, to achieve. In addition, access to\n audit records provides information an attacker could potentially use to his or\n her advantage.\n\n To ensure the veracity of audit data, the information system and/or the\n application must protect audit information from any and all unauthorized\n access. This includes read, write, copy, etc.\n\n This requirement can be achieved through multiple methods which will depend\n upon system architecture and design. Some commonly employed methods include\n ensuring log files enjoy the proper file system permissions utilizing file\n system protections and limiting log data location.\n\n Additionally, applications with user interfaces to audit records should not\n allow for the unfettered manipulation of or access to those records via the\n application. If the application provides access to the audit data, the\n application becomes accountable for ensuring that audit information is\n protected from unauthorized access.\n\n Audit information includes all information (e.g., audit records, audit\n settings, and audit reports) needed to successfully audit information system\n activity.","descriptions":{"default":"If audit data were to become compromised, then competent forensic\n analysis and discovery of the true source of potentially malicious system\n activity is difficult, if not impossible, to achieve. In addition, access to\n audit records provides information an attacker could potentially use to his or\n her advantage.\n\n To ensure the veracity of audit data, the information system and/or the\n application must protect audit information from any and all unauthorized\n access. This includes read, write, copy, etc.\n\n This requirement can be achieved through multiple methods which will depend\n upon system architecture and design. Some commonly employed methods include\n ensuring log files enjoy the proper file system permissions utilizing file\n system protections and limiting log data location.\n\n Additionally, applications with user interfaces to audit records should not\n allow for the unfettered manipulation of or access to those records via the\n application. If the application provides access to the audit data, the\n application becomes accountable for ensuring that audit information is\n protected from unauthorized access.\n\n Audit information includes all information (e.g., audit records, audit\n settings, and audit reports) needed to successfully audit information system\n activity.","check":"Verify User ownership, Group ownership, and permissions on the\n \"\":\n\n > ls –ald \n\n If the User owner is not \"mongod\", this is a finding.\n\n If the Group owner is not \"mongod\", this is a finding.\n\n If the directory is more permissive than \"700\", this is a finding.\n\n (The path for the MongoDB auditLog directory will vary according to local\n circumstances. The auditLog directory will be found in the MongoDB\n configuration file whose default location is '/etc/mongod.conf'.)\n\n To find the auditLog directory name, view and search for the entry in the\n MongoDB configuration file for the auditLog.path:\n\n Example:\n\n auditLog:\n destination: file\n format: BSON\n path: /var/lib/mongo/auditLog.bson\n\n Given the example above, to find the auditLog directory name run the following\n command:\n\n > dirname /var/lib/mongo/auditLog.bson\n the output will be the \"\"\n\n /var/lib/mongo","fix":"Run these commands:\n\n \"chown mongod \"\n \"chgrp mongod \"\n \"chmod 700 <\"\n\n (The path for the MongoDB auditLog directory will vary according to local\n circumstances. The auditLog directory will be found in the MongoDB\n configuration file whose default location is '/etc/mongod.conf'.)\n\n To find the auditLog directory name, view and search for the entry in the\n MongoDB configuration file for the auditLog.path:\n\n Example:\n\n auditLog:\n destination: file\n format: BSON\n path: /var/lib/mongo/auditLog.bson\n\n Given the example above, to find the auditLog directory name run the following\n command:\n\n > dirname /var/lib/mongo/auditLog.bson\n the output will be the \"\"\n\n /var/lib/mongo"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000118-DB-000059","satisfies":["SRG-APP-000118-DB-000059","SRG-APP-000119-DB-000060","SRG-APP-000120-DB-000061"],"gid":"V-81849","rid":"SV-96563r1_rule","stig_id":"MD3X-00-000190","fix_id":"F-88699r1_fix","cci":["CCI-000162","CCI-000163","CCI-000164"],"nist":["AU-9"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81849' do\n title \"The audit information produced by MongoDB must be protected from\n unauthorized read access.\"\n desc \"If audit data were to become compromised, then competent forensic\n analysis and discovery of the true source of potentially malicious system\n activity is difficult, if not impossible, to achieve. In addition, access to\n audit records provides information an attacker could potentially use to his or\n her advantage.\n\n To ensure the veracity of audit data, the information system and/or the\n application must protect audit information from any and all unauthorized\n access. This includes read, write, copy, etc.\n\n This requirement can be achieved through multiple methods which will depend\n upon system architecture and design. Some commonly employed methods include\n ensuring log files enjoy the proper file system permissions utilizing file\n system protections and limiting log data location.\n\n Additionally, applications with user interfaces to audit records should not\n allow for the unfettered manipulation of or access to those records via the\n application. If the application provides access to the audit data, the\n application becomes accountable for ensuring that audit information is\n protected from unauthorized access.\n\n Audit information includes all information (e.g., audit records, audit\n settings, and audit reports) needed to successfully audit information system\n activity.\n \"\n\n desc 'check', \"Verify User ownership, Group ownership, and permissions on the\n \\\"\\\":\n\n > ls –ald \n\n If the User owner is not \\\"mongod\\\", this is a finding.\n\n If the Group owner is not \\\"mongod\\\", this is a finding.\n\n If the directory is more permissive than \\\"700\\\", this is a finding.\n\n (The path for the MongoDB auditLog directory will vary according to local\n circumstances. The auditLog directory will be found in the MongoDB\n configuration file whose default location is '/etc/mongod.conf'.)\n\n To find the auditLog directory name, view and search for the entry in the\n MongoDB configuration file for the auditLog.path:\n\n Example:\n\n auditLog:\n destination: file\n format: BSON\n path: /var/lib/mongo/auditLog.bson\n\n Given the example above, to find the auditLog directory name run the following\n command:\n\n > dirname /var/lib/mongo/auditLog.bson\n the output will be the \\\"\\\"\n\n /var/lib/mongo\"\n desc 'fix', \"Run these commands:\n\n \\\"chown mongod \\\"\n \\\"chgrp mongod \\\"\n \\\"chmod 700 <\\\"\n\n (The path for the MongoDB auditLog directory will vary according to local\n circumstances. The auditLog directory will be found in the MongoDB\n configuration file whose default location is '/etc/mongod.conf'.)\n\n To find the auditLog directory name, view and search for the entry in the\n MongoDB configuration file for the auditLog.path:\n\n Example:\n\n auditLog:\n destination: file\n format: BSON\n path: /var/lib/mongo/auditLog.bson\n\n Given the example above, to find the auditLog directory name run the following\n command:\n\n > dirname /var/lib/mongo/auditLog.bson\n the output will be the \\\"\\\"\n\n /var/lib/mongo\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000118-DB-000059'\n tag \"satisfies\": %w(SRG-APP-000118-DB-000059 SRG-APP-000119-DB-000060\n SRG-APP-000120-DB-000061)\n tag \"gid\": 'V-81849'\n tag \"rid\": 'SV-96563r1_rule'\n tag \"stig_id\": 'MD3X-00-000190'\n tag \"fix_id\": 'F-88699r1_fix'\n tag \"cci\": %w(CCI-000162 CCI-000163 CCI-000164)\n tag \"nist\": ['AU-9']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongodb_auditlog_dir = yaml(input('mongod_conf'))['auditLog', 'path']\n mongodb_service_account = input('mongodb_service_account')\n mongodb_service_group = input('mongodb_service_group')\n\n describe file(mongodb_auditlog_dir) do\n it { should exist }\n end\n\n describe file(mongodb_auditlog_dir) do\n it { should_not be_more_permissive_than('0700') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\n\n describe command(\"dirname #{mongodb_auditlog_dir}\") do\n it { should cmp '/var/lib/mongo' }\n end\nend\n","source_location":{"ref":"./controls/V-81849.rb","line":1},"id":"V-81849"}],"groups":[{"title":null,"controls":["V-81843"],"id":"controls/V-81843.rb"},{"title":null,"controls":["V-81853"],"id":"controls/V-81853.rb"},{"title":null,"controls":["V-81885"],"id":"controls/V-81885.rb"},{"title":null,"controls":["V-81905"],"id":"controls/V-81905.rb"},{"title":null,"controls":["V-81915"],"id":"controls/V-81915.rb"},{"title":null,"controls":["V-81917"],"id":"controls/V-81917.rb"},{"title":null,"controls":["V-81901"],"id":"controls/V-81901.rb"},{"title":null,"controls":["V-81925"],"id":"controls/V-81925.rb"},{"title":null,"controls":["V-81911"],"id":"controls/V-81911.rb"},{"title":null,"controls":["V-81897"],"id":"controls/V-81897.rb"},{"title":null,"controls":["V-81863"],"id":"controls/V-81863.rb"},{"title":null,"controls":["V-81893"],"id":"controls/V-81893.rb"},{"title":null,"controls":["V-81907"],"id":"controls/V-81907.rb"},{"title":null,"controls":["V-81855"],"id":"controls/V-81855.rb"},{"title":null,"controls":["V-81909"],"id":"controls/V-81909.rb"},{"title":null,"controls":["V-81865"],"id":"controls/V-81865.rb"},{"title":null,"controls":["V-81867"],"id":"controls/V-81867.rb"},{"title":null,"controls":["V-81891"],"id":"controls/V-81891.rb"},{"title":null,"controls":["V-81929"],"id":"controls/V-81929.rb"},{"title":null,"controls":["V-81923"],"id":"controls/V-81923.rb"},{"title":null,"controls":["V-81871"],"id":"controls/V-81871.rb"},{"title":null,"controls":["V-81845"],"id":"controls/V-81845.rb"},{"title":null,"controls":["V-81851"],"id":"controls/V-81851.rb"},{"title":null,"controls":["V-81873"],"id":"controls/V-81873.rb"},{"title":null,"controls":["V-81889"],"id":"controls/V-81889.rb"},{"title":null,"controls":["V-81877"],"id":"controls/V-81877.rb"},{"title":null,"controls":["V-81919"],"id":"controls/V-81919.rb"},{"title":null,"controls":["V-81881"],"id":"controls/V-81881.rb"},{"title":null,"controls":["V-81913"],"id":"controls/V-81913.rb"},{"title":null,"controls":["V-81879"],"id":"controls/V-81879.rb"},{"title":null,"controls":["V-81899"],"id":"controls/V-81899.rb"},{"title":null,"controls":["V-81859"],"id":"controls/V-81859.rb"},{"title":null,"controls":["V-81921"],"id":"controls/V-81921.rb"},{"title":null,"controls":["V-81875"],"id":"controls/V-81875.rb"},{"title":null,"controls":["V-81927"],"id":"controls/V-81927.rb"},{"title":null,"controls":["V-81847"],"id":"controls/V-81847.rb"},{"title":null,"controls":["V-81883"],"id":"controls/V-81883.rb"},{"title":null,"controls":["V-81903"],"id":"controls/V-81903.rb"},{"title":null,"controls":["V-81861"],"id":"controls/V-81861.rb"},{"title":null,"controls":["V-81895"],"id":"controls/V-81895.rb"},{"title":null,"controls":["V-81857"],"id":"controls/V-81857.rb"},{"title":null,"controls":["V-81887"],"id":"controls/V-81887.rb"},{"title":null,"controls":["V-81869"],"id":"controls/V-81869.rb"},{"title":null,"controls":["V-81849"],"id":"controls/V-81849.rb"}],"sha256":"42cf40c6b367b47abff009d2dbb0b64cdc44f87f80221a1295e37fab59b330b1","status_message":"","status":"loaded","generator":{"name":"inspec","version":"4.37.30"}} From 06462b4483d3deba74f4f9f902a0dbffcfc37d13 Mon Sep 17 00:00:00 2001 From: Aaron Lippold Date: Fri, 25 Jun 2021 20:15:23 +0000 Subject: [PATCH 26/32] removed test.json file Signed-off-by: GitHub --- test.json | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 test.json diff --git a/test.json b/test.json deleted file mode 100644 index ac5e153..0000000 --- a/test.json +++ /dev/null @@ -1,13 +0,0 @@ -echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.version()" | mongo --quiet admin --host '127.0.0.1' --port '27017' -echo "db.adminCommand('listDatabases')" | mongo --quiet admin --host '127.0.0.1' --port '27017' -{"name":"mongodb-enterprise-advanced-3-stig-baseline","title":"mongodb-enterprise-advanced-3-stig-baseline","maintainer":"The MITRE SAF Team","copyright":"(c) 2020, The MITRE Corporation","copyright_email":"saf@groups.mitre.org","license":"Apache-2.0","summary":"Inspec Validation Profile for MongoDB Enterprise Advanced 3.x STIG","version":"1.2.0","inspec_version":">= 4.0","inputs":[],"supports":[],"controls":[{"title":"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.","desc":"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.","descriptions":{"default":"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.","check":"Verify that the MongoDB configuration file (default location:\n /etc/mongod.conf) contains the following:\n\n security:\n authorization: \"enabled\"\n\n If this parameter is not present, this is a finding.","fix":"Edit the MongoDB configuration file (default location:\n /etc/mongod.conf) to include the following:\n\n security:\n authorization: \"enabled\"\n\n This will enable SCRAM-SHA-1 authentication (default).\n\n Instruction on configuring the default authentication is provided here:\n\n https://docs.mongodb.com/v3.4/tutorial/enable-authentication/\n\n The high-level steps described by the above will require the following:\n\n 1. Start MongoDB without access control.\n 2. Connect to the instance.\n 3. Create the user administrator.\n 4. Restart the MongoDB instance with access control.\n 5. Connect and authenticate as the user administrator.\n 6. Create additional users as needed for your deployment."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000023-DB-000001","gid":"V-81843","rid":"SV-96557r1_rule","stig_id":"MD3X-00-000010","fix_id":"F-88693r1_fix","cci":["CCI-000015"],"nist":["AC-2 (1)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81843' do\n title \"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.\"\n desc \"MongoDB must integrate with an organization-level\n authentication/access mechanism providing account management and automation for\n all users, groups, roles, and any other principals.\"\n\n desc 'check', \"Verify that the MongoDB configuration file (default location:\n /etc/mongod.conf) contains the following:\n\n security:\n authorization: \\\"enabled\\\"\n\n If this parameter is not present, this is a finding.\"\n desc 'fix', \"Edit the MongoDB configuration file (default location:\n /etc/mongod.conf) to include the following:\n\n security:\n authorization: \\\"enabled\\\"\n\n This will enable SCRAM-SHA-1 authentication (default).\n\n Instruction on configuring the default authentication is provided here:\n\n https://docs.mongodb.com/v3.4/tutorial/enable-authentication/\n\n The high-level steps described by the above will require the following:\n\n 1. Start MongoDB without access control.\n 2. Connect to the instance.\n 3. Create the user administrator.\n 4. Restart the MongoDB instance with access control.\n 5. Connect and authenticate as the user administrator.\n 6. Create additional users as needed for your deployment.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000023-DB-000001'\n tag \"gid\": 'V-81843'\n tag \"rid\": 'SV-96557r1_rule'\n tag \"stig_id\": 'MD3X-00-000010'\n tag \"fix_id\": 'F-88693r1_fix'\n tag \"cci\": ['CCI-000015']\n tag \"nist\": ['AC-2 (1)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security authorization)) { should cmp 'enabled' }\n end\nend\n","source_location":{"ref":"./controls/V-81843.rb","line":1},"id":"V-81843"},{"title":"MongoDB software installation account must be restricted to authorized\n users.","desc":"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can have significant effects on the\n overall security of the system.\n\n If the system were to allow any user to make changes to software libraries,\n then those changes might be implemented without undergoing the appropriate\n testing and approvals that are part of a robust change management process.\n\n Accordingly, only qualified and authorized individuals must be allowed\n access to information system components for purposes of initiating changes,\n including upgrades and modifications.\n\n DBA and other privileged administrative or application owner accounts are\n granted privileges that allow actions that can have a great impact on database\n security and operation. It is especially important to grant privileged access\n to only those persons who are qualified and authorized to use them.","descriptions":{"default":"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can have significant effects on the\n overall security of the system.\n\n If the system were to allow any user to make changes to software libraries,\n then those changes might be implemented without undergoing the appropriate\n testing and approvals that are part of a robust change management process.\n\n Accordingly, only qualified and authorized individuals must be allowed\n access to information system components for purposes of initiating changes,\n including upgrades and modifications.\n\n DBA and other privileged administrative or application owner accounts are\n granted privileges that allow actions that can have a great impact on database\n security and operation. It is especially important to grant privileged access\n to only those persons who are qualified and authorized to use them.","check":"Review procedures for controlling, granting access to, and\n tracking use of the DBMS software installation account.\n\n If access or use of this account is not restricted to the minimum number of\n personnel required or if unauthorized access to the account has been granted,\n this is a finding.","fix":"Develop, document, and implement procedures to restrict and track\n use of the DBMS software installation account."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000133-DB-000198","gid":"V-81853","rid":"SV-96567r1_rule","stig_id":"MD3X-00-000250","fix_id":"F-88703r1_fix","cci":["CCI-001499"],"nist":["CM-5 (6)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81853' do\n title \"MongoDB software installation account must be restricted to authorized\n users.\"\n desc \"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can have significant effects on the\n overall security of the system.\n\n If the system were to allow any user to make changes to software libraries,\n then those changes might be implemented without undergoing the appropriate\n testing and approvals that are part of a robust change management process.\n\n Accordingly, only qualified and authorized individuals must be allowed\n access to information system components for purposes of initiating changes,\n including upgrades and modifications.\n\n DBA and other privileged administrative or application owner accounts are\n granted privileges that allow actions that can have a great impact on database\n security and operation. It is especially important to grant privileged access\n to only those persons who are qualified and authorized to use them.\n \"\n\n desc 'check', \"Review procedures for controlling, granting access to, and\n tracking use of the DBMS software installation account.\n\n If access or use of this account is not restricted to the minimum number of\n personnel required or if unauthorized access to the account has been granted,\n this is a finding.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000133-DB-000198'\n tag \"gid\": 'V-81853'\n tag \"rid\": 'SV-96567r1_rule'\n tag \"stig_id\": 'MD3X-00-000250'\n tag \"fix_id\": 'F-88703r1_fix'\n tag \"cci\": ['CCI-001499']\n tag \"nist\": ['CM-5 (6)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n desc 'fix', \"Develop, document, and implement procedures to restrict and track\n use of the DBMS software installation account.\"\n describe 'A manual review is required to ensure there are procedures in place to restrict and track the use of the DBMS software installation account' do\n skip 'A manual review is required to ensure there are procedures in place to restrict and track the use of the DBMS software installation account'\n end\nend\n","source_location":{"ref":"./controls/V-81853.rb","line":1},"id":"V-81853"},{"title":"Database contents must be protected from unauthorized and unintended\n information transfer by enforcement of a data-transfer policy.","desc":"Applications, including DBMSs, must prevent unauthorized and\n unintended information transfer via shared system resources.\n\n Data used for the development and testing of applications often involves\n copying data from production. It is important that specific procedures exist\n for this process, to include the conditions under which such transfer may take\n place, where the copies may reside, and the rules for ensuring sensitive data\n are not exposed.\n\n Copies of sensitive data must not be misplaced or left in a temporary\n location without the proper controls.","descriptions":{"default":"Applications, including DBMSs, must prevent unauthorized and\n unintended information transfer via shared system resources.\n\n Data used for the development and testing of applications often involves\n copying data from production. It is important that specific procedures exist\n for this process, to include the conditions under which such transfer may take\n place, where the copies may reside, and the rules for ensuring sensitive data\n are not exposed.\n\n Copies of sensitive data must not be misplaced or left in a temporary\n location without the proper controls.","check":"Review the procedures for the refreshing of development/test\n data from production.\n\n Review any scripts or code that exists for the movement of production data to\n development/test systems, or to any other location or for any other purpose.\n\n Verify that copies of production data are not left in unprotected locations.\n\n If the code that exists for data movement does not comply with the\n organization-defined data transfer policy and/or fails to remove any copies of\n production data from unprotected locations, this is a finding.","fix":"Modify any code used for moving data from production to\n development/test systems to comply with the organization-defined data transfer\n policy, and to ensure copies of production data are not left in unsecured\n locations."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000243-DB-000128","gid":"V-81885","rid":"SV-96599r1_rule","stig_id":"MD3X-00-000460","fix_id":"F-88735r1_fix","cci":["CCI-001090"],"nist":["SC-4"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81885' do\n title \"Database contents must be protected from unauthorized and unintended\n information transfer by enforcement of a data-transfer policy.\"\n desc \"Applications, including DBMSs, must prevent unauthorized and\n unintended information transfer via shared system resources.\n\n Data used for the development and testing of applications often involves\n copying data from production. It is important that specific procedures exist\n for this process, to include the conditions under which such transfer may take\n place, where the copies may reside, and the rules for ensuring sensitive data\n are not exposed.\n\n Copies of sensitive data must not be misplaced or left in a temporary\n location without the proper controls.\n \"\n\n desc 'check', \"Review the procedures for the refreshing of development/test\n data from production.\n\n Review any scripts or code that exists for the movement of production data to\n development/test systems, or to any other location or for any other purpose.\n\n Verify that copies of production data are not left in unprotected locations.\n\n If the code that exists for data movement does not comply with the\n organization-defined data transfer policy and/or fails to remove any copies of\n production data from unprotected locations, this is a finding.\"\n desc 'fix', \"Modify any code used for moving data from production to\n development/test systems to comply with the organization-defined data transfer\n policy, and to ensure copies of production data are not left in unsecured\n locations.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000243-DB-000128'\n tag \"gid\": 'V-81885'\n tag \"rid\": 'SV-96599r1_rule'\n tag \"stig_id\": 'MD3X-00-000460'\n tag \"fix_id\": 'F-88735r1_fix'\n tag \"cci\": ['CCI-001090']\n tag \"nist\": ['SC-4']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure that database contents are protected from unauthorized and unintended\n information transfer by enforcement of a data-transfer policy.' do\n skip 'A manual review is required to ensure that database contents are protected from unauthorized and unintended\n information transfer by enforcement of a data-transfer policy.'\n end\nend\n","source_location":{"ref":"./controls/V-81885.rb","line":1},"id":"V-81885"},{"title":"MongoDB must allocate audit record storage capacity in accordance with\n site audit record storage requirements.","desc":"In order to ensure sufficient storage capacity for the audit logs,\n MongoDB must be able to allocate audit record storage capacity. Although\n another requirement (SRG-APP-000515-DB-000318) mandates that audit data be\n off-loaded to a centralized log management system, it remains necessary to\n provide space on the database server to serve as a buffer against outages and\n capacity limits of the off-loading mechanism.\n\n The task of allocating audit record storage capacity is usually performed\n during initial installation of MongoDB and is closely associated with the DBA\n and system administrator roles. The DBA or system administrator will usually\n coordinate the allocation of physical drive space with the application\n owner/installer and the application will prompt the installer to provide the\n capacity information, the physical location of the disk, or both.\n\n In determining the capacity requirements, consider such factors as: total\n number of users; expected number of concurrent users during busy periods;\n number and type of events being monitored; types and amounts of data being\n captured; the frequency/speed with which audit records are off-loaded to the\n central log management system; and any limitations that exist on MongoDB's\n ability to reuse the space formerly occupied by off-loaded records.","descriptions":{"default":"In order to ensure sufficient storage capacity for the audit logs,\n MongoDB must be able to allocate audit record storage capacity. Although\n another requirement (SRG-APP-000515-DB-000318) mandates that audit data be\n off-loaded to a centralized log management system, it remains necessary to\n provide space on the database server to serve as a buffer against outages and\n capacity limits of the off-loading mechanism.\n\n The task of allocating audit record storage capacity is usually performed\n during initial installation of MongoDB and is closely associated with the DBA\n and system administrator roles. The DBA or system administrator will usually\n coordinate the allocation of physical drive space with the application\n owner/installer and the application will prompt the installer to provide the\n capacity information, the physical location of the disk, or both.\n\n In determining the capacity requirements, consider such factors as: total\n number of users; expected number of concurrent users during busy periods;\n number and type of events being monitored; types and amounts of data being\n captured; the frequency/speed with which audit records are off-loaded to the\n central log management system; and any limitations that exist on MongoDB's\n ability to reuse the space formerly occupied by off-loaded records.","check":"Investigate whether there have been any incidents where MongoDB\n ran out of audit log space since the last time the space was allocated or other\n corrective measures were taken.\n\n If there have been incidents where MongoDB ran out of audit log space, this is\n a finding.\n\n A MongoDB audit log that is configured to be stored in a file is identified in\n the MongoDB configuration file (default: /etc/mongod.conf) under the\n \"auditLog:\" key and subkey \"destination:\" where \"destination\" is\n \"file\".\n\n If this is the case then the \"AuditLog:\" subkey \"path:\" determines where\n (device/directory) that file will be located.\n\n View the mongodb configuration file (default location: /etc/mongod.conf) and\n identify how the \"auditlog.destination\" is configured.\n\n When the \"auditlog.destination\" is \"file\", this is a finding.","fix":"View the mongodb configuration file (default location:\n /etc/mongod.conf) and view the \"auditlog.path\" to identify the storage volume.\n\n Allocate sufficient space to the storage volume hosting the file identified in\n the MongoDB configuration \"auditLog.path\" to support audit file peak demand."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000357-DB-000316","gid":"V-81905","rid":"SV-96619r1_rule","stig_id":"MD3X-00-000620","fix_id":"F-88755r3_fix","cci":["CCI-001849"],"nist":["AU-4"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81905' do\n title \"MongoDB must allocate audit record storage capacity in accordance with\n site audit record storage requirements.\"\n desc \"In order to ensure sufficient storage capacity for the audit logs,\n MongoDB must be able to allocate audit record storage capacity. Although\n another requirement (SRG-APP-000515-DB-000318) mandates that audit data be\n off-loaded to a centralized log management system, it remains necessary to\n provide space on the database server to serve as a buffer against outages and\n capacity limits of the off-loading mechanism.\n\n The task of allocating audit record storage capacity is usually performed\n during initial installation of MongoDB and is closely associated with the DBA\n and system administrator roles. The DBA or system administrator will usually\n coordinate the allocation of physical drive space with the application\n owner/installer and the application will prompt the installer to provide the\n capacity information, the physical location of the disk, or both.\n\n In determining the capacity requirements, consider such factors as: total\n number of users; expected number of concurrent users during busy periods;\n number and type of events being monitored; types and amounts of data being\n captured; the frequency/speed with which audit records are off-loaded to the\n central log management system; and any limitations that exist on MongoDB's\n ability to reuse the space formerly occupied by off-loaded records.\n \"\n\n desc 'check', \"Investigate whether there have been any incidents where MongoDB\n ran out of audit log space since the last time the space was allocated or other\n corrective measures were taken.\n\n If there have been incidents where MongoDB ran out of audit log space, this is\n a finding.\n\n A MongoDB audit log that is configured to be stored in a file is identified in\n the MongoDB configuration file (default: /etc/mongod.conf) under the\n \\\"auditLog:\\\" key and subkey \\\"destination:\\\" where \\\"destination\\\" is\n \\\"file\\\".\n\n If this is the case then the \\\"AuditLog:\\\" subkey \\\"path:\\\" determines where\n (device/directory) that file will be located.\n\n View the mongodb configuration file (default location: /etc/mongod.conf) and\n identify how the \\\"auditlog.destination\\\" is configured.\n\n When the \\\"auditlog.destination\\\" is \\\"file\\\", this is a finding.\"\n desc 'fix', \"View the mongodb configuration file (default location:\n /etc/mongod.conf) and view the \\\"auditlog.path\\\" to identify the storage volume.\n\n Allocate sufficient space to the storage volume hosting the file identified in\n the MongoDB configuration \\\"auditLog.path\\\" to support audit file peak demand.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000357-DB-000316'\n tag \"gid\": 'V-81905'\n tag \"rid\": 'SV-96619r1_rule'\n tag \"stig_id\": 'MD3X-00-000620'\n tag \"fix_id\": 'F-88755r3_fix'\n tag \"cci\": ['CCI-001849']\n tag \"nist\": ['AU-4']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog destination)) { should_not cmp 'file' }\n its(%w(auditLog destination)) { should_not be_nil }\n end\nend\n","source_location":{"ref":"./controls/V-81905.rb","line":1},"id":"V-81905"},{"title":"MongoDB must prohibit the use of cached authenticators after an\n organization-defined time period.","desc":"If cached authentication information is out-of-date, the validity of\n the authentication information may be questionable.","descriptions":{"default":"If cached authentication information is out-of-date, the validity of\n the authentication information may be questionable.","check":"If MongoDB is configured to authenticate using SASL and\n LDAP/Active Directory check the saslauthd command line options in the system\n boot script that starts saslauthd (the location will be dependent on the\n specific Linux operating system and boot script layout and naming conventions).\n If the \"-t\" option is not set for the \"saslauthd\" process in the system\n boot script, this is a finding.\n If any mongos process is running (a MongoDB shared cluster) the\n \"userCacheInvalidationIntervalSecs\" option can be used to specify the cache\n timeout.\n The default is \"30\" seconds and the minimum is \"1\" second.","fix":"If MongoDB is configured to authenticate using SASL and\n LDAP/Active Directory modify and restart the saslauthd command line options in\n the system boot script and set the \"-t\" option to the appropriate timeout in\n seconds.\n From the Linux Command line (with root/sudo privs) run the following command to\n restart the saslauthd process after making the change for the \"-t\" parameter:\n systemctl restart saslauthd\n If any mongos process is running (a MongoDB shared cluster) the\n \"userCacheInvalidationIntervalSecs\" option to adjust the timeout in seconds\n can be changed from the default \"30\" seconds.\n This is accomplished by modifying the mongos configuration file (default\n location: /etc/mongod.conf) and then restarting mongos."},"impact":0.0,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000400-DB-000367","gid":"V-81915","rid":"SV-96629r1_rule","stig_id":"MD3X-00-000710","fix_id":"F-88765r1_fix","cci":["CCI-002007"],"nist":["IA-5 (13)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81915' do\n title \"MongoDB must prohibit the use of cached authenticators after an\n organization-defined time period.\"\n desc \"If cached authentication information is out-of-date, the validity of\n the authentication information may be questionable.\"\n\n desc 'check', \"If MongoDB is configured to authenticate using SASL and\n LDAP/Active Directory check the saslauthd command line options in the system\n boot script that starts saslauthd (the location will be dependent on the\n specific Linux operating system and boot script layout and naming conventions).\n If the \\\"-t\\\" option is not set for the \\\"saslauthd\\\" process in the system\n boot script, this is a finding.\n If any mongos process is running (a MongoDB shared cluster) the\n \\\"userCacheInvalidationIntervalSecs\\\" option can be used to specify the cache\n timeout.\n The default is \\\"30\\\" seconds and the minimum is \\\"1\\\" second.\n \"\n desc 'fix', \"If MongoDB is configured to authenticate using SASL and\n LDAP/Active Directory modify and restart the saslauthd command line options in\n the system boot script and set the \\\"-t\\\" option to the appropriate timeout in\n seconds.\n From the Linux Command line (with root/sudo privs) run the following command to\n restart the saslauthd process after making the change for the \\\"-t\\\" parameter:\n systemctl restart saslauthd\n If any mongos process is running (a MongoDB shared cluster) the\n \\\"userCacheInvalidationIntervalSecs\\\" option to adjust the timeout in seconds\n can be changed from the default \\\"30\\\" seconds.\n This is accomplished by modifying the mongos configuration file (default\n location: /etc/mongod.conf) and then restarting mongos.\n \"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000400-DB-000367'\n tag \"gid\": 'V-81915'\n tag \"rid\": 'SV-96629r1_rule'\n tag \"stig_id\": 'MD3X-00-000710'\n tag \"fix_id\": 'F-88765r1_fix'\n tag \"cci\": ['CCI-002007']\n tag \"nist\": ['IA-5 (13)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n if input('mongo_use_saslauthd') == 'true' && input('mongo_use_ldap') == 'true'\n describe processes('saslauthd') do\n its('commands.join') { should match /-t\\s/ }\n end\n else\n impact 0.0\n describe 'This control is Not Applicable because MongoDB is not configured to authenticate using SASL and LDAP.' do\n skip 'This control is Not Applicable because MongoDB is not configured to authenticate using SASL and LDAP.'\n end\n end\nend\n","source_location":{"ref":"./controls/V-81915.rb","line":1},"id":"V-81915"},{"title":"MongoDB must only accept end entity certificates issued by DoD PKI or\n DoD-approved PKI Certification Authorities (CAs) for the establishment of all\n encrypted sessions.","desc":"Only DoD-approved external PKIs have been evaluated to ensure that\n they have security controls and identity vetting procedures in place which are\n sufficient for DoD systems to rely on the identity asserted in the certificate.\n PKIs lacking sufficient security controls and identity vetting procedures risk\n being compromised and issuing certificates that enable adversaries to\n impersonate legitimate users.\n\n The authoritative list of DoD-approved PKIs is published at\n http://iase.disa.mil/pki-pke/interoperability.\n\n This requirement focuses on communications protection for MongoDB session\n rather than for the network packet.","descriptions":{"default":"Only DoD-approved external PKIs have been evaluated to ensure that\n they have security controls and identity vetting procedures in place which are\n sufficient for DoD systems to rely on the identity asserted in the certificate.\n PKIs lacking sufficient security controls and identity vetting procedures risk\n being compromised and issuing certificates that enable adversaries to\n impersonate legitimate users.\n\n The authoritative list of DoD-approved PKIs is published at\n http://iase.disa.mil/pki-pke/interoperability.\n\n This requirement focuses on communications protection for MongoDB session\n rather than for the network packet.","check":"To run MongoDB in SSL mode, you have to obtain a valid\n certificate singed by a single certificate authority.\n\n Before starting the MongoDB database in SSL mode, verify that certificate used\n is issued by a valid DoD certificate authority (openssl x509 -in\n -text | grep -i \"issuer\").\n\n If there is any issuer present in the certificate that is not a DoD approved\n certificate authority, this is a finding.","fix":"Remove any certificate that was not issued by an approved DoD\n certificate authority. Contact the organization's certificate issuer and\n request a new certificate that is issued by a valid DoD certificate\n authorities."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000427-DB-000385","gid":"V-81917","rid":"SV-96631r1_rule","stig_id":"MD3X-00-000730","fix_id":"F-88767r1_fix","cci":["CCI-002470"],"nist":["SC-23 (5)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81917' do\n title \"MongoDB must only accept end entity certificates issued by DoD PKI or\n DoD-approved PKI Certification Authorities (CAs) for the establishment of all\n encrypted sessions.\"\n desc \"Only DoD-approved external PKIs have been evaluated to ensure that\n they have security controls and identity vetting procedures in place which are\n sufficient for DoD systems to rely on the identity asserted in the certificate.\n PKIs lacking sufficient security controls and identity vetting procedures risk\n being compromised and issuing certificates that enable adversaries to\n impersonate legitimate users.\n\n The authoritative list of DoD-approved PKIs is published at\n http://iase.disa.mil/pki-pke/interoperability.\n\n This requirement focuses on communications protection for MongoDB session\n rather than for the network packet.\n \"\n\n desc 'check', \"To run MongoDB in SSL mode, you have to obtain a valid\n certificate singed by a single certificate authority.\n\n Before starting the MongoDB database in SSL mode, verify that certificate used\n is issued by a valid DoD certificate authority (openssl x509 -in\n -text | grep -i \\\"issuer\\\").\n\n If there is any issuer present in the certificate that is not a DoD approved\n certificate authority, this is a finding.\"\n desc 'fix', \"Remove any certificate that was not issued by an approved DoD\n certificate authority. Contact the organization's certificate issuer and\n request a new certificate that is issued by a valid DoD certificate\n authorities.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000427-DB-000385'\n tag \"gid\": 'V-81917'\n tag \"rid\": 'SV-96631r1_rule'\n tag \"stig_id\": 'MD3X-00-000730'\n tag \"fix_id\": 'F-88767r1_fix'\n tag \"cci\": ['CCI-002470']\n tag \"nist\": ['SC-23 (5)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n # Process flag takes precedence over the conf file\n x509_conf = yaml(input('mongod_conf'))['net', 'tls', 'certificateKeyFile']\n x509_process_flag = processes('mongod').commands.join.gsub('--tlsCertificateKeyFile', '').strip\n\n x509_cert_file = input('x509_cert_file') unless input('x509_cert_file').nil?\n x509_cert_file = x509_conf unless x509_conf.nil?\n x509_cert_file = x509_process_flag unless x509_process_flag.nil?\n\n if file(x509_cert_file).exist?\n describe x509_certificate(x509_cert_file) do\n its('issuer_dn') { should eq input('authorized_certificate_authority') }\n end\n else\n describe 'x509 file not found, manual review required' do\n skip 'x509 file not found, manual review required'\n end\n end\nend\n","source_location":{"ref":"./controls/V-81917.rb","line":1},"id":"V-81917"},{"title":"MongoDB must provide the means for individuals in authorized roles to\n change the auditing to be performed on all application components, based on all\n selectable event criteria within organization-defined time thresholds.","desc":"If authorized individuals do not have the ability to modify auditing\n parameters in response to a changing threat environment, the organization may\n not be able to effectively respond, and important forensic information may be\n lost.\n\n This requirement enables organizations to extend or limit auditing as\n necessary to meet organizational requirements. Auditing that is limited to\n conserve information system resources may be extended to address certain threat\n situations. In addition, auditing may be limited to a specific set of events to\n facilitate audit reduction, analysis, and reporting. Organizations can\n establish time thresholds in which audit actions are changed, for example, near\n real time, within minutes, or within hours.","descriptions":{"default":"If authorized individuals do not have the ability to modify auditing\n parameters in response to a changing threat environment, the organization may\n not be able to effectively respond, and important forensic information may be\n lost.\n\n This requirement enables organizations to extend or limit auditing as\n necessary to meet organizational requirements. Auditing that is limited to\n conserve information system resources may be extended to address certain threat\n situations. In addition, auditing may be limited to a specific set of events to\n facilitate audit reduction, analysis, and reporting. Organizations can\n establish time thresholds in which audit actions are changed, for example, near\n real time, within minutes, or within hours.","check":"The MongoDB auditing facility allows authorized administrators\n and users track system activity. Once auditing is configured and enabled,\n changes to the audit events and filters require restarting the mongod (and\n mongos, if applicable) instances. This can be done with zero down time by\n performing the modifications using a rolling maintenance approach (i.e., change\n the parameters on the secondaries, step down the primary such that one of the\n reconfigured secondaries becomes the primary then reconfigure the old primary).\n\n If replica sets or the rolling maintenance approach is not used for the\n procedure by the application owner, this is a finding.","fix":"Use the rolling maintenance procedure.\n\n For each member of a replica set, starting with a secondary member, perform the\n following sequence of events, ending with the primary:\n\n 1. Restart the mongod instance as a standalone.\n 2. Perform the configure auditing task on the standalone instance.\n 3. Restart the mongod instance as a member of the replica set."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000353-DB-000324","gid":"V-81901","rid":"SV-96615r1_rule","stig_id":"MD3X-00-000590","fix_id":"F-88751r1_fix","cci":["CCI-001914"],"nist":["AU-12 (3)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81901' do\n title \"MongoDB must provide the means for individuals in authorized roles to\n change the auditing to be performed on all application components, based on all\n selectable event criteria within organization-defined time thresholds.\"\n desc \"If authorized individuals do not have the ability to modify auditing\n parameters in response to a changing threat environment, the organization may\n not be able to effectively respond, and important forensic information may be\n lost.\n\n This requirement enables organizations to extend or limit auditing as\n necessary to meet organizational requirements. Auditing that is limited to\n conserve information system resources may be extended to address certain threat\n situations. In addition, auditing may be limited to a specific set of events to\n facilitate audit reduction, analysis, and reporting. Organizations can\n establish time thresholds in which audit actions are changed, for example, near\n real time, within minutes, or within hours.\n \"\n\n desc 'check', \"The MongoDB auditing facility allows authorized administrators\n and users track system activity. Once auditing is configured and enabled,\n changes to the audit events and filters require restarting the mongod (and\n mongos, if applicable) instances. This can be done with zero down time by\n performing the modifications using a rolling maintenance approach (i.e., change\n the parameters on the secondaries, step down the primary such that one of the\n reconfigured secondaries becomes the primary then reconfigure the old primary).\n\n If replica sets or the rolling maintenance approach is not used for the\n procedure by the application owner, this is a finding.\"\n desc 'fix', \"Use the rolling maintenance procedure.\n\n For each member of a replica set, starting with a secondary member, perform the\n following sequence of events, ending with the primary:\n\n 1. Restart the mongod instance as a standalone.\n 2. Perform the configure auditing task on the standalone instance.\n 3. Restart the mongod instance as a member of the replica set.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000353-DB-000324'\n tag \"gid\": 'V-81901'\n tag \"rid\": 'SV-96615r1_rule'\n tag \"stig_id\": 'MD3X-00-000590'\n tag \"fix_id\": 'F-88751r1_fix'\n tag \"cci\": ['CCI-001914']\n tag \"nist\": ['AU-12 (3)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to check if replica sets or the rolling maintenance approach is not used for changes to the audit events & filters' do\n skip 'A manual review is required to check if replica sets or the rolling maintenance approach is not used for changes to the audit events & filters'\n end\nend\n","source_location":{"ref":"./controls/V-81901.rb","line":1},"id":"V-81901"},{"title":"When invalid inputs are received, MongoDB must behave in a predictable\n and documented manner that reflects organizational and system objectives.","desc":"A common vulnerability is unplanned behavior when invalid inputs are\n received. This requirement guards against adverse or unintended system behavior\n caused by invalid inputs, where information system responses to the invalid\n input may be disruptive or cause the system to fail into an unsafe state.\n The behavior will be derived from the organizational and system\n requirements and includes, but is not limited to, notification of the\n appropriate personnel, creating an audit record, and rejecting invalid input.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"A common vulnerability is unplanned behavior when invalid inputs are\n received. This requirement guards against adverse or unintended system behavior\n caused by invalid inputs, where information system responses to the invalid\n input may be disruptive or cause the system to fail into an unsafe state.\n The behavior will be derived from the organizational and system\n requirements and includes, but is not limited to, notification of the\n appropriate personnel, creating an audit record, and rejecting invalid input.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"As a user with the \"dbAdminAnyDatabase\" role, execute the\n following on the database of interest:\n use myDB\n db.getCollectionInfos()\n Where \"myDB\" is the name of the database on which validator rules are to be\n inspected. This returns an array of documents containing all collections\n information within myDB. For each collection's information received.\n If the \"options\" sub-document within each does not contain a \"validator\"\n sub-document, this is a finding.","fix":"Document validation can be added at the time of creation of a\n collection. Existing collections can also be modified with document validation\n rules. Use the \"validator\" option to create or update a collection with the\n desired validation rules."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000447-DB-000393","gid":"V-81925","rid":"SV-96639r1_rule","stig_id":"MD3X-00-000780","fix_id":"F-88775r1_fix","cci":["CCI-002754"],"nist":["SI-10 (3)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81925' do\n title \"When invalid inputs are received, MongoDB must behave in a predictable\n and documented manner that reflects organizational and system objectives.\"\n desc \"A common vulnerability is unplanned behavior when invalid inputs are\n received. This requirement guards against adverse or unintended system behavior\n caused by invalid inputs, where information system responses to the invalid\n input may be disruptive or cause the system to fail into an unsafe state.\n The behavior will be derived from the organizational and system\n requirements and includes, but is not limited to, notification of the\n appropriate personnel, creating an audit record, and rejecting invalid input.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"As a user with the \\\"dbAdminAnyDatabase\\\" role, execute the\n following on the database of interest:\n use myDB\n db.getCollectionInfos()\n Where \\\"myDB\\\" is the name of the database on which validator rules are to be\n inspected. This returns an array of documents containing all collections\n information within myDB. For each collection's information received.\n If the \\\"options\\\" sub-document within each does not contain a \\\"validator\\\"\n sub-document, this is a finding.\"\n desc 'fix', \"Document validation can be added at the time of creation of a\n collection. Existing collections can also be modified with document validation\n rules. Use the \\\"validator\\\" option to create or update a collection with the\n desired validation rules.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000447-DB-000393'\n tag \"gid\": 'V-81925'\n tag \"rid\": 'SV-96639r1_rule'\n tag \"stig_id\": 'MD3X-00-000780'\n tag \"fix_id\": 'F-88775r1_fix'\n tag \"cci\": ['CCI-002754']\n tag \"nist\": ['SI-10 (3)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n validator_exception_dbs = %w(admin local config)\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n next if validator_exception_dbs.include?(db)\n\n db_command = \"db = db.getSiblingDB('#{db}');db.getCollectionInfos()\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Database: `#{db}`; Collection `#{entry['name']}`\" do\n subject { entry }\n its(%w(options validator)) { should_not be nil }\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81925.rb","line":1},"id":"V-81925"},{"title":"MongoDB must enforce access restrictions associated with changes to\n the configuration of MongoDB or database(s).","desc":"Failure to provide logical access restrictions associated with changes\n to configuration may have significant effects on the overall security of the\n system.\n\n When dealing with access restrictions pertaining to change control, it\n should be noted that any changes to the hardware, software, and/or firmware\n components of the information system can potentially have significant effects\n on the overall security of the system.\n\n Accordingly, only qualified and authorized individuals should be allowed to\n obtain access to system components for the purposes of initiating changes,\n including upgrades and modifications.","descriptions":{"default":"Failure to provide logical access restrictions associated with changes\n to configuration may have significant effects on the overall security of the\n system.\n\n When dealing with access restrictions pertaining to change control, it\n should be noted that any changes to the hardware, software, and/or firmware\n components of the information system can potentially have significant effects\n on the overall security of the system.\n\n Accordingly, only qualified and authorized individuals should be allowed to\n obtain access to system components for the purposes of initiating changes,\n including upgrades and modifications.","check":"Review the security configuration of the MongoDB database(s).\n\n If unauthorized users can start the mongod or mongos processes or edit the\n MongoDB configuration file (default location: /etc/mongod.conf), this is a\n finding.\n\n If MongoDB does not enforce access restrictions associated with changes to the\n configuration of the database(s), this is a finding.\n\n To assist in conducting reviews of permissions, the following MongoDB commands\n describe permissions of databases and users:\n\n Permissions of concern in this respect include the following, and possibly\n others:\n - any user with a role of userAdminAnyDatabase role or userAdmin role\n - any database or with a user have a role or privilege with \"C\" (create) or\n \"w\" (update) privileges that are not necessary\n\n MongoDB commands to view roles in a particular database:\n db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })","fix":"Prereq: To view a user's roles, must have the \"viewUser\"\n privilege.\n https://docs.mongodb.com/v3.4/reference/privilege-actions/\n\n Connect to MongoDB.\n\n For each database, identify the user's roles for the database.\n\n use \n db.getUser(\"[username]\")\n\n The server will return a document with the user's roles.\n\n To revoke a user's role from a database use the db.revokeRolesFromUser() method.\n https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/\n\n To grant a role to a user use the db.grantRolesToUser() method.\n https://docs.mongodb.com/v3.4/reference/method/db.grantRolesToUser/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000380-DB-000360","gid":"V-81911","rid":"SV-96625r1_rule","stig_id":"MD3X-00-000670","fix_id":"F-88761r1_fix","cci":["CCI-001813"],"nist":["CM-5 (1)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81911' do\n title \"MongoDB must enforce access restrictions associated with changes to\n the configuration of MongoDB or database(s).\"\n desc \"Failure to provide logical access restrictions associated with changes\n to configuration may have significant effects on the overall security of the\n system.\n\n When dealing with access restrictions pertaining to change control, it\n should be noted that any changes to the hardware, software, and/or firmware\n components of the information system can potentially have significant effects\n on the overall security of the system.\n\n Accordingly, only qualified and authorized individuals should be allowed to\n obtain access to system components for the purposes of initiating changes,\n including upgrades and modifications.\n \"\n\n desc 'check', \"Review the security configuration of the MongoDB database(s).\n\n If unauthorized users can start the mongod or mongos processes or edit the\n MongoDB configuration file (default location: /etc/mongod.conf), this is a\n finding.\n\n If MongoDB does not enforce access restrictions associated with changes to the\n configuration of the database(s), this is a finding.\n\n To assist in conducting reviews of permissions, the following MongoDB commands\n describe permissions of databases and users:\n\n Permissions of concern in this respect include the following, and possibly\n others:\n - any user with a role of userAdminAnyDatabase role or userAdmin role\n - any database or with a user have a role or privilege with \\\"C\\\" (create) or\n \\\"w\\\" (update) privileges that are not necessary\n\n MongoDB commands to view roles in a particular database:\n db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })\"\n desc 'fix', \"Prereq: To view a user's roles, must have the \\\"viewUser\\\"\n privilege.\n https://docs.mongodb.com/v3.4/reference/privilege-actions/\n\n Connect to MongoDB.\n\n For each database, identify the user's roles for the database.\n\n use \n db.getUser(\\\"[username]\\\")\n\n The server will return a document with the user's roles.\n\n To revoke a user's role from a database use the db.revokeRolesFromUser() method.\n https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/\n\n To grant a role to a user use the db.grantRolesToUser() method.\n https://docs.mongodb.com/v3.4/reference/method/db.grantRolesToUser/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000380-DB-000360'\n tag \"gid\": 'V-81911'\n tag \"rid\": 'SV-96625r1_rule'\n tag \"stig_id\": 'MD3X-00-000670'\n tag \"fix_id\": 'F-88761r1_fix'\n tag \"cci\": ['CCI-001813']\n tag \"nist\": ['CM-5 (1)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file' do\n skip 'Manually verify unauthorized users cannot start the mongod or mongos processes or edit the MongoDB configuration file'\n end\n\n describe 'Manually verify enforces access restrictions associated with changes to the configuration of the database(s)' do\n skip 'Manually verify enforces access restrictions associated with changes to the configuration of the database(s)'\n end\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getUsers()\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n if entry['roles'].map { |x| x['role'] }.include?('userAdminAnyDatabase')\n describe \"Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdminAnyDatabase` role\" do\n skip\n end\n end\n next unless entry['roles'].map { |x| x['role'] }.include?('userAdmin')\n describe \"Manually verify User: `#{entry['user']}` within Database: `#{entry['db']}` is authorized to have `userAdmin` role\" do\n skip\n end\n end\n end\nend\n","source_location":{"ref":"./controls/V-81911.rb","line":1},"id":"V-81911"},{"title":"MongoDB must associate organization-defined types of security labels\n having organization-defined security label values with information in storage.","desc":"Without the association of security labels to information, there is no\n basis for MongoDB to make security-related access-control decisions.\n\n Security labels are abstractions representing the basic properties or\n characteristics of an entity (e.g., subjects and objects) with respect to\n safeguarding information.\n\n These labels are typically associated with internal data structures (e.g.,\n tables, rows) within the database and are used to enable the implementation of\n access control and flow control policies, reflect special dissemination,\n handling, or distribution instructions, or support other aspects of the\n information security policy.\n\n One example includes marking data as classified or FOUO. These security\n labels may be assigned manually or during data processing, but, either way, it\n is imperative these assignments are maintained while the data is in storage. If\n the security labels are lost when the data is stored, there is the risk of a\n data compromise.\n\n The mechanism used to support security labeling may be a feature of MongoDB\n product, a third-party product, or custom application code.","descriptions":{"default":"Without the association of security labels to information, there is no\n basis for MongoDB to make security-related access-control decisions.\n\n Security labels are abstractions representing the basic properties or\n characteristics of an entity (e.g., subjects and objects) with respect to\n safeguarding information.\n\n These labels are typically associated with internal data structures (e.g.,\n tables, rows) within the database and are used to enable the implementation of\n access control and flow control policies, reflect special dissemination,\n handling, or distribution instructions, or support other aspects of the\n information security policy.\n\n One example includes marking data as classified or FOUO. These security\n labels may be assigned manually or during data processing, but, either way, it\n is imperative these assignments are maintained while the data is in storage. If\n the security labels are lost when the data is stored, there is the risk of a\n data compromise.\n\n The mechanism used to support security labeling may be a feature of MongoDB\n product, a third-party product, or custom application code.","check":"MongoDB supports role-based access control at the collection\n level. If enabled, the database process should be started with\n \"security.authorization:enabled\" in the config file or with \"--auth\" in the\n command line.\n\n For documents that have been labeled (e.g., {\"tag\" : \"classified\"}),\n read-only views can be created and secured via access privileges such that a\n user can only view those documents that have a specific tag or tags (e.g., user\n x can only view records that are labeled with the tag of classified). Existing\n views can be listed using the db.getCollectionInfos() command for the selected\n database in mongo shell.\n\n If a view is not present for the collection requiring security labeling, this\n is a finding.\n\n MongoDB supports field-level redaction that allows the application to indicate\n to the database whether or not certain fields should be returned based on\n values in the field labels.\n\n If desired and aggregation queries in the application code are not using the\n $redact stage with appropriate logic, this is a finding.","fix":"Follow the documentation page to setup\n RBAC:https://docs.mongodb.com/manual/core/authorization/.\n\n For the required collections, create specific read-only views that allow access\n to only a subset of the data in a collection as documented here:\n https://docs.mongodb.com/manual/core/views/. Permissions on the view are\n specified separately from the permissions on the underlying collection.\n\n Use the \"$redact\" operator to restrict the contents of the documents based on\n information stored in the documents themselves as documented here:\n https://docs.mongodb.com/master/reference/operator/aggregation/redact/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000311-DB-000308","satisfies":["SRG-APP-000311-DB-000308","SRG-APP-000313-DB-000309","SRG-APP-000313-DB-000310"],"gid":"V-81897","rid":"SV-96611r1_rule","stig_id":"MD3X-00-000540","fix_id":"F-88747r1_fix","cci":["CCI-002262","CCI-002263","CCI-002264"],"nist":["AC-16 a"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81897' do\n title \"MongoDB must associate organization-defined types of security labels\n having organization-defined security label values with information in storage.\"\n desc \"Without the association of security labels to information, there is no\n basis for MongoDB to make security-related access-control decisions.\n\n Security labels are abstractions representing the basic properties or\n characteristics of an entity (e.g., subjects and objects) with respect to\n safeguarding information.\n\n These labels are typically associated with internal data structures (e.g.,\n tables, rows) within the database and are used to enable the implementation of\n access control and flow control policies, reflect special dissemination,\n handling, or distribution instructions, or support other aspects of the\n information security policy.\n\n One example includes marking data as classified or FOUO. These security\n labels may be assigned manually or during data processing, but, either way, it\n is imperative these assignments are maintained while the data is in storage. If\n the security labels are lost when the data is stored, there is the risk of a\n data compromise.\n\n The mechanism used to support security labeling may be a feature of MongoDB\n product, a third-party product, or custom application code.\n \"\n\n desc 'check', \"MongoDB supports role-based access control at the collection\n level. If enabled, the database process should be started with\n \\\"security.authorization:enabled\\\" in the config file or with \\\"--auth\\\" in the\n command line.\n\n For documents that have been labeled (e.g., {\\\"tag\\\" : \\\"classified\\\"}),\n read-only views can be created and secured via access privileges such that a\n user can only view those documents that have a specific tag or tags (e.g., user\n x can only view records that are labeled with the tag of classified). Existing\n views can be listed using the db.getCollectionInfos() command for the selected\n database in mongo shell.\n\n If a view is not present for the collection requiring security labeling, this\n is a finding.\n\n MongoDB supports field-level redaction that allows the application to indicate\n to the database whether or not certain fields should be returned based on\n values in the field labels.\n\n If desired and aggregation queries in the application code are not using the\n $redact stage with appropriate logic, this is a finding.\"\n desc 'fix', \"Follow the documentation page to setup\n RBAC:https://docs.mongodb.com/manual/core/authorization/.\n\n For the required collections, create specific read-only views that allow access\n to only a subset of the data in a collection as documented here:\n https://docs.mongodb.com/manual/core/views/. Permissions on the view are\n specified separately from the permissions on the underlying collection.\n\n Use the \\\"$redact\\\" operator to restrict the contents of the documents based on\n information stored in the documents themselves as documented here:\n https://docs.mongodb.com/master/reference/operator/aggregation/redact/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000311-DB-000308'\n tag \"satisfies\": %w(SRG-APP-000311-DB-000308 SRG-APP-000313-DB-000309\n SRG-APP-000313-DB-000310)\n tag \"gid\": 'V-81897'\n tag \"rid\": 'SV-96611r1_rule'\n tag \"stig_id\": 'MD3X-00-000540'\n tag \"fix_id\": 'F-88747r1_fix'\n tag \"cci\": %w(CCI-002262 CCI-002263 CCI-002264)\n tag \"nist\": ['AC-16 a']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure MongoDB associates organization-defined types of security labels\n having organization-defined security label values with information in storage.' do\n skip 'A manual review is required to ensure MongoDB associates organization-defined types of security labels\n having organization-defined security label values with information in storage.'\n end\nend\n","source_location":{"ref":"./controls/V-81897.rb","line":1},"id":"V-81897"},{"title":"MongoDB must uniquely identify and authenticate organizational users\n (or processes acting on behalf of organizational users).","desc":"To assure accountability and prevent unauthenticated access,\n organizational users must be identified and authenticated to prevent potential\n misuse and compromise of the system.\n\n Organizational users include organizational employees or individuals the\n organization deems to have equivalent status of employees (e.g., contractors).\n Organizational users (and any processes acting on behalf of users) must be\n uniquely identified and authenticated for all accesses, except the following:\n\n (i) Accesses explicitly identified and documented by the organization.\n Organizations document specific user actions that can be performed on the\n information system without identification or authentication; and\n (ii) Accesses that occur through authorized use of group authenticators\n without individual authentication. Organizations may require unique\n identification of individuals using shared accounts, for detailed\n accountability of individual activity.","descriptions":{"default":"To assure accountability and prevent unauthenticated access,\n organizational users must be identified and authenticated to prevent potential\n misuse and compromise of the system.\n\n Organizational users include organizational employees or individuals the\n organization deems to have equivalent status of employees (e.g., contractors).\n Organizational users (and any processes acting on behalf of users) must be\n uniquely identified and authenticated for all accesses, except the following:\n\n (i) Accesses explicitly identified and documented by the organization.\n Organizations document specific user actions that can be performed on the\n information system without identification or authentication; and\n (ii) Accesses that occur through authorized use of group authenticators\n without individual authentication. Organizations may require unique\n identification of individuals using shared accounts, for detailed\n accountability of individual activity.","check":"To view another user’s information, you must have the\n \"viewUser\" action on the other user’s database.\n\n For each database in the system, run the following command:\n\n db.getUsers()\n\n Ensure each user identified is a member of an appropriate organization that can\n access the database.\n\n If a user is found not be a member or an appropriate organization that can\n access the database, this is a finding.\n\n Verify that the MongoDB configuration file (default location: /etc/mongod.conf)\n contains the following:\n\n security:\n authorization: \"enabled\"\n\n If this parameter is not present, this is a finding.","fix":"Prereq: To drop a user from a database, must have the\n \"dropUser\" action on the database.\n\n For any user not a member of an appropriate organization and has access to a\n database in the system run the following command:\n\n // Change to the appropriate database\n use \n db.dropUser(, {w: \"majority\", wtimeout: 5000}\n\n If the MongoDB configuration file (default location: /etc/mongod.conf) does not\n contain\n\n security: authorization: \"enabled\"\n\n Edit the MongoDB configuration file, add these parameters, stop/start (restart)\n any mongod or mongos process using this MongoDB configuration file."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000148-DB-000103","gid":"V-81863","rid":"SV-96577r1_rule","stig_id":"MD3X-00-000310","fix_id":"F-88713r1_fix","cci":["CCI-000764"],"nist":["IA-2"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81863' do\n title \"MongoDB must uniquely identify and authenticate organizational users\n (or processes acting on behalf of organizational users).\"\n desc \"To assure accountability and prevent unauthenticated access,\n organizational users must be identified and authenticated to prevent potential\n misuse and compromise of the system.\n\n Organizational users include organizational employees or individuals the\n organization deems to have equivalent status of employees (e.g., contractors).\n Organizational users (and any processes acting on behalf of users) must be\n uniquely identified and authenticated for all accesses, except the following:\n\n (i) Accesses explicitly identified and documented by the organization.\n Organizations document specific user actions that can be performed on the\n information system without identification or authentication; and\n (ii) Accesses that occur through authorized use of group authenticators\n without individual authentication. Organizations may require unique\n identification of individuals using shared accounts, for detailed\n accountability of individual activity.\n \"\n\n desc 'check', \"To view another user’s information, you must have the\n \\\"viewUser\\\" action on the other user’s database.\n\n For each database in the system, run the following command:\n\n db.getUsers()\n\n Ensure each user identified is a member of an appropriate organization that can\n access the database.\n\n If a user is found not be a member or an appropriate organization that can\n access the database, this is a finding.\n\n Verify that the MongoDB configuration file (default location: /etc/mongod.conf)\n contains the following:\n\n security:\n authorization: \\\"enabled\\\"\n\n If this parameter is not present, this is a finding.\"\n desc 'fix', \"Prereq: To drop a user from a database, must have the\n \\\"dropUser\\\" action on the database.\n\n For any user not a member of an appropriate organization and has access to a\n database in the system run the following command:\n\n // Change to the appropriate database\n use \n db.dropUser(, {w: \\\"majority\\\", wtimeout: 5000}\n\n If the MongoDB configuration file (default location: /etc/mongod.conf) does not\n contain\n\n security: authorization: \\\"enabled\\\"\n\n Edit the MongoDB configuration file, add these parameters, stop/start (restart)\n any mongod or mongos process using this MongoDB configuration file.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000148-DB-000103'\n tag \"gid\": 'V-81863'\n tag \"rid\": 'SV-96577r1_rule'\n tag \"stig_id\": 'MD3X-00-000310'\n tag \"fix_id\": 'F-88713r1_fix'\n tag \"cci\": ['CCI-000764']\n tag \"nist\": ['IA-2']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to determine if a user is found not be a memer or an appropriate organization that can access the database.' do\n skip 'A manual review is required to determine if a user is found not be a memer or an appropriate organization that can access the database.'\n end\n\n describe yaml(input('mongod_conf')) do\n its(%w(security authorization)) { should cmp 'enabled' }\n end\nend\n","source_location":{"ref":"./controls/V-81863.rb","line":1},"id":"V-81863"},{"title":"MongoDB must provide non-privileged users with error messages that\n provide information necessary for corrective actions without revealing\n information that could be exploited by adversaries.","desc":"Any DBMS or associated application providing too much information in\n error messages on the screen or printout risks compromising the data and\n security of the system. The structure and content of error messages need to be\n carefully considered by the organization and development team.\n Databases can inadvertently provide a wealth of information to an attacker\n through improperly handled error messages. In addition to sensitive business or\n personal information, database errors can provide host names, IP addresses,\n user names, and other system information not required for troubleshooting but\n very useful to someone targeting the system.\n Carefully consider the structure/content of error messages. The extent to\n which information systems are able to identify and handle error conditions is\n guided by organizational policy and operational requirements. Information that\n could be exploited by adversaries includes, for example, logon attempts with\n passwords entered by mistake as the username, mission/business information that\n can be derived from (if not stated explicitly by) information recorded, and\n personal information, such as account numbers, social security numbers, and\n credit card numbers.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"Any DBMS or associated application providing too much information in\n error messages on the screen or printout risks compromising the data and\n security of the system. The structure and content of error messages need to be\n carefully considered by the organization and development team.\n Databases can inadvertently provide a wealth of information to an attacker\n through improperly handled error messages. In addition to sensitive business or\n personal information, database errors can provide host names, IP addresses,\n user names, and other system information not required for troubleshooting but\n very useful to someone targeting the system.\n Carefully consider the structure/content of error messages. The extent to\n which information systems are able to identify and handle error conditions is\n guided by organizational policy and operational requirements. Information that\n could be exploited by adversaries includes, for example, logon attempts with\n passwords entered by mistake as the username, mission/business information that\n can be derived from (if not stated explicitly by) information recorded, and\n personal information, such as account numbers, social security numbers, and\n credit card numbers.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"Check custom database code to verify that error messages do not\n contain information beyond what is needed for troubleshooting the issue.\n If custom database errors contain PII data, sensitive business data, or\n information useful for identifying the host system or database structure, this\n is a finding.\n When attempting to login with incorrect credentials, the user will receive an\n error message that the operation was unauthorized.\n If a user is attempting to perform an operation for which they do not have\n privileges, the database will return an error message that the operation is not\n authorized.","fix":"Configure custom database code and associated application code\n not to divulge sensitive information or information useful for system\n identification in error messages."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000266-DB-000162","gid":"V-81893","rid":"SV-96607r1_rule","stig_id":"MD3X-00-000520","fix_id":"F-88743r1_fix","cci":["CCI-001312"],"nist":["SI-11 a"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81893' do\n title \"MongoDB must provide non-privileged users with error messages that\n provide information necessary for corrective actions without revealing\n information that could be exploited by adversaries.\"\n desc \"Any DBMS or associated application providing too much information in\n error messages on the screen or printout risks compromising the data and\n security of the system. The structure and content of error messages need to be\n carefully considered by the organization and development team.\n Databases can inadvertently provide a wealth of information to an attacker\n through improperly handled error messages. In addition to sensitive business or\n personal information, database errors can provide host names, IP addresses,\n user names, and other system information not required for troubleshooting but\n very useful to someone targeting the system.\n Carefully consider the structure/content of error messages. The extent to\n which information systems are able to identify and handle error conditions is\n guided by organizational policy and operational requirements. Information that\n could be exploited by adversaries includes, for example, logon attempts with\n passwords entered by mistake as the username, mission/business information that\n can be derived from (if not stated explicitly by) information recorded, and\n personal information, such as account numbers, social security numbers, and\n credit card numbers.\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"Check custom database code to verify that error messages do not\n contain information beyond what is needed for troubleshooting the issue.\n If custom database errors contain PII data, sensitive business data, or\n information useful for identifying the host system or database structure, this\n is a finding.\n When attempting to login with incorrect credentials, the user will receive an\n error message that the operation was unauthorized.\n If a user is attempting to perform an operation for which they do not have\n privileges, the database will return an error message that the operation is not\n authorized.\"\n desc 'fix', \"Configure custom database code and associated application code\n not to divulge sensitive information or information useful for system\n identification in error messages.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000266-DB-000162'\n tag \"gid\": 'V-81893'\n tag \"rid\": 'SV-96607r1_rule'\n tag \"stig_id\": 'MD3X-00-000520'\n tag \"fix_id\": 'F-88743r1_fix'\n tag \"cci\": ['CCI-001312']\n tag \"nist\": ['SI-11 a']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to check custom database code to verfiy that error messages do not contain information beyond what is needed for troubleshooting the issue.' do\n skip 'A manual review is required to check custom database code to verfiy that error messages do not contain information beyond what is needed for troubleshooting the issue.'\n end\nend\n","source_location":{"ref":"./controls/V-81893.rb","line":1},"id":"V-81893"},{"title":"MongoDB must provide a warning to appropriate support staff when\n allocated audit record storage volume reaches 75% of maximum audit record\n storage capacity.","desc":"Organizations are required to use a central log management system, so,\n under normal conditions, the audit space allocated to MongoDB on its own server\n will not be an issue. However, space will still be required on MongoDB server\n for audit records in transit, and, under abnormal conditions, this could fill\n up. Since a requirement exists to halt processing upon audit failure, a service\n outage would result.\n\n If support personnel are not notified immediately upon storage volume\n utilization reaching 75%, they are unable to plan for storage capacity\n expansion.\n\n The appropriate support staff include, at a minimum, the ISSO and the\n DBA/SA.","descriptions":{"default":"Organizations are required to use a central log management system, so,\n under normal conditions, the audit space allocated to MongoDB on its own server\n will not be an issue. However, space will still be required on MongoDB server\n for audit records in transit, and, under abnormal conditions, this could fill\n up. Since a requirement exists to halt processing upon audit failure, a service\n outage would result.\n\n If support personnel are not notified immediately upon storage volume\n utilization reaching 75%, they are unable to plan for storage capacity\n expansion.\n\n The appropriate support staff include, at a minimum, the ISSO and the\n DBA/SA.","check":"A MongoDB audit log that is configured to be stored in a file\n is identified in the MongoDB configuration file (default: /etc/mongod.conf)\n under the \"auditLog:\" key and subkey \"destination:\" where \"destination\"\n is \"file\".\n\n If this is the case then the \"AuditLog:\" subkey \"path:\" determines where\n (device/directory) that file will be located.\n\n View the mongodb configuration file (default location: /etc/mongod.conf) and\n identify how the \"auditlog.destination\" is configured.\n\n When the \"auditlog.destination\" is \"file\", this is a finding.","fix":"View the mongodb configuration file (default location:\n /etc/mongod.conf) and view the \"auditlog.path\" to identify the storage volume.\n\n Install MongoDB Ops Manager or other organization approved monitoring software.\n\n Configure the required alert in the monitoring software to send an alert where\n storage volume holding the auditLog file utilization reaches 75%."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000359-DB-000319","gid":"V-81907","rid":"SV-96621r1_rule","stig_id":"MD3X-00-000630","fix_id":"F-88757r2_fix","cci":["CCI-001855"],"nist":["AU-5 (1)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81907' do\n title \"MongoDB must provide a warning to appropriate support staff when\n allocated audit record storage volume reaches 75% of maximum audit record\n storage capacity.\"\n desc \"Organizations are required to use a central log management system, so,\n under normal conditions, the audit space allocated to MongoDB on its own server\n will not be an issue. However, space will still be required on MongoDB server\n for audit records in transit, and, under abnormal conditions, this could fill\n up. Since a requirement exists to halt processing upon audit failure, a service\n outage would result.\n\n If support personnel are not notified immediately upon storage volume\n utilization reaching 75%, they are unable to plan for storage capacity\n expansion.\n\n The appropriate support staff include, at a minimum, the ISSO and the\n DBA/SA.\n \"\n\n desc 'check', \"A MongoDB audit log that is configured to be stored in a file\n is identified in the MongoDB configuration file (default: /etc/mongod.conf)\n under the \\\"auditLog:\\\" key and subkey \\\"destination:\\\" where \\\"destination\\\"\n is \\\"file\\\".\n\n If this is the case then the \\\"AuditLog:\\\" subkey \\\"path:\\\" determines where\n (device/directory) that file will be located.\n\n View the mongodb configuration file (default location: /etc/mongod.conf) and\n identify how the \\\"auditlog.destination\\\" is configured.\n\n When the \\\"auditlog.destination\\\" is \\\"file\\\", this is a finding.\"\n desc 'fix', \"View the mongodb configuration file (default location:\n /etc/mongod.conf) and view the \\\"auditlog.path\\\" to identify the storage volume.\n\n Install MongoDB Ops Manager or other organization approved monitoring software.\n\n Configure the required alert in the monitoring software to send an alert where\n storage volume holding the auditLog file utilization reaches 75%.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000359-DB-000319'\n tag \"gid\": 'V-81907'\n tag \"rid\": 'SV-96621r1_rule'\n tag \"stig_id\": 'MD3X-00-000630'\n tag \"fix_id\": 'F-88757r2_fix'\n tag \"cci\": ['CCI-001855']\n tag \"nist\": ['AU-5 (1)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog destination)) { should_not cmp 'file' }\n its(%w(auditLog destination)) { should_not be_nil }\n end\nend\n","source_location":{"ref":"./controls/V-81907.rb","line":1},"id":"V-81907"},{"title":"Database software, including DBMS configuration files, must be stored\n in dedicated directories, or DASD pools, separate from the host OS and other\n applications.","desc":"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can potentially have significant effects\n on the overall security of the system.\n Multiple applications can provide a cumulative negative effect. A\n vulnerability and subsequent exploit to one application can lead to an exploit\n of other applications sharing the same security context. For example, an\n exploit to a web server process that leads to unauthorized administrative\n access to host system directories can most likely lead to a compromise of all\n applications hosted by the same system. Database software not installed using\n dedicated directories both threatens and is threatened by other hosted\n applications. Access controls defined for one application may by default\n provide access to the other application's database objects or directories. Any\n method that provides any level of separation of security context assists in the\n protection between applications.","descriptions":{"default":"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can potentially have significant effects\n on the overall security of the system.\n Multiple applications can provide a cumulative negative effect. A\n vulnerability and subsequent exploit to one application can lead to an exploit\n of other applications sharing the same security context. For example, an\n exploit to a web server process that leads to unauthorized administrative\n access to host system directories can most likely lead to a compromise of all\n applications hosted by the same system. Database software not installed using\n dedicated directories both threatens and is threatened by other hosted\n applications. Access controls defined for one application may by default\n provide access to the other application's database objects or directories. Any\n method that provides any level of separation of security context assists in the\n protection between applications.","check":"Review the MongoDB software library directory and note other\n root directories located on the same disk directory or any subdirectories.\n If any non-MongoDB software directories exist on the disk directory, examine or\n investigate their use. If any of the directories are used by other\n applications, including third-party applications that use the MongoDB this is a\n finding.\n Only applications that are required for the functioning and administration, not\n use, of the MongoDB should be located in the same disk directory as the MongoDB\n software libraries.\n If other applications are located in the same directory as the MongoDB database\n this is a finding.","fix":"Install all applications on directories separate from the MongoDB\n software library directory. Relocate any directories or reinstall other\n application software that currently shares the MongoDB software library\n directory."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000133-DB-000199","gid":"V-81855","rid":"SV-96569r1_rule","stig_id":"MD3X-00-000260","fix_id":"F-88705r1_fix","cci":["CCI-001499"],"nist":["CM-5 (6)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81855' do\n title \"Database software, including DBMS configuration files, must be stored\n in dedicated directories, or DASD pools, separate from the host OS and other\n applications.\"\n desc \"When dealing with change control issues, it should be noted any\n changes to the hardware, software, and/or firmware components of the\n information system and/or application can potentially have significant effects\n on the overall security of the system.\n Multiple applications can provide a cumulative negative effect. A\n vulnerability and subsequent exploit to one application can lead to an exploit\n of other applications sharing the same security context. For example, an\n exploit to a web server process that leads to unauthorized administrative\n access to host system directories can most likely lead to a compromise of all\n applications hosted by the same system. Database software not installed using\n dedicated directories both threatens and is threatened by other hosted\n applications. Access controls defined for one application may by default\n provide access to the other application's database objects or directories. Any\n method that provides any level of separation of security context assists in the\n protection between applications.\n \"\n\n desc 'check', \"Review the MongoDB software library directory and note other\n root directories located on the same disk directory or any subdirectories.\n If any non-MongoDB software directories exist on the disk directory, examine or\n investigate their use. If any of the directories are used by other\n applications, including third-party applications that use the MongoDB this is a\n finding.\n Only applications that are required for the functioning and administration, not\n use, of the MongoDB should be located in the same disk directory as the MongoDB\n software libraries.\n If other applications are located in the same directory as the MongoDB database\n this is a finding.\"\n desc 'fix', \"Install all applications on directories separate from the MongoDB\n software library directory. Relocate any directories or reinstall other\n application software that currently shares the MongoDB software library\n directory.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000133-DB-000199'\n tag \"gid\": 'V-81855'\n tag \"rid\": 'SV-96569r1_rule'\n tag \"stig_id\": 'MD3X-00-000260'\n tag \"fix_id\": 'F-88705r1_fix'\n tag \"cci\": ['CCI-001499']\n tag \"nist\": ['CM-5 (6)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n if virtualization.system.eql?('docker')\n impact 0.0\n desc 'caveat', 'This is Not Applicable since the MongoDB is installed within a Docker container so it is separate from the host OS'\n else\n describe \"This test requires a Manual Review: Ensure all database software,\n including DBMS configuration files, is stored in dedicated directories, or\n DASD pools, separate from the host OS and other applications.\" do\n skip \"This test requires a Manual Review: Ensure all database software,\n including DBMS configuration files, is stored in dedicated directories, or\n DASD pools, separate from the host OS and other applications.\"\n end\n end\nend\n","source_location":{"ref":"./controls/V-81855.rb","line":1},"id":"V-81855"},{"title":"MongoDB must prohibit user installation of logic modules (stored\n procedures, functions, triggers, views, etc.) without explicit privileged\n status.","desc":"Allowing regular users to install software, without explicit\n privileges, creates the risk that untested or potentially malicious software\n will be installed on the system. Explicit privileges (escalated or\n administrative privileges) provide the regular user with explicit capabilities\n and control that exceed the rights of a regular user.\n\n DBMS functionality and the nature and requirements of databases will vary;\n so while users are not permitted to install unapproved software, there may be\n instances where the organization allows the user to install approved software\n packages such as from an approved software repository. The requirements for\n production servers will be more restrictive than those used for development and\n research.\n\n MongoDB must enforce software installation by users based upon what types\n of software installations are permitted (e.g., updates and security patches to\n existing software) and what types of installations are prohibited (e.g.,\n software whose pedigree with regard to being potentially malicious is unknown\n or suspect) by the organization).\n\n In the case of a database management system, this requirement covers stored\n procedures, functions, triggers, views, etc.","descriptions":{"default":"Allowing regular users to install software, without explicit\n privileges, creates the risk that untested or potentially malicious software\n will be installed on the system. Explicit privileges (escalated or\n administrative privileges) provide the regular user with explicit capabilities\n and control that exceed the rights of a regular user.\n\n DBMS functionality and the nature and requirements of databases will vary;\n so while users are not permitted to install unapproved software, there may be\n instances where the organization allows the user to install approved software\n packages such as from an approved software repository. The requirements for\n production servers will be more restrictive than those used for development and\n research.\n\n MongoDB must enforce software installation by users based upon what types\n of software installations are permitted (e.g., updates and security patches to\n existing software) and what types of installations are prohibited (e.g.,\n software whose pedigree with regard to being potentially malicious is unknown\n or suspect) by the organization).\n\n In the case of a database management system, this requirement covers stored\n procedures, functions, triggers, views, etc.","check":"If MongoDB supports only software development, experimentation,\n and/or developer-level testing (that is, excluding production systems,\n integration testing, stress testing, and user acceptance testing), this is not\n a finding.\n\n Review the MongoDB security settings with respect to non-administrative users'\n ability to create, alter, or replace functions or views.\n\n These MongoDB commands can help with showing existing roles and permissions of\n users of the databases.\n\n db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })\n\n If any such permissions exist and are not documented and approved, this is a\n finding.","fix":"Revoke any roles with unnecessary privileges to privileged\n functionality by executing the revoke command.\n\n Revoke any unnecessary privileges from any roles by executing the revoke\n command.\n\n Create, as needed, new role(s) with associated privileges."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000378-DB-000365","gid":"V-81909","rid":"SV-96623r1_rule","stig_id":"MD3X-00-000650","fix_id":"F-88759r1_fix","cci":["CCI-001812"],"nist":["CM-11 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81909' do\n title \"MongoDB must prohibit user installation of logic modules (stored\n procedures, functions, triggers, views, etc.) without explicit privileged\n status.\"\n desc \"Allowing regular users to install software, without explicit\n privileges, creates the risk that untested or potentially malicious software\n will be installed on the system. Explicit privileges (escalated or\n administrative privileges) provide the regular user with explicit capabilities\n and control that exceed the rights of a regular user.\n\n DBMS functionality and the nature and requirements of databases will vary;\n so while users are not permitted to install unapproved software, there may be\n instances where the organization allows the user to install approved software\n packages such as from an approved software repository. The requirements for\n production servers will be more restrictive than those used for development and\n research.\n\n MongoDB must enforce software installation by users based upon what types\n of software installations are permitted (e.g., updates and security patches to\n existing software) and what types of installations are prohibited (e.g.,\n software whose pedigree with regard to being potentially malicious is unknown\n or suspect) by the organization).\n\n In the case of a database management system, this requirement covers stored\n procedures, functions, triggers, views, etc.\n \"\n\n desc 'check', \"If MongoDB supports only software development, experimentation,\n and/or developer-level testing (that is, excluding production systems,\n integration testing, stress testing, and user acceptance testing), this is not\n a finding.\n\n Review the MongoDB security settings with respect to non-administrative users'\n ability to create, alter, or replace functions or views.\n\n These MongoDB commands can help with showing existing roles and permissions of\n users of the databases.\n\n db.getRoles( { rolesInfo: 1, showPrivileges:true, showBuiltinRoles: true })\n\n If any such permissions exist and are not documented and approved, this is a\n finding.\"\n desc 'fix', \"Revoke any roles with unnecessary privileges to privileged\n functionality by executing the revoke command.\n\n Revoke any unnecessary privileges from any roles by executing the revoke\n command.\n\n Create, as needed, new role(s) with associated privileges.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000378-DB-000365'\n tag \"gid\": 'V-81909'\n tag \"rid\": 'SV-96623r1_rule'\n tag \"stig_id\": 'MD3X-00-000650'\n tag \"fix_id\": 'F-88759r1_fix'\n tag \"cci\": ['CCI-001812']\n tag \"nist\": ['CM-11 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getRoles({rolesInfo: 1,showPrivileges:true,showBuiltinRoles: true})\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Manually verify privileges for Role: `#{entry['role']}` within Database: `#{db}`\n Privileges: #{entry['privileges']}\" do\n skip\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81909.rb","line":1},"id":"V-81909"},{"title":"If DBMS authentication, using passwords, is employed, MongoDB must\n enforce the DoD standards for password complexity and lifetime.","desc":"OS/enterprise authentication and identification must be used\n (SQL2-00-023600). Native DBMS authentication may be used only when\n circumstances make it unavoidable; and must be documented and AO-approved.\n\n The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is not\n possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, the DoD standards for password complexity and lifetime must\n be implemented. DBMS products that can inherit the rules for these from the\n operating system or access control program (e.g., Microsoft Active Directory)\n must be configured to do so. For other DBMSs, the rules must be enforced using\n available configuration parameters or custom code.","descriptions":{"default":"OS/enterprise authentication and identification must be used\n (SQL2-00-023600). Native DBMS authentication may be used only when\n circumstances make it unavoidable; and must be documented and AO-approved.\n\n The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is not\n possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, the DoD standards for password complexity and lifetime must\n be implemented. DBMS products that can inherit the rules for these from the\n operating system or access control program (e.g., Microsoft Active Directory)\n must be configured to do so. For other DBMSs, the rules must be enforced using\n available configuration parameters or custom code.","check":"If MongoDB is using Native LDAP authentication where the LDAP\n server is configured to enforce password complexity and lifetime, this is not a\n finding.\n\n If MongoDB is using Kerberos authentication where Kerberos is configured to\n enforce password complexity and lifetime, this is not a finding.\n\n If MongoDB is configured for SCRAM-SHA1, MONGODB-CR, LDAP Proxy authentication,\n this is a finding.\n\n See: https://docs.mongodb.com/v3.4/core/authentication/#authentication-methods","fix":"Either configure MongoDB for Native LDAP authentication where\n LDAP is configured to enforce password complexity and lifetime.\n OR\n Configure MongoDB Kerberos authentication where Kerberos is configured to\n enforce password complexity and lifetime."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000164-DB-000401","gid":"V-81865","rid":"SV-96579r1_rule","stig_id":"MD3X-00-000320","fix_id":"F-88715r1_fix","cci":["CCI-000192"],"nist":["IA-5 (1) (a)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81865' do\n title \"If DBMS authentication, using passwords, is employed, MongoDB must\n enforce the DoD standards for password complexity and lifetime.\"\n desc \"OS/enterprise authentication and identification must be used\n (SQL2-00-023600). Native DBMS authentication may be used only when\n circumstances make it unavoidable; and must be documented and AO-approved.\n\n The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is not\n possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, the DoD standards for password complexity and lifetime must\n be implemented. DBMS products that can inherit the rules for these from the\n operating system or access control program (e.g., Microsoft Active Directory)\n must be configured to do so. For other DBMSs, the rules must be enforced using\n available configuration parameters or custom code.\n \"\n\n desc 'check', \"If MongoDB is using Native LDAP authentication where the LDAP\n server is configured to enforce password complexity and lifetime, this is not a\n finding.\n\n If MongoDB is using Kerberos authentication where Kerberos is configured to\n enforce password complexity and lifetime, this is not a finding.\n\n If MongoDB is configured for SCRAM-SHA1, MONGODB-CR, LDAP Proxy authentication,\n this is a finding.\n\n See: https://docs.mongodb.com/v3.4/core/authentication/#authentication-methods\"\n desc 'fix', \"Either configure MongoDB for Native LDAP authentication where\n LDAP is configured to enforce password complexity and lifetime.\n OR\n Configure MongoDB Kerberos authentication where Kerberos is configured to\n enforce password complexity and lifetime.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000164-DB-000401'\n tag \"gid\": 'V-81865'\n tag \"rid\": 'SV-96579r1_rule'\n tag \"stig_id\": 'MD3X-00-000320'\n tag \"fix_id\": 'F-88715r1_fix'\n tag \"cci\": ['CCI-000192']\n tag \"nist\": ['IA-5 (1) (a)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'MongoDB Server should be configured with a non-default authentication Mechanism' do\n subject { processes('mongod') }\n its('commands.join') { should match /authenticationMechanisms/ }\n end\n\n describe 'MongoDB Server authentication Mechanism' do\n subject { processes('mongod').commands.join }\n it { should_not match /SCRAM-SHA1|MONGODB-CR|PLAIN/ }\n end\nend\n","source_location":{"ref":"./controls/V-81865.rb","line":1},"id":"V-81865"},{"title":"If passwords are used for authentication, MongoDB must store only\n hashed, salted representations of passwords.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n In such cases, database passwords stored in clear text, using reversible\n encryption, or using unsalted hashes would be vulnerable to unauthorized\n disclosure. Database passwords must always be in the form of one-way, salted\n hashes when stored internally or externally to MongoDB.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n In such cases, database passwords stored in clear text, using reversible\n encryption, or using unsalted hashes would be vulnerable to unauthorized\n disclosure. Database passwords must always be in the form of one-way, salted\n hashes when stored internally or externally to MongoDB.","check":"MongoDB supports x.509 certificate authentication for use with\n a secure TLS/SSL connection.\n\n The x.509 client authentication allows clients to authenticate to servers with\n certificates rather than with a username and password.\n\n If X.509 authentication is not used, a SCRAM-SHA-1 authentication protocol is\n also available. The SCRAM-SHA-1 protocol uses one-way, salted hash functions\n for passwords as documented here:\n https://docs.mongodb.com/v3.4/core/security-scram-sha-1/\n\n To authenticate with a client certificate, you must first add a MongoDB user\n that corresponds to the client certificate. See Add x.509 Certificate subject\n as a User as documented here:\n https://docs.mongodb.com/v3.4/tutorial/configure-x509-client-authentication/\n\n To authenticate, use the db.auth() method in the $external database, specifying\n \"MONGODB-X509\" for the mechanism field, and the user that corresponds to the\n client certificate for the user field.\n\n If the mechanism field is not set to \"MONGODB-X509\", this is a finding.","fix":"Do the following:\n - Create local CA and signing keys.\n - Generate and sign server certificates for member authentication.\n - Generate and sign client certificates for client authentication.\n - Start MongoDB cluster in non-auth mode.\n - Set up replica set and initial users.\n - Restart MongoDB replica set in X.509 mode using server certificates.\n\n Example shown here for x.509 Authentication:\n https://www.mongodb.com/blog/post/secure-mongodb-with-x-509-authentication\n\n Additionally, SSL/TLS must be on as documented here:\n https://docs.mongodb.com/v3.4/tutorial/configure-ssl/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000171-DB-000074","gid":"V-81867","rid":"SV-96581r1_rule","stig_id":"MD3X-00-000330","fix_id":"F-88717r1_fix","cci":["CCI-000196"],"nist":["IA-5 (1) (c)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81867' do\n title \"If passwords are used for authentication, MongoDB must store only\n hashed, salted representations of passwords.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n In such cases, database passwords stored in clear text, using reversible\n encryption, or using unsalted hashes would be vulnerable to unauthorized\n disclosure. Database passwords must always be in the form of one-way, salted\n hashes when stored internally or externally to MongoDB.\n \"\n\n desc 'check', \"MongoDB supports x.509 certificate authentication for use with\n a secure TLS/SSL connection.\n\n The x.509 client authentication allows clients to authenticate to servers with\n certificates rather than with a username and password.\n\n If X.509 authentication is not used, a SCRAM-SHA-1 authentication protocol is\n also available. The SCRAM-SHA-1 protocol uses one-way, salted hash functions\n for passwords as documented here:\n https://docs.mongodb.com/v3.4/core/security-scram-sha-1/\n\n To authenticate with a client certificate, you must first add a MongoDB user\n that corresponds to the client certificate. See Add x.509 Certificate subject\n as a User as documented here:\n https://docs.mongodb.com/v3.4/tutorial/configure-x509-client-authentication/\n\n To authenticate, use the db.auth() method in the $external database, specifying\n \\\"MONGODB-X509\\\" for the mechanism field, and the user that corresponds to the\n client certificate for the user field.\n\n If the mechanism field is not set to \\\"MONGODB-X509\\\", this is a finding.\"\n desc 'fix', \"Do the following:\n - Create local CA and signing keys.\n - Generate and sign server certificates for member authentication.\n - Generate and sign client certificates for client authentication.\n - Start MongoDB cluster in non-auth mode.\n - Set up replica set and initial users.\n - Restart MongoDB replica set in X.509 mode using server certificates.\n\n Example shown here for x.509 Authentication:\n https://www.mongodb.com/blog/post/secure-mongodb-with-x-509-authentication\n\n Additionally, SSL/TLS must be on as documented here:\n https://docs.mongodb.com/v3.4/tutorial/configure-ssl/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000171-DB-000074'\n tag \"gid\": 'V-81867'\n tag \"rid\": 'SV-96581r1_rule'\n tag \"stig_id\": 'MD3X-00-000330'\n tag \"fix_id\": 'F-88717r1_fix'\n tag \"cci\": ['CCI-000196']\n tag \"nist\": ['IA-5 (1) (c)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security authorization)) { should cmp 'enabled' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(security clusterAuthMode)) { should cmp 'x509' }\n end\nend\n","source_location":{"ref":"./controls/V-81867.rb","line":1},"id":"V-81867"},{"title":"MongoDB and associated applications must reserve the use of dynamic\n code execution for situations that require it.","desc":"With respect to database management systems, one class of threat is\n known as SQL Injection, or more generally, code injection. It takes advantage\n of the dynamic execution capabilities of various programming languages,\n including dialects of SQL. In such cases, the attacker deduces the manner in\n which SQL statements are being processed, either from inside knowledge or by\n observing system behavior in response to invalid inputs. When the attacker\n identifies scenarios where SQL queries are being assembled by application code\n (which may be within the database or separate from it) and executed\n dynamically, the attacker is then able to craft input strings that subvert the\n intent of the query. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n The principal protection against code injection is not to use dynamic\n execution except where it provides necessary functionality that cannot be\n utilized otherwise. Use strongly typed data items rather than general-purpose\n strings as input parameters to task-specific, pre-compiled stored procedures\n and functions (and triggers).\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"With respect to database management systems, one class of threat is\n known as SQL Injection, or more generally, code injection. It takes advantage\n of the dynamic execution capabilities of various programming languages,\n including dialects of SQL. In such cases, the attacker deduces the manner in\n which SQL statements are being processed, either from inside knowledge or by\n observing system behavior in response to invalid inputs. When the attacker\n identifies scenarios where SQL queries are being assembled by application code\n (which may be within the database or separate from it) and executed\n dynamically, the attacker is then able to craft input strings that subvert the\n intent of the query. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n The principal protection against code injection is not to use dynamic\n execution except where it provides necessary functionality that cannot be\n utilized otherwise. Use strongly typed data items rather than general-purpose\n strings as input parameters to task-specific, pre-compiled stored procedures\n and functions (and triggers).\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"MongoDB operations permit arbitrary JavaScript expressions to\n be run directly on the server.\n\n If the following parameter is not present or not set as show below in the\n MongoDB configuration file (default location: /etc/mongod.conf), this is a\n finding.\n\n security:\n javascriptEnabled: \"false\"","fix":"Disable the \"javascriptEnabled\" option.\n\n Edit the MongoDB configuration file (default location: /etc/mongod.conf\" to\n include the following:\n\n security:\n javascriptEnabled: false"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000251-DB-000391","satisfies":["SRG-APP-000251-DB-000391","SRG-APP-000251-DB-000392"],"gid":"V-81891","rid":"SV-96605r1_rule","stig_id":"MD3X-00-000500","fix_id":"F-88741r1_fix","cci":["CCI-001310"],"nist":["SI-10"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81891' do\n title \"MongoDB and associated applications must reserve the use of dynamic\n code execution for situations that require it.\"\n desc \"With respect to database management systems, one class of threat is\n known as SQL Injection, or more generally, code injection. It takes advantage\n of the dynamic execution capabilities of various programming languages,\n including dialects of SQL. In such cases, the attacker deduces the manner in\n which SQL statements are being processed, either from inside knowledge or by\n observing system behavior in response to invalid inputs. When the attacker\n identifies scenarios where SQL queries are being assembled by application code\n (which may be within the database or separate from it) and executed\n dynamically, the attacker is then able to craft input strings that subvert the\n intent of the query. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n The principal protection against code injection is not to use dynamic\n execution except where it provides necessary functionality that cannot be\n utilized otherwise. Use strongly typed data items rather than general-purpose\n strings as input parameters to task-specific, pre-compiled stored procedures\n and functions (and triggers).\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"MongoDB operations permit arbitrary JavaScript expressions to\n be run directly on the server.\n\n If the following parameter is not present or not set as show below in the\n MongoDB configuration file (default location: /etc/mongod.conf), this is a\n finding.\n\n security:\n javascriptEnabled: \\\"false\\\"\"\n desc 'fix', \"Disable the \\\"javascriptEnabled\\\" option.\n\n Edit the MongoDB configuration file (default location: /etc/mongod.conf\\\" to\n include the following:\n\n security:\n javascriptEnabled: false\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000251-DB-000391'\n tag \"satisfies\": %w(SRG-APP-000251-DB-000391 SRG-APP-000251-DB-000392)\n tag \"gid\": 'V-81891'\n tag \"rid\": 'SV-96605r1_rule'\n tag \"stig_id\": 'MD3X-00-000500'\n tag \"fix_id\": 'F-88741r1_fix'\n tag \"cci\": ['CCI-001310']\n tag \"nist\": ['SI-10']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security javascriptEnabled)) { should cmp 'false' }\n end\nend\n","source_location":{"ref":"./controls/V-81891.rb","line":1},"id":"V-81891"},{"title":"MongoDB must be configured in accordance with the security\n configuration settings based on DoD security configuration and implementation\n guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.","desc":"Configuring MongoDB to implement organization-wide security\n implementation guides and security checklists ensures compliance with federal\n standards and establishes a common security baseline across DoD that reflects\n the most restrictive security posture consistent with operational requirements.\n\n In addition to this SRG, sources of guidance on security and information\n assurance exist. These include NSA configuration guides, CTOs, DTMs, and IAVMs.\n MongoDB must be configured in compliance with guidance from all such relevant\n sources.","descriptions":{"default":"Configuring MongoDB to implement organization-wide security\n implementation guides and security checklists ensures compliance with federal\n standards and establishes a common security baseline across DoD that reflects\n the most restrictive security posture consistent with operational requirements.\n\n In addition to this SRG, sources of guidance on security and information\n assurance exist. These include NSA configuration guides, CTOs, DTMs, and IAVMs.\n MongoDB must be configured in compliance with guidance from all such relevant\n sources.","check":"Review the MongoDB documentation and configuration to determine\n it is configured in accordance with DoD security configuration and\n implementation guidance, including STIGs, NSA configuration guides, CTOs, DTMs,\n and IAVMs.\n\n If the MongoDB is not configured in accordance with security configuration\n settings, this is a finding.","fix":"Configure MongoDB in accordance with security configuration\n settings by reviewing the Operation System and MongoDB documentation and\n applying the necessary configuration parameters to meet the configurations\n required by the STIG, NSA configuration guidelines, CTOs, DTMs, and IAVMs."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000516-DB-000363","gid":"V-81929","rid":"SV-96643r1_rule","stig_id":"MD3X-00-001100","fix_id":"F-88779r1_fix","cci":["CCI-000366"],"nist":["CM-6 b"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81929' do\n title \"MongoDB must be configured in accordance with the security\n configuration settings based on DoD security configuration and implementation\n guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.\"\n desc \"Configuring MongoDB to implement organization-wide security\n implementation guides and security checklists ensures compliance with federal\n standards and establishes a common security baseline across DoD that reflects\n the most restrictive security posture consistent with operational requirements.\n\n In addition to this SRG, sources of guidance on security and information\n assurance exist. These include NSA configuration guides, CTOs, DTMs, and IAVMs.\n MongoDB must be configured in compliance with guidance from all such relevant\n sources.\n \"\n\n desc 'check', \"Review the MongoDB documentation and configuration to determine\n it is configured in accordance with DoD security configuration and\n implementation guidance, including STIGs, NSA configuration guides, CTOs, DTMs,\n and IAVMs.\n\n If the MongoDB is not configured in accordance with security configuration\n settings, this is a finding.\"\n desc 'fix', \"Configure MongoDB in accordance with security configuration\n settings by reviewing the Operation System and MongoDB documentation and\n applying the necessary configuration parameters to meet the configurations\n required by the STIG, NSA configuration guidelines, CTOs, DTMs, and IAVMs.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000516-DB-000363'\n tag \"gid\": 'V-81929'\n tag \"rid\": 'SV-96643r1_rule'\n tag \"stig_id\": 'MD3X-00-001100'\n tag \"fix_id\": 'F-88779r1_fix'\n tag \"cci\": ['CCI-000366']\n tag \"nist\": ['CM-6 b']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure that MongoDB is configured in accordance with the security\n configuration settings based on DoD security configuration and implementation\n guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.' do\n skip 'A manual review is required to ensure that MongoDB is configured in accordance with the security\n configuration settings based on DoD security configuration and implementation\n guidance, including STIGs, NSA configuration guides, CTOs, DTMs, and IAVMs.'\n end\nend\n","source_location":{"ref":"./controls/V-81929.rb","line":1},"id":"V-81929"},{"title":"MongoDB must maintain the confidentiality and integrity of information\n during reception.","desc":"Information can be either unintentionally or maliciously disclosed or\n modified during reception, including, for example, during aggregation, at\n protocol transformation points, and during packing/unpacking. These\n unauthorized disclosures or modifications compromise the confidentiality or\n integrity of the information.\n\n This requirement applies only to those applications that are either\n distributed or can allow access to data nonlocally. Use of this requirement\n will be limited to situations where the data owner has a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process.\n\n When receiving data, MongoDB, associated applications, and infrastructure\n must leverage protection mechanisms.","descriptions":{"default":"Information can be either unintentionally or maliciously disclosed or\n modified during reception, including, for example, during aggregation, at\n protocol transformation points, and during packing/unpacking. These\n unauthorized disclosures or modifications compromise the confidentiality or\n integrity of the information.\n\n This requirement applies only to those applications that are either\n distributed or can allow access to data nonlocally. Use of this requirement\n will be limited to situations where the data owner has a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process.\n\n When receiving data, MongoDB, associated applications, and infrastructure\n must leverage protection mechanisms.","check":"If the data owner does not have a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process, this is not a finding.\n\n If such strict requirement for ensure data integrity and confidentially is\n present, inspect the MongoDB configuration file (default location:\n /etc/mongod.conf) for the following entries:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n If net.ssl.mode is not set to \"requireSSL\", this is a finding.","fix":"Obtain a certificate from a valid DoD certificate authority to be\n used for encrypted data transmission.\n\n Modify the MongoDB configuration file (default location: /etc/mongod.conf) with\n the network configuration options.\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n Set \"net.ssl.mode\" to the \"requireSSL\".\n Set \"net.ssl.KeyFile\" to the full path of the certificate (.pem) file.\n\n Start/stop (restart) all mongod or mongos instances using the MongoDB\n configuration file (default location: /etc/mongod.conf)."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000442-DB-000379","gid":"V-81923","rid":"SV-96637r1_rule","stig_id":"MD3X-00-000770","fix_id":"F-88773r2_fix","cci":["CCI-002422"],"nist":["SC-8 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81923' do\n title \"MongoDB must maintain the confidentiality and integrity of information\n during reception.\"\n desc \"Information can be either unintentionally or maliciously disclosed or\n modified during reception, including, for example, during aggregation, at\n protocol transformation points, and during packing/unpacking. These\n unauthorized disclosures or modifications compromise the confidentiality or\n integrity of the information.\n\n This requirement applies only to those applications that are either\n distributed or can allow access to data nonlocally. Use of this requirement\n will be limited to situations where the data owner has a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process.\n\n When receiving data, MongoDB, associated applications, and infrastructure\n must leverage protection mechanisms.\n \"\n\n desc 'check', \"If the data owner does not have a strict requirement for\n ensuring data integrity and confidentiality is maintained at every step of the\n data transfer and handling process, this is not a finding.\n\n If such strict requirement for ensure data integrity and confidentially is\n present, inspect the MongoDB configuration file (default location:\n /etc/mongod.conf) for the following entries:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n If net.ssl.mode is not set to \\\"requireSSL\\\", this is a finding.\"\n desc 'fix', \"Obtain a certificate from a valid DoD certificate authority to be\n used for encrypted data transmission.\n\n Modify the MongoDB configuration file (default location: /etc/mongod.conf) with\n the network configuration options.\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n Set \\\"net.ssl.mode\\\" to the \\\"requireSSL\\\".\n Set \\\"net.ssl.KeyFile\\\" to the full path of the certificate (.pem) file.\n\n Start/stop (restart) all mongod or mongos instances using the MongoDB\n configuration file (default location: /etc/mongod.conf).\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000442-DB-000379'\n tag \"gid\": 'V-81923'\n tag \"rid\": 'SV-96637r1_rule'\n tag \"stig_id\": 'MD3X-00-000770'\n tag \"fix_id\": 'F-88773r2_fix'\n tag \"cci\": ['CCI-002422']\n tag \"nist\": ['SC-8 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl mode)) { should cmp 'requireSSL' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl PEMKeyFile)) { should_not be nil }\n end\nend\n","source_location":{"ref":"./controls/V-81923.rb","line":1},"id":"V-81923"},{"title":"MongoDB must enforce authorized access to all PKI private keys\n stored/utilized by MongoDB.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n PKI certificate-based authentication is performed by requiring the certificate\n holder to cryptographically prove possession of the corresponding private key.\n If the private key is stolen, an attacker can use the private key(s) to\n impersonate the certificate holder. In cases where MongoDB-stored private keys\n are used to authenticate MongoDB to the system’s clients, loss of the\n corresponding private keys would allow an attacker to successfully perform\n undetected man in the middle attacks against MongoDB system and its clients.\n Both the holder of a digital certificate and the issuing authority must\n take careful measures to protect the corresponding private key. Private keys\n should always be generated and protected in FIPS 140-2 validated cryptographic\n modules.\n All access to the private key(s) of MongoDB must be restricted to\n authorized and authenticated users. If unauthorized users have access to one or\n more of MongoDB's private keys, an attacker could gain access to the key(s) and\n use them to impersonate the database on the network or otherwise perform\n unauthorized actions.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n PKI certificate-based authentication is performed by requiring the certificate\n holder to cryptographically prove possession of the corresponding private key.\n If the private key is stolen, an attacker can use the private key(s) to\n impersonate the certificate holder. In cases where MongoDB-stored private keys\n are used to authenticate MongoDB to the system’s clients, loss of the\n corresponding private keys would allow an attacker to successfully perform\n undetected man in the middle attacks against MongoDB system and its clients.\n Both the holder of a digital certificate and the issuing authority must\n take careful measures to protect the corresponding private key. Private keys\n should always be generated and protected in FIPS 140-2 validated cryptographic\n modules.\n All access to the private key(s) of MongoDB must be restricted to\n authorized and authenticated users. If unauthorized users have access to one or\n more of MongoDB's private keys, an attacker could gain access to the key(s) and\n use them to impersonate the database on the network or otherwise perform\n unauthorized actions.","check":"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), review the following parameters:\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n CAFile: /etc/ssl/mongodbca.pem\n Verify ownership, group ownership, and permissions on the file given for\n PEMKeyFile (default 'mongodb.pem').\n Run following command and review its output:\n ls -al /etc/mongod.conf\n typical output:\n -rw------- 1 mongod mongod 566 Apr 26 20:20 /etc/mongod.conf\n If the user owner is not \"mongod\", this is a finding.\n If the group owner is not \"mongod\", this is a finding.\n If the file is more permissive than \"600\", this is a finding.\n Verify ownership, group ownership, and permissions on the file given for CAFile\n (default 'ca.pem').\n If the user owner is not \"mongod\", this is a finding.\n If the group owner is not \"mongod\", this is a finding.\n IF the file is more permissive than \"600\", this is a finding.","fix":"Run these commands:\n \"chown mongod:mongod /etc/ssl/mongodb.pem\"\n \"chmod 600 /etc/ssl/mongodb.pem\"\n \"chown mongod:mongod /etc/ssl/mongodbca.pem\"\n \"chmod 600 /etc/ssl/mongodbca.pem\""},"impact":0.7,"refs":[],"tags":{"severity":"high","gtitle":"SRG-APP-000176-DB-000068","gid":"V-81871","rid":"SV-96585r1_rule","stig_id":"MD3X-00-000360","fix_id":"F-88721r1_fix","cci":["CCI-000186"],"nist":["IA-5 (2) (b)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81871' do\n title \"MongoDB must enforce authorized access to all PKI private keys\n stored/utilized by MongoDB.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n PKI certificate-based authentication is performed by requiring the certificate\n holder to cryptographically prove possession of the corresponding private key.\n If the private key is stolen, an attacker can use the private key(s) to\n impersonate the certificate holder. In cases where MongoDB-stored private keys\n are used to authenticate MongoDB to the system’s clients, loss of the\n corresponding private keys would allow an attacker to successfully perform\n undetected man in the middle attacks against MongoDB system and its clients.\n Both the holder of a digital certificate and the issuing authority must\n take careful measures to protect the corresponding private key. Private keys\n should always be generated and protected in FIPS 140-2 validated cryptographic\n modules.\n All access to the private key(s) of MongoDB must be restricted to\n authorized and authenticated users. If unauthorized users have access to one or\n more of MongoDB's private keys, an attacker could gain access to the key(s) and\n use them to impersonate the database on the network or otherwise perform\n unauthorized actions.\n \"\n\n desc 'check', \"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), review the following parameters:\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n CAFile: /etc/ssl/mongodbca.pem\n Verify ownership, group ownership, and permissions on the file given for\n PEMKeyFile (default 'mongodb.pem').\n Run following command and review its output:\n ls -al /etc/mongod.conf\n typical output:\n -rw------- 1 mongod mongod 566 Apr 26 20:20 /etc/mongod.conf\n If the user owner is not \\\"mongod\\\", this is a finding.\n If the group owner is not \\\"mongod\\\", this is a finding.\n If the file is more permissive than \\\"600\\\", this is a finding.\n Verify ownership, group ownership, and permissions on the file given for CAFile\n (default 'ca.pem').\n If the user owner is not \\\"mongod\\\", this is a finding.\n If the group owner is not \\\"mongod\\\", this is a finding.\n IF the file is more permissive than \\\"600\\\", this is a finding.\"\n desc 'fix', \"Run these commands:\n \\\"chown mongod:mongod /etc/ssl/mongodb.pem\\\"\n \\\"chmod 600 /etc/ssl/mongodb.pem\\\"\n \\\"chown mongod:mongod /etc/ssl/mongodbca.pem\\\"\n \\\"chmod 600 /etc/ssl/mongodbca.pem\\\"\"\n\n impact 0.7\n tag \"severity\": 'high'\n tag \"gtitle\": 'SRG-APP-000176-DB-000068'\n tag \"gid\": 'V-81871'\n tag \"rid\": 'SV-96585r1_rule'\n tag \"stig_id\": 'MD3X-00-000360'\n tag \"fix_id\": 'F-88721r1_fix'\n tag \"cci\": ['CCI-000186']\n tag \"nist\": ['IA-5 (2) (b)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongod_pem = yaml(input('mongod_conf'))['net', 'ssl', 'PEMKeyFile']\n mongod_cafile = yaml(input('mongod_conf'))['net', 'ssl', 'CAFile']\n mongodb_service_account = input('mongodb_service_account')\n mongodb_service_group = input('mongodb_service_group')\n\n describe file(mongod_pem) do\n it { should exist }\n end\n\n describe file(mongod_pem) do\n it { should_not be_more_permissive_than('0600') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\n\n describe file(mongod_cafile) do\n it { should exist }\n end\n\n describe file(mongod_cafile) do\n it { should_not be_more_permissive_than('0600') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\nend\n","source_location":{"ref":"./controls/V-81871.rb","line":1},"id":"V-81871"},{"title":"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.","desc":"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.","descriptions":{"default":"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.","check":"Review the system documentation to determine the required\n levels of protection for DBMS server securables by type of login. Review the\n permissions actually in place on the server. If the actual permissions do not\n match the documented requirements, this is a finding.\n\n MongoDB commands to view roles in a particular database:\n\n db.getRoles(\n {\n rolesInfo: 1,\n showPrivileges:true,\n showBuiltinRoles: true\n }\n )","fix":"Use createRole(), updateRole(), dropRole(), grantRole()\n statements to add and remove permissions on server-level securables, bringing\n them into line with the documented requirements.\n\n MongoDB commands for role management can be found here:\n https://docs.mongodb.com/v3.4/reference/method/js-role-management/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000033-DB-000084","gid":"V-81845","rid":"SV-96559r1_rule","stig_id":"MD3X-00-000020","fix_id":"F-88695r2_fix","cci":["CCI-000213"],"nist":["AC-3"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81845' do\n title \"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.\"\n desc \"MongoDB must enforce approved authorizations for logical access to\n information and system resources in accordance with applicable access control\n policies.\"\n\n desc 'check', \"Review the system documentation to determine the required\n levels of protection for DBMS server securables by type of login. Review the\n permissions actually in place on the server. If the actual permissions do not\n match the documented requirements, this is a finding.\n\n MongoDB commands to view roles in a particular database:\n\n db.getRoles(\n {\n rolesInfo: 1,\n showPrivileges:true,\n showBuiltinRoles: true\n }\n )\"\n desc 'fix', \"Use createRole(), updateRole(), dropRole(), grantRole()\n statements to add and remove permissions on server-level securables, bringing\n them into line with the documented requirements.\n\n MongoDB commands for role management can be found here:\n https://docs.mongodb.com/v3.4/reference/method/js-role-management/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000033-DB-000084'\n tag \"gid\": 'V-81845'\n tag \"rid\": 'SV-96559r1_rule'\n tag \"stig_id\": 'MD3X-00-000020'\n tag \"fix_id\": 'F-88695r2_fix'\n tag \"cci\": ['CCI-000213']\n tag \"nist\": ['AC-3']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getRoles({rolesInfo: 1,showPrivileges:true,showBuiltinRoles: true})\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Manually verify privileges for Role: `#{entry['role']}` within Database: `#{db}`\n Privileges: #{entry['privileges']}\" do\n skip\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81845.rb","line":1},"id":"V-81845"},{"title":"MongoDB must protect its audit features from unauthorized access.","desc":"Protecting audit data also includes identifying and protecting the\n tools used to view and manipulate log data.\n\n Depending upon the log format and application, system and application log\n tools may provide the only means to manipulate and manage application and\n system log data. It is, therefore, imperative that access to audit tools be\n controlled and protected from unauthorized access.\n\n Applications providing tools to interface with audit data will leverage\n user permissions and roles identifying the user accessing the tools and the\n corresponding rights the user enjoys in order make access decisions regarding\n the access to audit tools.\n\n Audit tools include, but are not limited to, OS-provided audit tools,\n vendor-provided audit tools, and open source audit tools needed to successfully\n view and manipulate audit information system activity and records.\n\n If an attacker were to gain access to audit tools, he could analyze audit\n logs for system weaknesses or weaknesses in the auditing itself. An attacker\n could also manipulate logs to hide evidence of malicious activity.","descriptions":{"default":"Protecting audit data also includes identifying and protecting the\n tools used to view and manipulate log data.\n\n Depending upon the log format and application, system and application log\n tools may provide the only means to manipulate and manage application and\n system log data. It is, therefore, imperative that access to audit tools be\n controlled and protected from unauthorized access.\n\n Applications providing tools to interface with audit data will leverage\n user permissions and roles identifying the user accessing the tools and the\n corresponding rights the user enjoys in order make access decisions regarding\n the access to audit tools.\n\n Audit tools include, but are not limited to, OS-provided audit tools,\n vendor-provided audit tools, and open source audit tools needed to successfully\n view and manipulate audit information system activity and records.\n\n If an attacker were to gain access to audit tools, he could analyze audit\n logs for system weaknesses or weaknesses in the auditing itself. An attacker\n could also manipulate logs to hide evidence of malicious activity.","check":"Verify User ownership, Group ownership, and permissions on the\n “\":\n\n (default name and location is '/etc/mongod.conf')\n\n (The name and location for the MongoDB configuration file will vary according\n to local circumstances.)\n\n Using the default name and location the command would be:\n\n > ls –ald /etc/mongod.conf\n\n If the User owner is not \"mongod\", this is a finding.\n\n If the Group owner is not \"mongod\", this is a finding.\n\n If the filename is more permissive than \"700\", this is a finding.","fix":"Run these commands:\n\n \"chown mongod \"\n \"chgrp mongod \"\n \"chmod 700 <\"\n\n (The name and location for the MongoDB configuration file will vary according\n to local circumstances. The default name and location is '/etc/mongod.conf'.)\n\n Using the default name and location the commands would be:\n\n > chown mongod /etc/mongod.conf\n > chgrp mongod /etc/mongod.conf\n > chmod 700 /etc/mongod.conf"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000121-DB-000202","satisfies":["SRG-APP-000121-DB-000202","SRG-APP-000122-DB-000203","SRG-APP-000122-DB-000204"],"gid":"V-81851","rid":"SV-96565r1_rule","stig_id":"MD3X-00-000220","fix_id":"F-88701r1_fix","cci":["CCI-001493","CCI-001494","CCI-001495"],"nist":["AU-9"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81851' do\n title 'MongoDB must protect its audit features from unauthorized access.'\n desc \"Protecting audit data also includes identifying and protecting the\n tools used to view and manipulate log data.\n\n Depending upon the log format and application, system and application log\n tools may provide the only means to manipulate and manage application and\n system log data. It is, therefore, imperative that access to audit tools be\n controlled and protected from unauthorized access.\n\n Applications providing tools to interface with audit data will leverage\n user permissions and roles identifying the user accessing the tools and the\n corresponding rights the user enjoys in order make access decisions regarding\n the access to audit tools.\n\n Audit tools include, but are not limited to, OS-provided audit tools,\n vendor-provided audit tools, and open source audit tools needed to successfully\n view and manipulate audit information system activity and records.\n\n If an attacker were to gain access to audit tools, he could analyze audit\n logs for system weaknesses or weaknesses in the auditing itself. An attacker\n could also manipulate logs to hide evidence of malicious activity.\n \"\n\n desc 'check', \"Verify User ownership, Group ownership, and permissions on the\n “\\\":\n\n (default name and location is '/etc/mongod.conf')\n\n (The name and location for the MongoDB configuration file will vary according\n to local circumstances.)\n\n Using the default name and location the command would be:\n\n > ls –ald /etc/mongod.conf\n\n If the User owner is not \\\"mongod\\\", this is a finding.\n\n If the Group owner is not \\\"mongod\\\", this is a finding.\n\n If the filename is more permissive than \\\"700\\\", this is a finding.\"\n desc 'fix', \"Run these commands:\n\n \\\"chown mongod \\\"\n \\\"chgrp mongod \\\"\n \\\"chmod 700 <\\\"\n\n (The name and location for the MongoDB configuration file will vary according\n to local circumstances. The default name and location is '/etc/mongod.conf'.)\n\n Using the default name and location the commands would be:\n\n > chown mongod /etc/mongod.conf\n > chgrp mongod /etc/mongod.conf\n > chmod 700 /etc/mongod.conf\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000121-DB-000202'\n tag \"satisfies\": %w(SRG-APP-000121-DB-000202 SRG-APP-000122-DB-000203\n SRG-APP-000122-DB-000204)\n tag \"gid\": 'V-81851'\n tag \"rid\": 'SV-96565r1_rule'\n tag \"stig_id\": 'MD3X-00-000220'\n tag \"fix_id\": 'F-88701r1_fix'\n tag \"cci\": %w(CCI-001493 CCI-001494 CCI-001495)\n tag \"nist\": ['AU-9']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongodb_service_account = input('mongodb_service_account')\n mongodb_service_group = input('mongodb_service_group')\n\n describe file(input('mongod_conf')) do\n it { should_not be_more_permissive_than('0700') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\nend\n","source_location":{"ref":"./controls/V-81851.rb","line":1},"id":"V-81851"},{"title":"MongoDB must map the PKI-authenticated identity to an associated user\n account.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n Once a PKI certificate has been validated, it must be mapped to a DBMS user\n account for the authenticated identity to be meaningful to MongoDB and useful\n for authorization decisions.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n Once a PKI certificate has been validated, it must be mapped to a DBMS user\n account for the authenticated identity to be meaningful to MongoDB and useful\n for authorization decisions.","check":"To authenticate with a client certificate, you must first add\n the value of the subject from the client certificate as a MongoDB user.\n\n Each unique x.509 client certificate corresponds to a single MongoDB user; i.e.\n you cannot use a single client certificate to authenticate more than one\n MongoDB user.\n\n Login to MongoDB and run the following command:\n\n use $external\n db.getUsers()\n\n If the output does not contain a Relative Distinguished Name (RDN) for an\n authorized user, this is a finding.\n\n If the output shows a Relative Distinguished Name (RDN) for users that are not\n authorized, this is a finding.","fix":"Add x.509 Certificate subject as an authorized user.\n\n To authenticate with a client certificate, you must first add the value of the\n subject from the client certificate as a MongoDB user.\n\n Each unique x.509 client certificate corresponds to a single MongoDB user; i.e.\n you cannot use a single client certificate to authenticate more than one\n MongoDB user.\n\n Note: The RDNs in the subject string must be compatible with the RFC2253\n standard.\n\n Retrieve the RFC2253 formatted subject from the client certificate with the\n following command:\n openssl x509 -in -inform PEM -subject -nameopt RFC2253\n\n The command returns the subject string as well as certificate:\n subject= CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry\n -----BEGIN CERTIFICATE-----\n # ...\n -----END CERTIFICATE-----\n\n Add the RFC2253 compliant value of the subject as a user. Omit spaces as needed.\n\n For example, in the mongo shell, to add the user with both the \"readWrite\"\n role in the test database and the \"userAdminAnyDatabase\" role which is\n defined only in the admin database:\n db.getSiblingDB(\"$external\").runCommand(\n {\n createUser:\n \"CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry\",\n roles: [\n { role: 'readWrite', db: 'test' },\n { role: 'userAdminAnyDatabase', db: 'admin' }\n ],\n writeConcern: { w: \"majority\" , wtimeout: 5000 }\n }\n )\n\n In the above example, to add the user with the \"readWrite\" role in the test\n database, the role specification document specified \"test\" in the \"db\"\n field. To add \"userAdminAnyDatabase\" role for the user, the above example\n specified \"admin\" in the \"db\" field.\n\n Note: Some roles are defined only in the admin database, including:\n clusterAdmin, readAnyDatabase, readWriteAnyDatabase, dbAdminAnyDatabase, and\n userAdminAnyDatabase. To add a user with these roles, specify \"admin\" in the\n \"db\" field. See Manage Users and Roles for details on adding a user with\n roles.\n\n To remove a user that is not authorized run the following command:\n\n use $external\n db.dropUser(\"\")"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000177-DB-000069","gid":"V-81873","rid":"SV-96587r1_rule","stig_id":"MD3X-00-000370","fix_id":"F-88723r1_fix","cci":["CCI-000187"],"nist":["IA-5 (2) (c)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81873' do\n title \"MongoDB must map the PKI-authenticated identity to an associated user\n account.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n Once a PKI certificate has been validated, it must be mapped to a DBMS user\n account for the authenticated identity to be meaningful to MongoDB and useful\n for authorization decisions.\"\n\n desc 'check', \"To authenticate with a client certificate, you must first add\n the value of the subject from the client certificate as a MongoDB user.\n\n Each unique x.509 client certificate corresponds to a single MongoDB user; i.e.\n you cannot use a single client certificate to authenticate more than one\n MongoDB user.\n\n Login to MongoDB and run the following command:\n\n use $external\n db.getUsers()\n\n If the output does not contain a Relative Distinguished Name (RDN) for an\n authorized user, this is a finding.\n\n If the output shows a Relative Distinguished Name (RDN) for users that are not\n authorized, this is a finding.\"\n desc 'fix', \"Add x.509 Certificate subject as an authorized user.\n\n To authenticate with a client certificate, you must first add the value of the\n subject from the client certificate as a MongoDB user.\n\n Each unique x.509 client certificate corresponds to a single MongoDB user; i.e.\n you cannot use a single client certificate to authenticate more than one\n MongoDB user.\n\n Note: The RDNs in the subject string must be compatible with the RFC2253\n standard.\n\n Retrieve the RFC2253 formatted subject from the client certificate with the\n following command:\n openssl x509 -in -inform PEM -subject -nameopt RFC2253\n\n The command returns the subject string as well as certificate:\n subject= CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry\n -----BEGIN CERTIFICATE-----\n # ...\n -----END CERTIFICATE-----\n\n Add the RFC2253 compliant value of the subject as a user. Omit spaces as needed.\n\n For example, in the mongo shell, to add the user with both the \\\"readWrite\\\"\n role in the test database and the \\\"userAdminAnyDatabase\\\" role which is\n defined only in the admin database:\n db.getSiblingDB(\\\"$external\\\").runCommand(\n {\n createUser:\n \\\"CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry\\\",\n roles: [\n { role: 'readWrite', db: 'test' },\n { role: 'userAdminAnyDatabase', db: 'admin' }\n ],\n writeConcern: { w: \\\"majority\\\" , wtimeout: 5000 }\n }\n )\n\n In the above example, to add the user with the \\\"readWrite\\\" role in the test\n database, the role specification document specified \\\"test\\\" in the \\\"db\\\"\n field. To add \\\"userAdminAnyDatabase\\\" role for the user, the above example\n specified \\\"admin\\\" in the \\\"db\\\" field.\n\n Note: Some roles are defined only in the admin database, including:\n clusterAdmin, readAnyDatabase, readWriteAnyDatabase, dbAdminAnyDatabase, and\n userAdminAnyDatabase. To add a user with these roles, specify \\\"admin\\\" in the\n \\\"db\\\" field. See Manage Users and Roles for details on adding a user with\n roles.\n\n To remove a user that is not authorized run the following command:\n\n use $external\n db.dropUser(\\\"\\\")\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000177-DB-000069'\n tag \"gid\": 'V-81873'\n tag \"rid\": 'SV-96587r1_rule'\n tag \"stig_id\": 'MD3X-00-000370'\n tag \"fix_id\": 'F-88723r1_fix'\n tag \"cci\": ['CCI-000187']\n tag \"nist\": ['IA-5 (2) (c)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure MongoDB maps the PKI-authenticated identity to an associated user\n account' do\n skip 'A manual review is required to ensure MongoDB maps the PKI-authenticated identity to an associated user\n account'\n end\nend\n","source_location":{"ref":"./controls/V-81873.rb","line":1},"id":"V-81873"},{"title":"MongoDB must check the validity of all data inputs except those\n specifically identified by the organization.","desc":"Invalid user input occurs when a user inserts data or characters into\n an application's data entry fields and the application is unprepared to process\n that data. This results in unanticipated application behavior, potentially\n leading to an application or information system compromise. Invalid user input\n is one of the primary methods employed when attempting to compromise an\n application.\n\n With respect to database management systems, one class of threat is known\n as SQL Injection, or more generally, code injection. It takes advantage of the\n dynamic execution capabilities of various programming languages, including\n dialects of SQL. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n Even when no such hijacking takes place, invalid input that gets recorded\n in the database, whether accidental or malicious, reduces the reliability and\n usability of the system. Available protections include data types, referential\n constraints, uniqueness constraints, range checking, and application-specific\n logic. Application-specific logic can be implemented within the database in\n stored procedures and triggers, where appropriate.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"Invalid user input occurs when a user inserts data or characters into\n an application's data entry fields and the application is unprepared to process\n that data. This results in unanticipated application behavior, potentially\n leading to an application or information system compromise. Invalid user input\n is one of the primary methods employed when attempting to compromise an\n application.\n\n With respect to database management systems, one class of threat is known\n as SQL Injection, or more generally, code injection. It takes advantage of the\n dynamic execution capabilities of various programming languages, including\n dialects of SQL. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n Even when no such hijacking takes place, invalid input that gets recorded\n in the database, whether accidental or malicious, reduces the reliability and\n usability of the system. Available protections include data types, referential\n constraints, uniqueness constraints, range checking, and application-specific\n logic. Application-specific logic can be implemented within the database in\n stored procedures and triggers, where appropriate.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"As a client program assembles a query in MongoDB, it builds a\n BSON object, not a string. Thus traditional SQL injection attacks are not a\n problem. However, MongoDB operations permit arbitrary JavaScript expressions to\n be run directly on the server.\n\n If the \"security.javascriptEnabled\" option is set to \"true\" in the config\n file, this is a finding.\n\n Starting with MongoDB 3.2, database-level document validation can be configured\n for specific collections. Configured validation rules for the selected database\n can be viewed via the db.getSisterDB(\"database_name\").getCollectionInfos()\n command in mongo shell.\n\n If validation is desired, but no rules are set, the valdiationAction is not\n \"error\" or the \"bypassDocumentValidation\" option is used for write commands\n on the application side, this is a finding.","fix":"Disable the javascriptEnabled option in the config file.\n\n security:\n javascriptEnabled: false\n\n If document validation is needed, it should be configured according to the\n documentation page at\n https://docs.mongodb.com/manual/core/document-validation/."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000251-DB-000160","gid":"V-81889","rid":"SV-96603r1_rule","stig_id":"MD3X-00-000490","fix_id":"F-88739r1_fix","cci":["CCI-001310"],"nist":["SI-10"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81889' do\n title \"MongoDB must check the validity of all data inputs except those\n specifically identified by the organization.\"\n desc \"Invalid user input occurs when a user inserts data or characters into\n an application's data entry fields and the application is unprepared to process\n that data. This results in unanticipated application behavior, potentially\n leading to an application or information system compromise. Invalid user input\n is one of the primary methods employed when attempting to compromise an\n application.\n\n With respect to database management systems, one class of threat is known\n as SQL Injection, or more generally, code injection. It takes advantage of the\n dynamic execution capabilities of various programming languages, including\n dialects of SQL. Potentially, the attacker can gain unauthorized access to\n data, including security settings, and severely corrupt or destroy the database.\n\n Even when no such hijacking takes place, invalid input that gets recorded\n in the database, whether accidental or malicious, reduces the reliability and\n usability of the system. Available protections include data types, referential\n constraints, uniqueness constraints, range checking, and application-specific\n logic. Application-specific logic can be implemented within the database in\n stored procedures and triggers, where appropriate.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"As a client program assembles a query in MongoDB, it builds a\n BSON object, not a string. Thus traditional SQL injection attacks are not a\n problem. However, MongoDB operations permit arbitrary JavaScript expressions to\n be run directly on the server.\n\n If the \\\"security.javascriptEnabled\\\" option is set to \\\"true\\\" in the config\n file, this is a finding.\n\n Starting with MongoDB 3.2, database-level document validation can be configured\n for specific collections. Configured validation rules for the selected database\n can be viewed via the db.getSisterDB(\\\"database_name\\\").getCollectionInfos()\n command in mongo shell.\n\n If validation is desired, but no rules are set, the valdiationAction is not\n \\\"error\\\" or the \\\"bypassDocumentValidation\\\" option is used for write commands\n on the application side, this is a finding.\"\n desc 'fix', \"Disable the javascriptEnabled option in the config file.\n\n security:\n javascriptEnabled: false\n\n If document validation is needed, it should be configured according to the\n documentation page at\n https://docs.mongodb.com/manual/core/document-validation/.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000251-DB-000160'\n tag \"gid\": 'V-81889'\n tag \"rid\": 'SV-96603r1_rule'\n tag \"stig_id\": 'MD3X-00-000490'\n tag \"fix_id\": 'F-88739r1_fix'\n tag \"cci\": ['CCI-001310']\n tag \"nist\": ['SI-10']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security javascriptEnabled)) { should cmp 'false' }\n end\nend\n","source_location":{"ref":"./controls/V-81889.rb","line":1},"id":"V-81889"},{"title":"MongoDB must uniquely identify and authenticate non-organizational\n users (or processes acting on behalf of non-organizational users).","desc":"Non-organizational users include all information system users other\n than organizational users, which include organizational employees or\n individuals the organization deems to have equivalent status of employees\n (e.g., contractors, guest researchers, individuals from allied nations).\n\n Non-organizational users must be uniquely identified and authenticated for\n all accesses other than those accesses explicitly identified and documented by\n the organization when related to the use of anonymous access, such as accessing\n a web server.\n\n Accordingly, a risk assessment is used in determining the authentication\n needs of the organization.\n\n Scalability, practicality, and security are simultaneously considered in\n balancing the need to ensure ease of use for access to federal information and\n information systems with the need to protect and adequately mitigate risk to\n organizational operations, organizational assets, individuals, other\n organizations, and the Nation.","descriptions":{"default":"Non-organizational users include all information system users other\n than organizational users, which include organizational employees or\n individuals the organization deems to have equivalent status of employees\n (e.g., contractors, guest researchers, individuals from allied nations).\n\n Non-organizational users must be uniquely identified and authenticated for\n all accesses other than those accesses explicitly identified and documented by\n the organization when related to the use of anonymous access, such as accessing\n a web server.\n\n Accordingly, a risk assessment is used in determining the authentication\n needs of the organization.\n\n Scalability, practicality, and security are simultaneously considered in\n balancing the need to ensure ease of use for access to federal information and\n information systems with the need to protect and adequately mitigate risk to\n organizational operations, organizational assets, individuals, other\n organizations, and the Nation.","check":"MongoDB grants access to data and commands through role-based\n authorization and provides built-in roles that provide the different levels of\n access commonly needed in a database system. You can additionally create\n user-defined roles.\n\n Check a user's role to ensure correct privileges for the function:\n\n Prereq: To view a user's roles, you must have the \"viewUser\" privilege.\n\n Connect to MongoDB.\n\n For each database in the system, identify the user's roles for the database:\n\n use \n db.getUser(\"[username]\")\n\n The server will return a document with the user's roles.\n\n View a role's privileges:\n\n Prereq: To view a user's roles, you must have the \"viewUser\" privilege.\n\n For each database, identify the privileges granted by a role:\n\n use \n db.getRole( \"read\", { showPrivileges: true } )\n\n The server will return a document with the \"privileges\" and\n \"inheritedPrivileges\" arrays. The \"privileges returned document lists the\n privileges directly specified by the role and excludes those privileges\n inherited from other roles. The \"inheritedPrivileges\" returned document lists\n all privileges granted by this role, both directly specified and inherited. If\n the role does not inherit from other roles, the two fields are the same.\n\n If a user has a role with inappropriate privileges, this is a finding.","fix":"Prereq: To view a user's roles, must have the \"viewUser\"\n privilege.\n\n Connect to MongoDB.\n\n For each database, identify the user's roles for the database.\n\n use \n db.getUser(\"[username]\")\n\n The server will return a document with the user's roles.\n\n To revoke a user's role from a database use the db.revokeRolesFromUser() method.\n\n To grant a role to a user use the db.grantRolesToUser() method."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000180-DB-000115","satisfies":["SRG-APP-000180-DB-000115","SRG-APP-000211-DB-000122","SRG-APP-000211-DB-000124"],"gid":"V-81877","rid":"SV-96591r1_rule","stig_id":"MD3X-00-000390","fix_id":"F-88727r2_fix","cci":["CCI-000804","CCI-001082","CCI-001084"],"nist":["IA-8","SC-2","SC-3"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81877' do\n title \"MongoDB must uniquely identify and authenticate non-organizational\n users (or processes acting on behalf of non-organizational users).\"\n desc \"Non-organizational users include all information system users other\n than organizational users, which include organizational employees or\n individuals the organization deems to have equivalent status of employees\n (e.g., contractors, guest researchers, individuals from allied nations).\n\n Non-organizational users must be uniquely identified and authenticated for\n all accesses other than those accesses explicitly identified and documented by\n the organization when related to the use of anonymous access, such as accessing\n a web server.\n\n Accordingly, a risk assessment is used in determining the authentication\n needs of the organization.\n\n Scalability, practicality, and security are simultaneously considered in\n balancing the need to ensure ease of use for access to federal information and\n information systems with the need to protect and adequately mitigate risk to\n organizational operations, organizational assets, individuals, other\n organizations, and the Nation.\n \"\n\n desc 'check', \"MongoDB grants access to data and commands through role-based\n authorization and provides built-in roles that provide the different levels of\n access commonly needed in a database system. You can additionally create\n user-defined roles.\n\n Check a user's role to ensure correct privileges for the function:\n\n Prereq: To view a user's roles, you must have the \\\"viewUser\\\" privilege.\n\n Connect to MongoDB.\n\n For each database in the system, identify the user's roles for the database:\n\n use \n db.getUser(\\\"[username]\\\")\n\n The server will return a document with the user's roles.\n\n View a role's privileges:\n\n Prereq: To view a user's roles, you must have the \\\"viewUser\\\" privilege.\n\n For each database, identify the privileges granted by a role:\n\n use \n db.getRole( \\\"read\\\", { showPrivileges: true } )\n\n The server will return a document with the \\\"privileges\\\" and\n \\\"inheritedPrivileges\\\" arrays. The \\\"privileges returned document lists the\n privileges directly specified by the role and excludes those privileges\n inherited from other roles. The \\\"inheritedPrivileges\\\" returned document lists\n all privileges granted by this role, both directly specified and inherited. If\n the role does not inherit from other roles, the two fields are the same.\n\n If a user has a role with inappropriate privileges, this is a finding.\"\n desc 'fix', \"Prereq: To view a user's roles, must have the \\\"viewUser\\\"\n privilege.\n\n Connect to MongoDB.\n\n For each database, identify the user's roles for the database.\n\n use \n db.getUser(\\\"[username]\\\")\n\n The server will return a document with the user's roles.\n\n To revoke a user's role from a database use the db.revokeRolesFromUser() method.\n\n To grant a role to a user use the db.grantRolesToUser() method.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000180-DB-000115'\n tag \"satisfies\": %w(SRG-APP-000180-DB-000115 SRG-APP-000211-DB-000122\n SRG-APP-000211-DB-000124)\n tag \"gid\": 'V-81877'\n tag \"rid\": 'SV-96591r1_rule'\n tag \"stig_id\": 'MD3X-00-000390'\n tag \"fix_id\": 'F-88727r2_fix'\n tag \"cci\": %w(CCI-000804 CCI-001082 CCI-001084)\n tag \"nist\": %w(IA-8 SC-2 SC-3)\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getUsers()\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Manually verify roles for User: `#{entry['user']}` within Database: `#{entry['db']}`\n Roles: #{entry['roles']}\" do\n skip\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81877.rb","line":1},"id":"V-81877"},{"title":"MongoDB must implement cryptographic mechanisms to prevent\n unauthorized modification of organization-defined information at rest (to\n include, at a minimum, PII and classified information) on organization-defined\n information system components.","desc":"DBMSs handling data requiring \"data at rest\" protections must employ\n cryptographic mechanisms to prevent unauthorized disclosure and modification of\n the information at rest. These cryptographic mechanisms may be native to\n MongoDB or implemented via additional software or operating system/file system\n settings, as appropriate to the situation.\n\n Selection of a cryptographic mechanism is based on the need to protect the\n integrity of organizational information. The strength of the mechanism is\n commensurate with the security category and/or classification of the\n information. Organizations have the flexibility to either encrypt all\n information on storage devices (i.e., full disk encryption) or encrypt specific\n data structures (e.g., files, records, or fields).\n\n The decision whether and what to encrypt rests with the data owner and is\n also influenced by the physical measures taken to secure the equipment and\n media on which the information resides.","descriptions":{"default":"DBMSs handling data requiring \"data at rest\" protections must employ\n cryptographic mechanisms to prevent unauthorized disclosure and modification of\n the information at rest. These cryptographic mechanisms may be native to\n MongoDB or implemented via additional software or operating system/file system\n settings, as appropriate to the situation.\n\n Selection of a cryptographic mechanism is based on the need to protect the\n integrity of organizational information. The strength of the mechanism is\n commensurate with the security category and/or classification of the\n information. Organizations have the flexibility to either encrypt all\n information on storage devices (i.e., full disk encryption) or encrypt specific\n data structures (e.g., files, records, or fields).\n\n The decision whether and what to encrypt rests with the data owner and is\n also influenced by the physical measures taken to secure the equipment and\n media on which the information resides.","check":"Review the documentation and/or specification for the\n organization-defined information.\n\n If any data is PII, classified or is deemed by the organization to be encrypted\n at rest, this is a finding.\n\n Verify the mongod command line contain the following options:\n\n --enableEncryption\n --kmipServerName \n --kmipPort \n --kmipServerCAFile ca.pem\n --kmipClientCertificateFile client.pem\n\n If these above options are not part of the mongod command line, this is a\n finding.\n\n Items in the <> above and starting with kmip* are specific to the KMIP\n appliance and need to be set according to the KMIP appliance configuration.","fix":"Configure MongoDB to use the Encrypted Storage Engine and a KMIP\n appliance as documented here:\n\n https://docs.mongodb.com/v3.4/core/security-encryption-at-rest/\n https://docs.mongodb.com/v3.4/tutorial/configure-encryption/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000428-DB-000386","satisfies":["SRG-APP-000428-DB-000386","SRG-APP-000429-DB-000387"],"gid":"V-81919","rid":"SV-96633r1_rule","stig_id":"MD3X-00-000740","fix_id":"F-88769r1_fix","cci":["CCI-002475"],"nist":["SC-28 (1)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81919' do\n title \"MongoDB must implement cryptographic mechanisms to prevent\n unauthorized modification of organization-defined information at rest (to\n include, at a minimum, PII and classified information) on organization-defined\n information system components.\"\n desc \"DBMSs handling data requiring \\\"data at rest\\\" protections must employ\n cryptographic mechanisms to prevent unauthorized disclosure and modification of\n the information at rest. These cryptographic mechanisms may be native to\n MongoDB or implemented via additional software or operating system/file system\n settings, as appropriate to the situation.\n\n Selection of a cryptographic mechanism is based on the need to protect the\n integrity of organizational information. The strength of the mechanism is\n commensurate with the security category and/or classification of the\n information. Organizations have the flexibility to either encrypt all\n information on storage devices (i.e., full disk encryption) or encrypt specific\n data structures (e.g., files, records, or fields).\n\n The decision whether and what to encrypt rests with the data owner and is\n also influenced by the physical measures taken to secure the equipment and\n media on which the information resides.\n\n \"\n\n desc 'check', \"Review the documentation and/or specification for the\n organization-defined information.\n\n If any data is PII, classified or is deemed by the organization to be encrypted\n at rest, this is a finding.\n\n Verify the mongod command line contain the following options:\n\n --enableEncryption\n --kmipServerName \n --kmipPort \n --kmipServerCAFile ca.pem\n --kmipClientCertificateFile client.pem\n\n If these above options are not part of the mongod command line, this is a\n finding.\n\n Items in the <> above and starting with kmip* are specific to the KMIP\n appliance and need to be set according to the KMIP appliance configuration.\"\n desc 'fix', \"Configure MongoDB to use the Encrypted Storage Engine and a KMIP\n appliance as documented here:\n\n https://docs.mongodb.com/v3.4/core/security-encryption-at-rest/\n https://docs.mongodb.com/v3.4/tutorial/configure-encryption/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000428-DB-000386'\n tag \"satisfies\": %w(SRG-APP-000428-DB-000386 SRG-APP-000429-DB-000387)\n tag \"gid\": 'V-81919'\n tag \"rid\": 'SV-96633r1_rule'\n tag \"stig_id\": 'MD3X-00-000740'\n tag \"fix_id\": 'F-88769r1_fix'\n tag \"cci\": ['CCI-002475']\n tag \"nist\": ['SC-28 (1)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe.one do\n describe yaml(input('mongod_conf')) do\n its(%w(security kmip serverName)) { should_not be_nil }\n its(%w(security kmip port)) { should_not be_nil }\n its(%w(security kmip port)) { should_not be_nil }\n its(%w(security kmip serverCAFile)) { should_not be_nil }\n its(%w(security kmip clientCertificateFile)) { should_not be_nil }\n its(%w(security enableEncryption)) { should cmp 'true' }\n end\n describe processes('mongod') do\n its('commands.join') { should match /--enableEncryption/ }\n its('commands.join') { should match /--kmipServerName/ }\n its('commands.join') { should match /--kmipPort/ }\n its('commands.join') { should match /--kmipServerCAFile/ }\n its('commands.join') { should match /--kmipClientCertificateFile/ }\n end\n end\nend\n","source_location":{"ref":"./controls/V-81919.rb","line":1},"id":"V-81919"},{"title":"MongoDB must fail to a secure state if system initialization fails,\n shutdown fails, or aborts fail.","desc":"Failure to a known state can address safety or security in accordance\n with the mission/business needs of the organization.\n\n Failure to a known secure state helps prevent a loss of confidentiality,\n integrity, or availability in the event of a failure of the information system\n or a component of the system.\n\n Failure to a known safe state helps prevent systems from failing to a state\n that may cause loss of data or unauthorized access to system resources. Systems\n that fail suddenly and with no incorporated failure state planning may leave\n the hosting system available but with a reduced security protection capability.\n Preserving information system state data also facilitates system restart and\n return to the operational mode of the organization with less disruption of\n mission/business processes.\n\n Databases must fail to a known consistent state. Transactions must be\n successfully completed or rolled back.\n\n In general, security mechanisms should be designed so that a failure will\n follow the same execution path as disallowing the operation. For example,\n application security methods, such as isAuthorized(), isAuthenticated(), and\n validate(), should all return false if there is an exception during processing.\n If security controls can throw exceptions, they must be very clear about\n exactly what that condition means.\n\n Abort refers to stopping a program or function before it has finished\n naturally. The term abort refers to both requested and unexpected terminations.","descriptions":{"default":"Failure to a known state can address safety or security in accordance\n with the mission/business needs of the organization.\n\n Failure to a known secure state helps prevent a loss of confidentiality,\n integrity, or availability in the event of a failure of the information system\n or a component of the system.\n\n Failure to a known safe state helps prevent systems from failing to a state\n that may cause loss of data or unauthorized access to system resources. Systems\n that fail suddenly and with no incorporated failure state planning may leave\n the hosting system available but with a reduced security protection capability.\n Preserving information system state data also facilitates system restart and\n return to the operational mode of the organization with less disruption of\n mission/business processes.\n\n Databases must fail to a known consistent state. Transactions must be\n successfully completed or rolled back.\n\n In general, security mechanisms should be designed so that a failure will\n follow the same execution path as disallowing the operation. For example,\n application security methods, such as isAuthorized(), isAuthenticated(), and\n validate(), should all return false if there is an exception during processing.\n If security controls can throw exceptions, they must be very clear about\n exactly what that condition means.\n\n Abort refers to stopping a program or function before it has finished\n naturally. The term abort refers to both requested and unexpected terminations.","check":"Journaling is enabled by default in 64-bit systems.\n\n With journaling enabled, if mongod stops unexpectedly, the program can recover\n everything written to the journal.\n\n MongoDB will re-apply the write operations on restart and maintain a consistent\n state. By default, the greatest extent of lost writes, i.e., those not made to\n the journal, are those made in the last 100 milliseconds, plus the time it\n takes to perform the actual journal writes.\n\n Verify the mongod process startup options.\n\n If the mongod process was started with the \"--nojournal\" option, this is a\n finding.","fix":"Modify the mongod startup command-line options by removing the\n \"--nojournal\" option.\n\n Edit the MongoDB database configuration file (default location:\n /etc/mongod.conf) to ensure it contains the following parameter setting:\n\n storage:\n journal:\n enabled: true\n\n Stop/start (restart) any or all mongod processes."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000225-DB-000153","satisfies":["SRG-APP-000225-DB-000153","SRG-APP-000226-DB-000147"],"gid":"V-81881","rid":"SV-96595r1_rule","stig_id":"MD3X-00-000420","fix_id":"F-88731r1_fix","cci":["CCI-001190","CCI-001665"],"nist":["SC-24"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81881' do\n title \"MongoDB must fail to a secure state if system initialization fails,\n shutdown fails, or aborts fail.\"\n desc \"Failure to a known state can address safety or security in accordance\n with the mission/business needs of the organization.\n\n Failure to a known secure state helps prevent a loss of confidentiality,\n integrity, or availability in the event of a failure of the information system\n or a component of the system.\n\n Failure to a known safe state helps prevent systems from failing to a state\n that may cause loss of data or unauthorized access to system resources. Systems\n that fail suddenly and with no incorporated failure state planning may leave\n the hosting system available but with a reduced security protection capability.\n Preserving information system state data also facilitates system restart and\n return to the operational mode of the organization with less disruption of\n mission/business processes.\n\n Databases must fail to a known consistent state. Transactions must be\n successfully completed or rolled back.\n\n In general, security mechanisms should be designed so that a failure will\n follow the same execution path as disallowing the operation. For example,\n application security methods, such as isAuthorized(), isAuthenticated(), and\n validate(), should all return false if there is an exception during processing.\n If security controls can throw exceptions, they must be very clear about\n exactly what that condition means.\n\n Abort refers to stopping a program or function before it has finished\n naturally. The term abort refers to both requested and unexpected terminations.\n \"\n\n desc 'check', \"Journaling is enabled by default in 64-bit systems.\n\n With journaling enabled, if mongod stops unexpectedly, the program can recover\n everything written to the journal.\n\n MongoDB will re-apply the write operations on restart and maintain a consistent\n state. By default, the greatest extent of lost writes, i.e., those not made to\n the journal, are those made in the last 100 milliseconds, plus the time it\n takes to perform the actual journal writes.\n\n Verify the mongod process startup options.\n\n If the mongod process was started with the \\\"--nojournal\\\" option, this is a\n finding.\"\n desc 'fix', \"Modify the mongod startup command-line options by removing the\n \\\"--nojournal\\\" option.\n\n Edit the MongoDB database configuration file (default location:\n /etc/mongod.conf) to ensure it contains the following parameter setting:\n\n storage:\n journal:\n enabled: true\n\n Stop/start (restart) any or all mongod processes.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000225-DB-000153'\n tag \"satisfies\": %w(SRG-APP-000225-DB-000153 SRG-APP-000226-DB-000147)\n tag \"gid\": 'V-81881'\n tag \"rid\": 'SV-96595r1_rule'\n tag \"stig_id\": 'MD3X-00-000420'\n tag \"fix_id\": 'F-88731r1_fix'\n tag \"cci\": %w(CCI-001190 CCI-001665)\n tag \"nist\": ['SC-24']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(storage journal enabled)) { should cmp 'true' }\n end\n\n describe processes('mongod') do\n its('commands.join') { should_not match /--nojournal/ }\n end\nend\n","source_location":{"ref":"./controls/V-81881.rb","line":1},"id":"V-81881"},{"title":"MongoDB must require users to reauthenticate when organization-defined\n circumstances or situations require reauthentication.","desc":"The DoD standard for authentication of an interactive user is the\n presentation of a Common Access Card (CAC) or other physical token bearing a\n valid, current, DoD-issued Public Key Infrastructure (PKI) certificate, coupled\n with a Personal Identification Number (PIN) to be entered by the user at the\n beginning of each session and whenever reauthentication is required.\n\n Without reauthentication, users may access resources or perform tasks for\n which they do not have authorization.\n\n When applications provide the capability to change security roles or\n escalate the functional capability of the application, it is critical the user\n reauthenticate.\n\n In addition to the reauthentication requirements associated with session\n locks, organizations may require reauthentication of individuals and/or devices\n in other situations, including (but not limited to) the following circumstances:\n\n (i) When authenticators change;\n (ii) When roles change;\n (iii) When security categories of information systems change;\n (iv) When the execution of privileged functions occurs;\n (v) After a fixed period of time; or\n (vi) Periodically.\n\n Within the DoD, the minimum circumstances requiring reauthentication are\n privilege escalation and role changes.","descriptions":{"default":"The DoD standard for authentication of an interactive user is the\n presentation of a Common Access Card (CAC) or other physical token bearing a\n valid, current, DoD-issued Public Key Infrastructure (PKI) certificate, coupled\n with a Personal Identification Number (PIN) to be entered by the user at the\n beginning of each session and whenever reauthentication is required.\n\n Without reauthentication, users may access resources or perform tasks for\n which they do not have authorization.\n\n When applications provide the capability to change security roles or\n escalate the functional capability of the application, it is critical the user\n reauthenticate.\n\n In addition to the reauthentication requirements associated with session\n locks, organizations may require reauthentication of individuals and/or devices\n in other situations, including (but not limited to) the following circumstances:\n\n (i) When authenticators change;\n (ii) When roles change;\n (iii) When security categories of information systems change;\n (iv) When the execution of privileged functions occurs;\n (v) After a fixed period of time; or\n (vi) Periodically.\n\n Within the DoD, the minimum circumstances requiring reauthentication are\n privilege escalation and role changes.","check":"If organization-defined circumstances or situations require\n reauthentication, and these situations are not configured to terminate existing\n logins to require reauthentication, this is a finding.","fix":"Determine the organization-defined circumstances or situations\n that require reauthentication and ensure that the mongod and mongos processes\n are stopped/started (restart)."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000389-DB-000372","gid":"V-81913","rid":"SV-96627r1_rule","stig_id":"MD3X-00-000700","fix_id":"F-88763r1_fix","cci":["CCI-002038"],"nist":["IA-11"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81913' do\n title \"MongoDB must require users to reauthenticate when organization-defined\n circumstances or situations require reauthentication.\"\n desc \"The DoD standard for authentication of an interactive user is the\n presentation of a Common Access Card (CAC) or other physical token bearing a\n valid, current, DoD-issued Public Key Infrastructure (PKI) certificate, coupled\n with a Personal Identification Number (PIN) to be entered by the user at the\n beginning of each session and whenever reauthentication is required.\n\n Without reauthentication, users may access resources or perform tasks for\n which they do not have authorization.\n\n When applications provide the capability to change security roles or\n escalate the functional capability of the application, it is critical the user\n reauthenticate.\n\n In addition to the reauthentication requirements associated with session\n locks, organizations may require reauthentication of individuals and/or devices\n in other situations, including (but not limited to) the following circumstances:\n\n (i) When authenticators change;\n (ii) When roles change;\n (iii) When security categories of information systems change;\n (iv) When the execution of privileged functions occurs;\n (v) After a fixed period of time; or\n (vi) Periodically.\n\n Within the DoD, the minimum circumstances requiring reauthentication are\n privilege escalation and role changes.\n \"\n\n desc 'check', \"If organization-defined circumstances or situations require\n reauthentication, and these situations are not configured to terminate existing\n logins to require reauthentication, this is a finding.\"\n desc 'fix', \"Determine the organization-defined circumstances or situations\n that require reauthentication and ensure that the mongod and mongos processes\n are stopped/started (restart).\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000389-DB-000372'\n tag \"gid\": 'V-81913'\n tag \"rid\": 'SV-96627r1_rule'\n tag \"stig_id\": 'MD3X-00-000700'\n tag \"fix_id\": 'F-88763r1_fix'\n tag \"cci\": ['CCI-002038']\n tag \"nist\": ['IA-11']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to ensure MongoDB requires users to reauthenticate when organization-defined\n circumstances or situations require reauthentication.' do\n skip 'A manual review is required to ensure MongoDB requires users to reauthenticate when organization-defined\n circumstances or situations require reauthentication.'\n end\nend\n","source_location":{"ref":"./controls/V-81913.rb","line":1},"id":"V-81913"},{"title":"MongoDB must maintain the authenticity of communications sessions by\n 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\n the adversary guessing at valid session identifiers based on patterns in\n identifiers already known.\n\n The preferred technique for thwarting guesses at Session IDs is the\n generation of unique session identifiers using a FIPS 140-2 approved random\n number generator.\n\n However, it is recognized that available DBMS products do not all implement\n the preferred technique yet may have other protections against session\n hijacking. Therefore, other techniques are acceptable, provided they are\n demonstrated to be effective.","descriptions":{"default":"One class of man-in-the-middle, or session hijacking, attack involves\n the adversary guessing at valid session identifiers based on patterns in\n identifiers already known.\n\n The preferred technique for thwarting guesses at Session IDs is the\n generation of unique session identifiers using a FIPS 140-2 approved random\n number generator.\n\n However, it is recognized that available DBMS products do not all implement\n the preferred technique yet may have other protections against session\n hijacking. Therefore, other techniques are acceptable, provided they are\n demonstrated to be effective.","check":"Check the MongoDB configuration file (default location:\n /etc/mongod.conf).\n\n The following should be set:\n\n net:\n ssl:\n mode: requireSSL\n\n If this is not found in the MongoDB configuration file, this is a finding.","fix":"Follow the documentation guide at\n https://docs.mongodb.com/v3.4/tutorial/configure-ssl/.\n\n Stop/start (restart) and mongod or mongos using the MongoDB configuration file."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000224-DB-000384","gid":"V-81879","rid":"SV-96593r1_rule","stig_id":"MD3X-00-000410","fix_id":"F-88729r1_fix","cci":["CCI-001188"],"nist":["SC-23 (3)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81879' do\n title \"MongoDB must maintain the authenticity of communications sessions by\n guarding against man-in-the-middle attacks that guess at Session ID values.\"\n desc \"One class of man-in-the-middle, or session hijacking, attack involves\n the adversary guessing at valid session identifiers based on patterns in\n identifiers already known.\n\n The preferred technique for thwarting guesses at Session IDs is the\n generation of unique session identifiers using a FIPS 140-2 approved random\n number generator.\n\n However, it is recognized that available DBMS products do not all implement\n the preferred technique yet may have other protections against session\n hijacking. Therefore, other techniques are acceptable, provided they are\n demonstrated to be effective.\n \"\n\n desc 'check', \"Check the MongoDB configuration file (default location:\n /etc/mongod.conf).\n\n The following should be set:\n\n net:\n ssl:\n mode: requireSSL\n\n If this is not found in the MongoDB configuration file, this is a finding.\"\n desc 'fix', \"Follow the documentation guide at\n https://docs.mongodb.com/v3.4/tutorial/configure-ssl/.\n\n Stop/start (restart) and mongod or mongos using the MongoDB configuration file.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000224-DB-000384'\n tag \"gid\": 'V-81879'\n tag \"rid\": 'SV-96593r1_rule'\n tag \"stig_id\": 'MD3X-00-000410'\n tag \"fix_id\": 'F-88729r1_fix'\n tag \"cci\": ['CCI-001188']\n tag \"nist\": ['SC-23 (3)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl mode)) { should cmp 'requireSSL' }\n end\nend\n","source_location":{"ref":"./controls/V-81879.rb","line":1},"id":"V-81879"},{"title":"MongoDB must enforce discretionary access control policies, as defined\n by the data owner, over defined subjects and objects.","desc":"Discretionary Access Control (DAC) is based on the notion that\n individual users are \"owners\" of objects and therefore have discretion over\n who should be authorized to access the object and in which mode (e.g., read or\n write). Ownership is usually acquired as a consequence of creating the object\n or via specified ownership assignment. DAC allows the owner to determine who\n will have access to objects they control. An example of DAC includes\n user-controlled table permissions.\n\n When discretionary access control policies are implemented, subjects are\n not constrained with regard to what actions they can take with information for\n which they have already been granted access. Thus, subjects that have been\n granted access to information are not prevented from passing (i.e., the\n subjects have the discretion to pass) the information to other subjects or\n objects.\n\n A subject that is constrained in its operation by Mandatory Access Control\n policies is still able to operate under the less rigorous constraints of this\n requirement. Thus, while Mandatory Access Control imposes constraints\n preventing a subject from passing information to another subject operating at a\n different sensitivity level, this requirement permits the subject to pass the\n information to any subject at the same sensitivity level.\n\n The policy is bounded by the information system boundary. Once the\n information is passed outside of the control of the information system,\n additional means may be required to ensure the constraints remain in effect.\n While the older, more traditional definitions of discretionary access control\n require identity-based access control, that limitation is not required for this\n use of discretionary access control.","descriptions":{"default":"Discretionary Access Control (DAC) is based on the notion that\n individual users are \"owners\" of objects and therefore have discretion over\n who should be authorized to access the object and in which mode (e.g., read or\n write). Ownership is usually acquired as a consequence of creating the object\n or via specified ownership assignment. DAC allows the owner to determine who\n will have access to objects they control. An example of DAC includes\n user-controlled table permissions.\n\n When discretionary access control policies are implemented, subjects are\n not constrained with regard to what actions they can take with information for\n which they have already been granted access. Thus, subjects that have been\n granted access to information are not prevented from passing (i.e., the\n subjects have the discretion to pass) the information to other subjects or\n objects.\n\n A subject that is constrained in its operation by Mandatory Access Control\n policies is still able to operate under the less rigorous constraints of this\n requirement. Thus, while Mandatory Access Control imposes constraints\n preventing a subject from passing information to another subject operating at a\n different sensitivity level, this requirement permits the subject to pass the\n information to any subject at the same sensitivity level.\n\n The policy is bounded by the information system boundary. Once the\n information is passed outside of the control of the information system,\n additional means may be required to ensure the constraints remain in effect.\n While the older, more traditional definitions of discretionary access control\n require identity-based access control, that limitation is not required for this\n use of discretionary access control.","check":"Review the system documentation to obtain the definition of the\n database/DBMS functionality considered privileged in the context of the system\n in question.\n\n If any functionality considered privileged has access privileges granted to\n non-privileged users, this is a finding.","fix":"Revoke any roles with unnecessary privileges to privileged\n functionality by executing the revoke command as documented here:\n https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/\n\n Revoke any unnecessary privileges from any roles by executing the revoke\n command as document here:\n https://docs.mongodb.com/v3.4/reference/method/db.revokePrivilegesFromRole/\n\n If a new role with associated privileges needs to be created, follow the\n documentation here:\n https://docs.mongodb.com/v3.4/reference/command/createRole/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000328-DB-000301","satisfies":["SRG-APP-000328-DB-000301","SRG-APP-000340-DB-000304"],"gid":"V-81899","rid":"SV-96613r1_rule","stig_id":"MD3X-00-000570","fix_id":"F-88749r1_fix","cci":["CCI-002165","CCI-002235"],"nist":["AC-3 (4)","AC-6 (10)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81899' do\n title \"MongoDB must enforce discretionary access control policies, as defined\n by the data owner, over defined subjects and objects.\"\n desc \"Discretionary Access Control (DAC) is based on the notion that\n individual users are \\\"owners\\\" of objects and therefore have discretion over\n who should be authorized to access the object and in which mode (e.g., read or\n write). Ownership is usually acquired as a consequence of creating the object\n or via specified ownership assignment. DAC allows the owner to determine who\n will have access to objects they control. An example of DAC includes\n user-controlled table permissions.\n\n When discretionary access control policies are implemented, subjects are\n not constrained with regard to what actions they can take with information for\n which they have already been granted access. Thus, subjects that have been\n granted access to information are not prevented from passing (i.e., the\n subjects have the discretion to pass) the information to other subjects or\n objects.\n\n A subject that is constrained in its operation by Mandatory Access Control\n policies is still able to operate under the less rigorous constraints of this\n requirement. Thus, while Mandatory Access Control imposes constraints\n preventing a subject from passing information to another subject operating at a\n different sensitivity level, this requirement permits the subject to pass the\n information to any subject at the same sensitivity level.\n\n The policy is bounded by the information system boundary. Once the\n information is passed outside of the control of the information system,\n additional means may be required to ensure the constraints remain in effect.\n While the older, more traditional definitions of discretionary access control\n require identity-based access control, that limitation is not required for this\n use of discretionary access control.\n \"\n\n desc 'check', \"Review the system documentation to obtain the definition of the\n database/DBMS functionality considered privileged in the context of the system\n in question.\n\n If any functionality considered privileged has access privileges granted to\n non-privileged users, this is a finding.\"\n desc 'fix', \"Revoke any roles with unnecessary privileges to privileged\n functionality by executing the revoke command as documented here:\n https://docs.mongodb.com/v3.4/reference/method/db.revokeRolesFromUser/\n\n Revoke any unnecessary privileges from any roles by executing the revoke\n command as document here:\n https://docs.mongodb.com/v3.4/reference/method/db.revokePrivilegesFromRole/\n\n If a new role with associated privileges needs to be created, follow the\n documentation here:\n https://docs.mongodb.com/v3.4/reference/command/createRole/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000328-DB-000301'\n tag \"satisfies\": %w(SRG-APP-000328-DB-000301 SRG-APP-000340-DB-000304)\n tag \"gid\": 'V-81899'\n tag \"rid\": 'SV-96613r1_rule'\n tag \"stig_id\": 'MD3X-00-000570'\n tag \"fix_id\": 'F-88749r1_fix'\n tag \"cci\": %w(CCI-002165 CCI-002235)\n tag \"nist\": ['AC-3 (4)', 'AC-6 (10)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe 'A manual review is required to determine if any functionality considered privileged has access privileges granted to non-privileged users' do\n skip 'A manual review is required to determine if any functionality considered privileged has access privileges granted to non-privileged users'\n end\nend\n","source_location":{"ref":"./controls/V-81899.rb","line":1},"id":"V-81899"},{"title":"Unused database components, DBMS software, and database objects must\n be removed.","desc":"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.","descriptions":{"default":"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.","check":"Review the list of components and features installed with the\n MongoDB database.\n\n If unused components are installed and are not documented and authorized, this\n is a finding.\n\n RPM can also be used to check to see what is installed:\n\n yum list installed | grep mongodb\n\n This returns MongoDB database packages that have been installed.\n\n If any packages displayed by this command are not being used, this is a\n finding.","fix":"On data-bearing nodes and arbiter nodes, the\n mongodb-enterprise-tools, mongodb-enterprise-shell and\n mongodb-enterprise-mongos can be removed (or not installed).\n\n On applications servers that typically run the mongos process when connecting\n to a shared cluster, the only package required is the mongodb-enterprise-mongos\n package."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000141-DB-000091","gid":"V-81859","rid":"SV-96573r1_rule","stig_id":"MD3X-00-000280","fix_id":"F-88709r1_fix","cci":["CCI-000381"],"nist":["CM-7 a"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81859' do\n title \"Unused database components, DBMS software, and database objects must\n be removed.\"\n desc \"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.\n \"\n\n desc 'check', \"Review the list of components and features installed with the\n MongoDB database.\n\n If unused components are installed and are not documented and authorized, this\n is a finding.\n\n RPM can also be used to check to see what is installed:\n\n yum list installed | grep mongodb\n\n This returns MongoDB database packages that have been installed.\n\n If any packages displayed by this command are not being used, this is a\n finding.\"\n desc 'fix', \"On data-bearing nodes and arbiter nodes, the\n mongodb-enterprise-tools, mongodb-enterprise-shell and\n mongodb-enterprise-mongos can be removed (or not installed).\n\n On applications servers that typically run the mongos process when connecting\n to a shared cluster, the only package required is the mongodb-enterprise-mongos\n package.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000141-DB-000091'\n tag \"gid\": 'V-81859'\n tag \"rid\": 'SV-96573r1_rule'\n tag \"stig_id\": 'MD3X-00-000280'\n tag \"fix_id\": 'F-88709r1_fix'\n tag \"cci\": ['CCI-000381']\n tag \"nist\": ['CM-7 a']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n approved_mongo_packages = input('approved_mongo_packages')\n\n dpkg_packages = packages(/mongodb/).names\n if dpkg_packages.empty?\n describe 'There are no mongo database packages installed, therefore for this control is NA' do\n skip 'There are no mongo database packages installed, therefore for this control is NA'\n end\n else\n dpkg_packages.each do |package|\n describe \"The installed mongodb package: #{package}\" do\n subject { package }\n it { should be_in approved_mongo_packages }\n end\n end\n end\nend\n","source_location":{"ref":"./controls/V-81859.rb","line":1},"id":"V-81859"},{"title":"MongoDB must maintain the confidentiality and integrity of information\n during preparation for transmission.","desc":"Information can be either unintentionally or maliciously disclosed or\n modified during preparation for transmission, including, for example, during\n aggregation, at protocol transformation points, and during packing/unpacking.\n These unauthorized disclosures or modifications compromise the confidentiality\n or integrity of the information.\n\n Use of this requirement will be limited to situations where the data owner\n has a strict requirement for ensuring data integrity and confidentiality is\n maintained at every step of the data transfer and handling process.\n\n When transmitting data, MongoDB, associated applications, and\n infrastructure must leverage transmission protection mechanisms.","descriptions":{"default":"Information can be either unintentionally or maliciously disclosed or\n modified during preparation for transmission, including, for example, during\n aggregation, at protocol transformation points, and during packing/unpacking.\n These unauthorized disclosures or modifications compromise the confidentiality\n or integrity of the information.\n\n Use of this requirement will be limited to situations where the data owner\n has a strict requirement for ensuring data integrity and confidentiality is\n maintained at every step of the data transfer and handling process.\n\n When transmitting data, MongoDB, associated applications, and\n infrastructure must leverage transmission protection mechanisms.","check":"Review the system information/specification for information\n indicating a strict requirement for data integrity and confidentiality when\n data is being prepared to be transmitted.\n\n If such information is absent therein, this is not a finding.\n\n If such information is present, inspect the MongoDB configuration file (default\n location: /etc/mongod.conf) for the following entries:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n If net.ssl.mode is not set to \"requireSSL\", this is a finding.","fix":"Stop the MongoDB instance if it is running. Obtain a certificate\n from a valid DoD certificate authority to be used for encrypted data\n transmission. Modify the MongoDB configuration file with ssl configuration\n options such as:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n Set \"net.ssl.mode\" to the \"requireSSL\".\n Set \"net.ssl.KeyFile\" to the full path of the certificate (.pem) file.\n\n Start/stop (restart) all mongod or mongos instances using the MongoDB\n configuration file (default location: /etc/mongod.conf)."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000441-DB-000378","gid":"V-81921","rid":"SV-96635r1_rule","stig_id":"MD3X-00-000760","fix_id":"F-88771r1_fix","cci":["CCI-002420"],"nist":["SC-8 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81921' do\n title \"MongoDB must maintain the confidentiality and integrity of information\n during preparation for transmission.\"\n desc \"Information can be either unintentionally or maliciously disclosed or\n modified during preparation for transmission, including, for example, during\n aggregation, at protocol transformation points, and during packing/unpacking.\n These unauthorized disclosures or modifications compromise the confidentiality\n or integrity of the information.\n\n Use of this requirement will be limited to situations where the data owner\n has a strict requirement for ensuring data integrity and confidentiality is\n maintained at every step of the data transfer and handling process.\n\n When transmitting data, MongoDB, associated applications, and\n infrastructure must leverage transmission protection mechanisms.\n \"\n\n desc 'check', \"Review the system information/specification for information\n indicating a strict requirement for data integrity and confidentiality when\n data is being prepared to be transmitted.\n\n If such information is absent therein, this is not a finding.\n\n If such information is present, inspect the MongoDB configuration file (default\n location: /etc/mongod.conf) for the following entries:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n If net.ssl.mode is not set to \\\"requireSSL\\\", this is a finding.\"\n desc 'fix', \"Stop the MongoDB instance if it is running. Obtain a certificate\n from a valid DoD certificate authority to be used for encrypted data\n transmission. Modify the MongoDB configuration file with ssl configuration\n options such as:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n\n Set \\\"net.ssl.mode\\\" to the \\\"requireSSL\\\".\n Set \\\"net.ssl.KeyFile\\\" to the full path of the certificate (.pem) file.\n\n Start/stop (restart) all mongod or mongos instances using the MongoDB\n configuration file (default location: /etc/mongod.conf).\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000441-DB-000378'\n tag \"gid\": 'V-81921'\n tag \"rid\": 'SV-96635r1_rule'\n tag \"stig_id\": 'MD3X-00-000760'\n tag \"fix_id\": 'F-88771r1_fix'\n tag \"cci\": ['CCI-002420']\n tag \"nist\": ['SC-8 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl mode)) { should cmp 'requireSSL' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl PEMKeyFile)) { should_not be nil }\n end\nend\n","source_location":{"ref":"./controls/V-81921.rb","line":1},"id":"V-81921"},{"title":"MongoDB must use NIST FIPS 140-2-validated cryptographic modules for\n cryptographic operations.","desc":"Use of weak or not validated cryptographic algorithms undermines the\n purposes of utilizing encryption and digital signatures to protect data. Weak\n algorithms can be easily broken and not validated cryptographic modules may not\n implement algorithms correctly. Unapproved cryptographic modules or algorithms\n should not be relied on for authentication, confidentiality, or integrity. Weak\n cryptography could allow an attacker to gain access to and modify data stored\n in the database as well as the administration settings of MongoDB.\n\n Applications, including DBMSs, utilizing cryptography are required to use\n approved NIST FIPS 140-2-validated cryptographic modules that meet the\n requirements of applicable federal laws, Executive Orders, directives,\n policies, regulations, standards, and guidance.\n\n The security functions validated as part of FIPS 140-2 for cryptographic\n modules are described in FIPS 140-2 Annex A.\n\n NSA Type-X (where X=1, 2, 3, 4) products are NSA-certified, hardware-based\n encryption modules.","descriptions":{"default":"Use of weak or not validated cryptographic algorithms undermines the\n purposes of utilizing encryption and digital signatures to protect data. Weak\n algorithms can be easily broken and not validated cryptographic modules may not\n implement algorithms correctly. Unapproved cryptographic modules or algorithms\n should not be relied on for authentication, confidentiality, or integrity. Weak\n cryptography could allow an attacker to gain access to and modify data stored\n in the database as well as the administration settings of MongoDB.\n\n Applications, including DBMSs, utilizing cryptography are required to use\n approved NIST FIPS 140-2-validated cryptographic modules that meet the\n requirements of applicable federal laws, Executive Orders, directives,\n policies, regulations, standards, and guidance.\n\n The security functions validated as part of FIPS 140-2 for cryptographic\n modules are described in FIPS 140-2 Annex A.\n\n NSA Type-X (where X=1, 2, 3, 4) products are NSA-certified, hardware-based\n encryption modules.","check":"If MongoDB is deployed in a classified environment:\n\n In the MongoDB database configuration file (default location:\n /etc/mongod.conf), search for and review the following parameters:\n\n net:\n ssl:\n FIPSMode: true\n\n If this parameter is not present in the configuration file, this is a finding.\n\n If \"FIPSMode\" is set to \"false\", this is a finding.\n\n Check the server log file for a message that FIPS is active:\n Search the log for the following text \"\"FIPS 140-2 mode activated\"\".\n\n If this text is not found, this is a finding.\n\n Verify that FIPS has been enabled at the operating system. The following will\n return \"1\" if FIPS is enabled:\n cat /proc/sys/crypto/fips_enabled\n\n If the above command does not return \"1\", this is a finding.","fix":"Enable FIPS 140-2 mode for MongoDB Enterprise.\n\n Edit the MongoDB database configuration file (default location:\n /etc/mongod.conf) to contain the following parameter setting:\n\n net:\n ssl:\n FIPSMode: true\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\n\n For the operating system finding, please refer to the appropriate operating\n system documentation for the procedure to install, configure, and test FIPS\n mode."},"impact":0.7,"refs":[],"tags":{"severity":"high","gtitle":"SRG-APP-000179-DB-000114","satisfies":["SRG-APP-000179-DB-000114","SRG-APP-000514-DB-000381","SRG-APP-000514-DB-000382","SRG-APP-000514-DB-000383","SRG-APP-000416-DB-000380"],"gid":"V-81875","rid":"SV-96589r1_rule","stig_id":"MD3X-00-000380","fix_id":"F-88725r1_fix","cci":["CCI-000803","CCI-002450"],"nist":["IA-7","SC-13"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81875' do\n title \"MongoDB must use NIST FIPS 140-2-validated cryptographic modules for\n cryptographic operations.\"\n desc \"Use of weak or not validated cryptographic algorithms undermines the\n purposes of utilizing encryption and digital signatures to protect data. Weak\n algorithms can be easily broken and not validated cryptographic modules may not\n implement algorithms correctly. Unapproved cryptographic modules or algorithms\n should not be relied on for authentication, confidentiality, or integrity. Weak\n cryptography could allow an attacker to gain access to and modify data stored\n in the database as well as the administration settings of MongoDB.\n\n Applications, including DBMSs, utilizing cryptography are required to use\n approved NIST FIPS 140-2-validated cryptographic modules that meet the\n requirements of applicable federal laws, Executive Orders, directives,\n policies, regulations, standards, and guidance.\n\n The security functions validated as part of FIPS 140-2 for cryptographic\n modules are described in FIPS 140-2 Annex A.\n\n NSA Type-X (where X=1, 2, 3, 4) products are NSA-certified, hardware-based\n encryption modules.\n \"\n\n desc 'check', \"If MongoDB is deployed in a classified environment:\n\n In the MongoDB database configuration file (default location:\n /etc/mongod.conf), search for and review the following parameters:\n\n net:\n ssl:\n FIPSMode: true\n\n If this parameter is not present in the configuration file, this is a finding.\n\n If \\\"FIPSMode\\\" is set to \\\"false\\\", this is a finding.\n\n Check the server log file for a message that FIPS is active:\n Search the log for the following text \\\"\\\"FIPS 140-2 mode activated\\\"\\\".\n\n If this text is not found, this is a finding.\n\n Verify that FIPS has been enabled at the operating system. The following will\n return \\\"1\\\" if FIPS is enabled:\n cat /proc/sys/crypto/fips_enabled\n\n If the above command does not return \\\"1\\\", this is a finding.\"\n desc 'fix', \"Enable FIPS 140-2 mode for MongoDB Enterprise.\n\n Edit the MongoDB database configuration file (default location:\n /etc/mongod.conf) to contain the following parameter setting:\n\n net:\n ssl:\n FIPSMode: true\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\n\n For the operating system finding, please refer to the appropriate operating\n system documentation for the procedure to install, configure, and test FIPS\n mode.\"\n\n impact 0.7\n tag \"severity\": 'high'\n tag \"gtitle\": 'SRG-APP-000179-DB-000114'\n tag \"satisfies\": %w(SRG-APP-000179-DB-000114 SRG-APP-000514-DB-000381\n SRG-APP-000514-DB-000382 SRG-APP-000514-DB-000383\n SRG-APP-000416-DB-000380)\n tag \"gid\": 'V-81875'\n tag \"rid\": 'SV-96589r1_rule'\n tag \"stig_id\": 'MD3X-00-000380'\n tag \"fix_id\": 'F-88725r1_fix'\n tag \"cci\": %w(CCI-000803 CCI-002450)\n tag \"nist\": %w(IA-7 SC-13)\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n if input('is_sensitive')\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl FIPSMode)) { should cmp 'true' }\n end\n else\n describe 'The system is not a classified environment, therefore for this control is NA' do\n skip 'The system is not a classified environment, therefore for this control is NA'\n end\n end\nend\n","source_location":{"ref":"./controls/V-81875.rb","line":1},"id":"V-81875"},{"title":"MongoDB must obscure feedback of authentication information during the\n authentication process to protect the information from possible\n exploitation/use by unauthorized individuals.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n\n Normally, with PKI authentication, the interaction with the user for\n authentication will be handled by a software component separate from MongoDB,\n such as ActivIdentity ActivClient. However, in cases where MongoDB controls the\n interaction, this requirement applies.\n\n To prevent the compromise of authentication information such as passwords\n and PINs during the authentication process, the feedback from the system must\n not provide any information that would allow an unauthorized user to compromise\n the authentication mechanism.\n\n Obfuscation of user-provided authentication secrets when typed into the\n system is a method used in addressing this risk.\n\n Displaying asterisks when a user types in a password or a smart card PIN is\n an example of obscuring feedback of authentication secrets.\n\n This calls for review of applications, which will require collaboration\n with the application developers. It is recognized that in many cases, the\n database administrator (DBA) is organizationally separate from the application\n developers, and may have limited, if any, access to source code. Nevertheless,\n protections of this type are so important to the secure operation of databases\n that they must not be ignored. At a minimum, the DBA must attempt to obtain\n assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n\n Normally, with PKI authentication, the interaction with the user for\n authentication will be handled by a software component separate from MongoDB,\n such as ActivIdentity ActivClient. However, in cases where MongoDB controls the\n interaction, this requirement applies.\n\n To prevent the compromise of authentication information such as passwords\n and PINs during the authentication process, the feedback from the system must\n not provide any information that would allow an unauthorized user to compromise\n the authentication mechanism.\n\n Obfuscation of user-provided authentication secrets when typed into the\n system is a method used in addressing this risk.\n\n Displaying asterisks when a user types in a password or a smart card PIN is\n an example of obscuring feedback of authentication secrets.\n\n This calls for review of applications, which will require collaboration\n with the application developers. It is recognized that in many cases, the\n database administrator (DBA) is organizationally separate from the application\n developers, and may have limited, if any, access to source code. Nevertheless,\n protections of this type are so important to the secure operation of databases\n that they must not be ignored. At a minimum, the DBA must attempt to obtain\n assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"For the MongoDB command-line tools \"mongo shell\",\n \"mongodump\", \"mongorestore\", \"mongoimport\", \"mongoexport\", which cannot\n be configured not to accept a plain-text password, and any other essential tool\n with the same limitation, verify that the system documentation explains the\n need for the tool, who uses it, and any relevant mitigations and that AO\n approval has been obtained.\n\n If it is not documented, this is a finding.\n\n Request evidence that all users of these MongoDB command-line tools are trained\n in the use of the \"-p\" option plain-text password option and how to keep the\n password protected from unauthorized viewing/capture and that they adhere to\n this practice.\n\n If evidence of training does not exist, this is a finding.","fix":"For the \"mongo shell\", \"mongodump\", \"mongorestore\",\n \"mongoimport\", \"mongoexport\", which can accept a plain-text password, and\n any other essential tool with the same limitation:\n\n Document the need for it, who uses it, and any relevant mitigations, and obtain\n AO approval.\n\n Train all users of the tool in the nature of using the plain-text password\n option and in how to keep the password protected from unauthorized\n viewing/capture and document they have been trained."},"impact":0.7,"refs":[],"tags":{"severity":"high","gtitle":"SRG-APP-000178-DB-000083","gid":"V-81927","rid":"SV-96641r1_rule","stig_id":"MD3X-00-000800","fix_id":"F-88777r1_fix","cci":["CCI-000206"],"nist":["IA-6"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81927' do\n title \"MongoDB must obscure feedback of authentication information during the\n authentication process to protect the information from possible\n exploitation/use by unauthorized individuals.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n\n Normally, with PKI authentication, the interaction with the user for\n authentication will be handled by a software component separate from MongoDB,\n such as ActivIdentity ActivClient. However, in cases where MongoDB controls the\n interaction, this requirement applies.\n\n To prevent the compromise of authentication information such as passwords\n and PINs during the authentication process, the feedback from the system must\n not provide any information that would allow an unauthorized user to compromise\n the authentication mechanism.\n\n Obfuscation of user-provided authentication secrets when typed into the\n system is a method used in addressing this risk.\n\n Displaying asterisks when a user types in a password or a smart card PIN is\n an example of obscuring feedback of authentication secrets.\n\n This calls for review of applications, which will require collaboration\n with the application developers. It is recognized that in many cases, the\n database administrator (DBA) is organizationally separate from the application\n developers, and may have limited, if any, access to source code. Nevertheless,\n protections of this type are so important to the secure operation of databases\n that they must not be ignored. At a minimum, the DBA must attempt to obtain\n assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"For the MongoDB command-line tools \\\"mongo shell\\\",\n \\\"mongodump\\\", \\\"mongorestore\\\", \\\"mongoimport\\\", \\\"mongoexport\\\", which cannot\n be configured not to accept a plain-text password, and any other essential tool\n with the same limitation, verify that the system documentation explains the\n need for the tool, who uses it, and any relevant mitigations and that AO\n approval has been obtained.\n\n If it is not documented, this is a finding.\n\n Request evidence that all users of these MongoDB command-line tools are trained\n in the use of the \\\"-p\\\" option plain-text password option and how to keep the\n password protected from unauthorized viewing/capture and that they adhere to\n this practice.\n\n If evidence of training does not exist, this is a finding.\"\n desc 'fix', \"For the \\\"mongo shell\\\", \\\"mongodump\\\", \\\"mongorestore\\\",\n \\\"mongoimport\\\", \\\"mongoexport\\\", which can accept a plain-text password, and\n any other essential tool with the same limitation:\n\n Document the need for it, who uses it, and any relevant mitigations, and obtain\n AO approval.\n\n Train all users of the tool in the nature of using the plain-text password\n option and in how to keep the password protected from unauthorized\n viewing/capture and document they have been trained.\"\n\n impact 0.7\n tag \"severity\": 'high'\n tag \"gtitle\": 'SRG-APP-000178-DB-000083'\n tag \"gid\": 'V-81927'\n tag \"rid\": 'SV-96641r1_rule'\n tag \"stig_id\": 'MD3X-00-000800'\n tag \"fix_id\": 'F-88777r1_fix'\n tag \"cci\": ['CCI-000206']\n tag \"nist\": ['IA-6']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n tools = %w(mongo mongodump mongorestore mongoimport mongoexport)\n\n installed_tools = []\n\n tools.each do |tool|\n if command(tool).exist?\n installed_tools << tool\n end\n end\n\n describe \"Manually review that the use presence of tools `#{installed_tools}.to_s` is authorized and the users have the required training.\" do\n skip\n end\nend\n","source_location":{"ref":"./controls/V-81927.rb","line":1},"id":"V-81927"},{"title":"MongoDB must provide audit record generation for DoD-defined auditable\n events within all DBMS/database components.","desc":"MongoDB must provide audit record generation capability for\n DoD-defined auditable events within all DBMS/database components.","descriptions":{"default":"MongoDB must provide audit record generation capability for\n DoD-defined auditable events within all DBMS/database components.","check":"Check the MongoDB configuration file (default location:\n '/etc/mongod.conf)' for a key named 'auditLog:'.\n\n Example shown below:\n\n auditLog:\n destination: syslog\n\n If an \"auditLog:\" key is not present, this is a finding indicating that\n auditing is not turned on.\n\n If the \"auditLog:\" key is present and contains a subkey of \"filter:\" with\n an associated filter value string, this is a finding.\n\n The site auditing policy must be reviewed to determine if the \"filter:\" being\n applied meets the site auditing requirements. If not, then the filter being\n applied will need to be modified to comply.\n\n Example show below:\n\n auditLog:\n destination: syslog\n filter: '{ atype: { $in: [ \"createCollection\", \"dropCollection\" ] } }'","fix":"If the \"auditLog\" setting was not present in the MongoDB\n configuration file (default location: '/etc/mongod.conf)' edit this file and\n add a configured \"auditLog\" setting:\n\n auditLog:\n destination: syslog\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\n\n If the \"auditLog\" setting was present and contained a \"filter:\" parameter,\n ensure the \"filter:\" expression does not prevent the auditing of events that\n should be audited or remove the \"filter:\" parameter to enable auditing all\n events."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000089-DB-000064","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-000093-DB-000052","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"],"gid":"V-81847","rid":"SV-96561r1_rule","stig_id":"MD3X-00-000040","fix_id":"F-88697r1_fix","cci":["CCI-000130","CCI-000131","CCI-000132","CCI-000133","CCI-000134","CCI-000135","CCI-000140","CCI-000166","CCI-000171","CCI-000172","CCI-001462","CCI-001464","CCI-001487","CCI-001814","CCI-001844","CCI-001851","CCI-001858"],"nist":["AU-3","AU-3","AU-3","AU-3","AU-3","AU-3 (1)","AU-5 b","AU-10","AU-12 b","AU-12 c","AU-14 (2)","AU-14 (1)","AU-3","CM-5 (1)","AU-3 (2)","AU-4 (1)","AU-5 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81847' do\n title \"MongoDB must provide audit record generation for DoD-defined auditable\n events within all DBMS/database components.\"\n desc \"MongoDB must provide audit record generation capability for\n DoD-defined auditable events within all DBMS/database components.\n \"\n desc 'check', \"Check the MongoDB configuration file (default location:\n '/etc/mongod.conf)' for a key named 'auditLog:'.\n\n Example shown below:\n\n auditLog:\n destination: syslog\n\n If an \\\"auditLog:\\\" key is not present, this is a finding indicating that\n auditing is not turned on.\n\n If the \\\"auditLog:\\\" key is present and contains a subkey of \\\"filter:\\\" with\n an associated filter value string, this is a finding.\n\n The site auditing policy must be reviewed to determine if the \\\"filter:\\\" being\n applied meets the site auditing requirements. If not, then the filter being\n applied will need to be modified to comply.\n\n Example show below:\n\n auditLog:\n destination: syslog\n filter: '{ atype: { $in: [ \\\"createCollection\\\", \\\"dropCollection\\\" ] } }'\"\n desc 'fix', \"If the \\\"auditLog\\\" setting was not present in the MongoDB\n configuration file (default location: '/etc/mongod.conf)' edit this file and\n add a configured \\\"auditLog\\\" setting:\n\n auditLog:\n destination: syslog\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\n\n If the \\\"auditLog\\\" setting was present and contained a \\\"filter:\\\" parameter,\n ensure the \\\"filter:\\\" expression does not prevent the auditing of events that\n should be audited or remove the \\\"filter:\\\" parameter to enable auditing all\n events.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000089-DB-000064'\n tag \"satisfies\": %w(SRG-APP-000089-DB-000064 SRG-APP-000080-DB-000063\n SRG-APP-000090-DB-000065 SRG-APP-000091-DB-000066\n SRG-APP-000091-DB-000325 SRG-APP-000092-DB-000208\n SRG-APP-000093-DB-000052 SRG-APP-000095-DB-000039\n SRG-APP-000096-DB-000040 SRG-APP-000097-DB-000041\n SRG-APP-000098-DB-000042 SRG-APP-000099-DB-000043\n SRG-APP-000100-DB-000201 SRG-APP-000101-DB-000044\n SRG-APP-000109-DB-000049 SRG-APP-000356-DB-000315\n SRG-APP-000360-DB-000320 SRG-APP-000381-DB-000361\n SRG-APP-000492-DB-000332 SRG-APP-000492-DB-000333\n SRG-APP-000494-DB-000344 SRG-APP-000494-DB-000345\n SRG-APP-000495-DB-000326 SRG-APP-000495-DB-000327\n SRG-APP-000495-DB-000328 SRG-APP-000495-DB-000329\n SRG-APP-000496-DB-000334 SRG-APP-000496-DB-000335\n SRG-APP-000498-DB-000346 SRG-APP-000498-DB-000347\n SRG-APP-000499-DB-000330 SRG-APP-000499-DB-000331\n SRG-APP-000501-DB-000336 SRG-APP-000501-DB-000337\n SRG-APP-000502-DB-000348 SRG-APP-000502-DB-000349\n SRG-APP-000503-DB-000350 SRG-APP-000503-DB-000351\n SRG-APP-000504-DB-000354 SRG-APP-000504-DB-000355\n SRG-APP-000505-DB-000352 SRG-APP-000506-DB-000353\n SRG-APP-000507-DB-000356 SRG-APP-000507-DB-000357\n SRG-APP-000508-DB-000358 SRG-APP-000515-DB-000318)\n tag \"gid\": 'V-81847'\n tag \"rid\": 'SV-96561r1_rule'\n tag \"stig_id\": 'MD3X-00-000040'\n tag \"fix_id\": 'F-88697r1_fix'\n tag \"cci\": %w(CCI-000130 CCI-000131 CCI-000132 CCI-000133\n CCI-000134 CCI-000135 CCI-000140 CCI-000166 CCI-000171\n CCI-000172 CCI-001462 CCI-001464 CCI-001487 CCI-001814\n CCI-001844 CCI-001851 CCI-001858)\n tag \"nist\": ['AU-3', 'AU-3', 'AU-3', 'AU-3', 'AU-3', 'AU-3 (1)', 'AU-5 b',\n 'AU-10', 'AU-12 b', 'AU-12 c', 'AU-14 (2)', 'AU-14 (1)', 'AU-3', 'CM-5 (1)',\n 'AU-3 (2)', 'AU-4 (1)', 'AU-5 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog destination)) { should cmp 'syslog' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog filter)) { should be_nil }\n end\nend\n","source_location":{"ref":"./controls/V-81847.rb","line":1},"id":"V-81847"},{"title":"MongoDB must protect the confidentiality and integrity of all\n information at rest.","desc":"This control is intended to address the confidentiality and integrity\n of information at rest in non-mobile devices and covers user information and\n system information. Information at rest refers to the state of information when\n it is located on a secondary storage device (e.g., disk drive, tape drive)\n within an organizational information system. Applications and application users\n generate information throughout the course of their application use.\n\n User data generated, as well as application-specific configuration data,\n needs to be protected. Organizations may choose to employ different mechanisms\n to achieve confidentiality and integrity protections, as appropriate.\n\n If the confidentiality and integrity of application data is not protected,\n the data will be open to compromise and unauthorized modification.","descriptions":{"default":"This control is intended to address the confidentiality and integrity\n of information at rest in non-mobile devices and covers user information and\n system information. Information at rest refers to the state of information when\n it is located on a secondary storage device (e.g., disk drive, tape drive)\n within an organizational information system. Applications and application users\n generate information throughout the course of their application use.\n\n User data generated, as well as application-specific configuration data,\n needs to be protected. Organizations may choose to employ different mechanisms\n to achieve confidentiality and integrity protections, as appropriate.\n\n If the confidentiality and integrity of application data is not protected,\n the data will be open to compromise and unauthorized modification.","check":"If the MongoDB Encrypted Storage Engines is being used, ensure\n that the \"security.enableEncryption\" option is set to \"true\" in the MongoDB\n configuration file (default location: /etc/mongod.conf) or that MongoDB was\n started with the \"--enableEncryption\" command line option.\n\n Check the MongoDB configuration file (default location: /etc/mongod.conf).\n\n If the following parameter is not present, this is a finding.\n\n security:\n enableEncryption: \"true\"\n\n If any mongod process is started with \"--enableEncryption false\", this is a\n finding.","fix":"Ensure that the MongoDB Configuration file (default location:\n /etc/mongod.conf) has the following set:\n\n security:\n enableEncryption: \"true\"\n\n Ensure that any mongod process that contains the option \"--enableEcryption\"\n has \"true\" as its parameter value (e.g., \"--enableEncryption\n true\").\n\n Stop/start (restart) and mongod process using either the MongoDB configuration\n file or that contains the \"--enableEncryption\" option."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000231-DB-000154","gid":"V-81883","rid":"SV-96597r1_rule","stig_id":"MD3X-00-000440","fix_id":"F-88733r1_fix","cci":["CCI-001199"],"nist":["SC-28"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81883' do\n title \"MongoDB must protect the confidentiality and integrity of all\n information at rest.\"\n desc \"This control is intended to address the confidentiality and integrity\n of information at rest in non-mobile devices and covers user information and\n system information. Information at rest refers to the state of information when\n it is located on a secondary storage device (e.g., disk drive, tape drive)\n within an organizational information system. Applications and application users\n generate information throughout the course of their application use.\n\n User data generated, as well as application-specific configuration data,\n needs to be protected. Organizations may choose to employ different mechanisms\n to achieve confidentiality and integrity protections, as appropriate.\n\n If the confidentiality and integrity of application data is not protected,\n the data will be open to compromise and unauthorized modification.\n \"\n\n desc 'check', \"If the MongoDB Encrypted Storage Engines is being used, ensure\n that the \\\"security.enableEncryption\\\" option is set to \\\"true\\\" in the MongoDB\n configuration file (default location: /etc/mongod.conf) or that MongoDB was\n started with the \\\"--enableEncryption\\\" command line option.\n\n Check the MongoDB configuration file (default location: /etc/mongod.conf).\n\n If the following parameter is not present, this is a finding.\n\n security:\n enableEncryption: \\\"true\\\"\n\n If any mongod process is started with \\\"--enableEncryption false\\\", this is a\n finding.\"\n desc 'fix', \"Ensure that the MongoDB Configuration file (default location:\n /etc/mongod.conf) has the following set:\n\n security:\n enableEncryption: \\\"true\\\"\n\n Ensure that any mongod process that contains the option \\\"--enableEcryption\\\"\n has \\\"true\\\" as its parameter value (e.g., \\\"--enableEncryption\n true\\\").\n\n Stop/start (restart) and mongod process using either the MongoDB configuration\n file or that contains the \\\"--enableEncryption\\\" option.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000231-DB-000154'\n tag \"gid\": 'V-81883'\n tag \"rid\": 'SV-96597r1_rule'\n tag \"stig_id\": 'MD3X-00-000440'\n tag \"fix_id\": 'F-88733r1_fix'\n tag \"cci\": ['CCI-001199']\n tag \"nist\": ['SC-28']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe.one do\n describe yaml(input('mongod_conf')) do\n its(%w(security enableEncryption)) { should cmp 'true' }\n end\n describe processes('mongod') do\n its('commands.join') { should match /--enableEncryption true/ }\n end\n end\n\n describe processes('mongod') do\n its('commands.join') { should_not match /--enableEncryption false/ }\n end\nend\n","source_location":{"ref":"./controls/V-81883.rb","line":1},"id":"V-81883"},{"title":"MongoDB must utilize centralized management of the content captured in\n audit records generated by all components of MongoDB.","desc":"Without the ability to centrally manage the content captured in the\n audit records, identification, troubleshooting, and correlation of suspicious\n behavior would be difficult and could lead to a delayed or incomplete analysis\n of an ongoing attack.\n\n The content captured in audit records must be managed from a central\n location (necessitating automation). Centralized management of audit records\n and logs provides for efficiency in maintenance and management of records, as\n well as the backup and archiving of those records.\n\n MongoDB may write audit records to database tables, to files in the file\n system, to other kinds of local repository, or directly to a centralized log\n management system. Whatever the method used, it must be compatible with\n off-loading the records to the centralized system.","descriptions":{"default":"Without the ability to centrally manage the content captured in the\n audit records, identification, troubleshooting, and correlation of suspicious\n behavior would be difficult and could lead to a delayed or incomplete analysis\n of an ongoing attack.\n\n The content captured in audit records must be managed from a central\n location (necessitating automation). Centralized management of audit records\n and logs provides for efficiency in maintenance and management of records, as\n well as the backup and archiving of those records.\n\n MongoDB may write audit records to database tables, to files in the file\n system, to other kinds of local repository, or directly to a centralized log\n management system. Whatever the method used, it must be compatible with\n off-loading the records to the centralized system.","check":"MongoDB can be configured to write audit events to the syslog\n in Linux, but this is not available in Windows. Audit events can also be\n written to a file in either JSON on BSON format. Through the use of third-party\n tools or via syslog directly, audit records can be pushed to a centralized log\n management system.\n\n If a centralized tool for log management is not installed and configured to\n collect audit logs or syslogs, this is a finding.","fix":"Install a centralized syslog collecting tool and configured it as\n instructed in its documentation.\n\n To enable auditing and print audit events to the syslog in JSON format, specify\n the syslog for the --auditDestination setting:\n mongod --dbpath /data/db --auditDestination syslog\n\n Alternatively, these options can also be specified in the configuration file:\n storage:\n dbPath: /data/db\n auditLog:\n destination: syslog"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000356-DB-000314","gid":"V-81903","rid":"SV-96617r1_rule","stig_id":"MD3X-00-000600","fix_id":"F-88753r1_fix","cci":["CCI-001844"],"nist":["AU-3 (2)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81903' do\n title \"MongoDB must utilize centralized management of the content captured in\n audit records generated by all components of MongoDB.\"\n desc \"Without the ability to centrally manage the content captured in the\n audit records, identification, troubleshooting, and correlation of suspicious\n behavior would be difficult and could lead to a delayed or incomplete analysis\n of an ongoing attack.\n\n The content captured in audit records must be managed from a central\n location (necessitating automation). Centralized management of audit records\n and logs provides for efficiency in maintenance and management of records, as\n well as the backup and archiving of those records.\n\n MongoDB may write audit records to database tables, to files in the file\n system, to other kinds of local repository, or directly to a centralized log\n management system. Whatever the method used, it must be compatible with\n off-loading the records to the centralized system.\n \"\n\n desc 'check', \"MongoDB can be configured to write audit events to the syslog\n in Linux, but this is not available in Windows. Audit events can also be\n written to a file in either JSON on BSON format. Through the use of third-party\n tools or via syslog directly, audit records can be pushed to a centralized log\n management system.\n\n If a centralized tool for log management is not installed and configured to\n collect audit logs or syslogs, this is a finding.\"\n desc 'fix', \"Install a centralized syslog collecting tool and configured it as\n instructed in its documentation.\n\n To enable auditing and print audit events to the syslog in JSON format, specify\n the syslog for the --auditDestination setting:\n mongod --dbpath /data/db --auditDestination syslog\n\n Alternatively, these options can also be specified in the configuration file:\n storage:\n dbPath: /data/db\n auditLog:\n destination: syslog\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000356-DB-000314'\n tag \"gid\": 'V-81903'\n tag \"rid\": 'SV-96617r1_rule'\n tag \"stig_id\": 'MD3X-00-000600'\n tag \"fix_id\": 'F-88753r1_fix'\n tag \"cci\": ['CCI-001844']\n tag \"nist\": ['AU-3 (2)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe.one do\n describe yaml(input('mongod_conf')) do\n its(%w(auditLog destination)) { should cmp 'syslog' }\n end\n describe processes('mongod') do\n its('commands.join') { should match /--auditDestination syslog/ }\n end\n end\nend\n","source_location":{"ref":"./controls/V-81903.rb","line":1},"id":"V-81903"},{"title":"Unused database components that are integrated in MongoDB and cannot\n be uninstalled must be disabled.","desc":"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.\n\n Unused, unnecessary DBMS components increase the attack vector for MongoDB\n by introducing additional targets for attack. By minimizing the services and\n applications installed on the system, the number of potential vulnerabilities\n is reduced. Components of the system that are unused and cannot be uninstalled\n must be disabled. The techniques available for disabling components will vary\n by DBMS product, OS, and the nature of the component and may include DBMS\n configuration settings, OS service settings, OS file access security, and DBMS\n user/role permissions.","descriptions":{"default":"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.\n\n Unused, unnecessary DBMS components increase the attack vector for MongoDB\n by introducing additional targets for attack. By minimizing the services and\n applications installed on the system, the number of potential vulnerabilities\n is reduced. Components of the system that are unused and cannot be uninstalled\n must be disabled. The techniques available for disabling components will vary\n by DBMS product, OS, and the nature of the component and may include DBMS\n configuration settings, OS service settings, OS file access security, and DBMS\n user/role permissions.","check":"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), review the following parameters:\n\n net:\n http:\n enabled: true\n JSONPEnabled: true\n RESTInterfaceEnabled: true\n\n If any of the are \"True\" or \"Enabled\", this is a finding.","fix":"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), ensure the following parameters either:\n\n Does not exist in the file\n OR\n Are set to \"false\" as shown below:\n\n http:\n enabled: false\n JSONPEnabled: false\n RESTInterfaceEnabled: false"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000141-DB-000092","satisfies":["SRG-APP-000141-DB-000092","SRG-APP-000142-DB-000094"],"gid":"V-81861","rid":"SV-96575r1_rule","stig_id":"MD3X-00-000290","fix_id":"F-88711r1_fix","cci":["CCI-000381","CCI-000382"],"nist":["CM-7 a","CM-7 b"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81861' do\n title \"Unused database components that are integrated in MongoDB and cannot\n be uninstalled must be disabled.\"\n desc \"Information systems are capable of providing a wide variety of\n functions and services. Some of the functions and services, provided by\n default, may not be necessary to support essential organizational operations\n (e.g., key missions, functions).\n\n It is detrimental for software products to provide, or install by default,\n functionality exceeding requirements or mission objectives.\n\n DBMSs must adhere to the principles of least functionality by providing\n only essential capabilities.\n\n Unused, unnecessary DBMS components increase the attack vector for MongoDB\n by introducing additional targets for attack. By minimizing the services and\n applications installed on the system, the number of potential vulnerabilities\n is reduced. Components of the system that are unused and cannot be uninstalled\n must be disabled. The techniques available for disabling components will vary\n by DBMS product, OS, and the nature of the component and may include DBMS\n configuration settings, OS service settings, OS file access security, and DBMS\n user/role permissions.\n \"\n\n desc 'check', \"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), review the following parameters:\n\n net:\n http:\n enabled: true\n JSONPEnabled: true\n RESTInterfaceEnabled: true\n\n If any of the are \\\"True\\\" or \\\"Enabled\\\", this is a finding.\"\n desc 'fix', \"In the MongoDB database configuration file (default location:\n /etc/mongod.conf), ensure the following parameters either:\n\n Does not exist in the file\n OR\n Are set to \\\"false\\\" as shown below:\n\n http:\n enabled: false\n JSONPEnabled: false\n RESTInterfaceEnabled: false\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000141-DB-000092'\n tag \"satisfies\": %w(SRG-APP-000141-DB-000092 SRG-APP-000142-DB-000094)\n tag \"gid\": 'V-81861'\n tag \"rid\": 'SV-96575r1_rule'\n tag \"stig_id\": 'MD3X-00-000290'\n tag \"fix_id\": 'F-88711r1_fix'\n tag \"cci\": %w(CCI-000381 CCI-000382)\n tag \"nist\": ['CM-7 a', 'CM-7 b']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_conf_file = input('mongod_conf').to_s\n describe.one do\n describe yaml(mongo_conf_file) do\n its(%w(net http enabled)) { should cmp 'false' }\n end\n describe yaml(mongo_conf_file) do\n its(%w(net http enabled)) { should be_nil }\n end\n end\n\n describe.one do\n describe yaml(mongo_conf_file) do\n its(%w(net http JSONPEnabled)) { should cmp 'false' }\n end\n describe yaml(mongo_conf_file) do\n its(%w(net http JSONPEnabled)) { should be_nil }\n end\n end\n\n describe.one do\n describe yaml(mongo_conf_file) do\n its(%w(net http RESTInterfaceEnabled)) { should cmp 'false' }\n end\n describe yaml(mongo_conf_file) do\n its(%w(net http RESTInterfaceEnabled)) { should be_nil }\n end\n end\nend\n","source_location":{"ref":"./controls/V-81861.rb","line":1},"id":"V-81861"},{"title":"MongoDB must reveal detailed error messages only to the ISSO, ISSM,\n SA, and DBA.","desc":"If MongoDB provides too much information in error logs and\n administrative messages to the screen, this could lead to compromise. The\n structure and content of error messages need to be carefully considered by the\n organization and development team. The extent to which the information system\n is able to identify and handle error conditions is guided by organizational\n policy and operational requirements.\n\n Some default DBMS error messages can contain information that could aid an\n attacker in, among others things, identifying the database type, host address,\n or state of the database. Custom errors may contain sensitive customer\n information.\n\n It is important that detailed error messages be visible only to those who\n are authorized to view them; that general users receive only generalized\n acknowledgment that errors have occurred; and that these generalized messages\n appear only when relevant to the user's task. For example, a message along the\n lines of, \"An error has occurred. Unable to save your changes. If this problem\n persists, contact your help desk\" would be relevant. A message such as\n \"Warning: your transaction generated a large number of page splits\" would\n likely not be relevant.\n\n Administrative users authorized to review detailed error messages typically\n are the ISSO, ISSM, SA, and DBA. Other individuals or roles may be specified\n according to organization-specific needs, with appropriate approval.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","descriptions":{"default":"If MongoDB provides too much information in error logs and\n administrative messages to the screen, this could lead to compromise. The\n structure and content of error messages need to be carefully considered by the\n organization and development team. The extent to which the information system\n is able to identify and handle error conditions is guided by organizational\n policy and operational requirements.\n\n Some default DBMS error messages can contain information that could aid an\n attacker in, among others things, identifying the database type, host address,\n or state of the database. Custom errors may contain sensitive customer\n information.\n\n It is important that detailed error messages be visible only to those who\n are authorized to view them; that general users receive only generalized\n acknowledgment that errors have occurred; and that these generalized messages\n appear only when relevant to the user's task. For example, a message along the\n lines of, \"An error has occurred. Unable to save your changes. If this problem\n persists, contact your help desk\" would be relevant. A message such as\n \"Warning: your transaction generated a large number of page splits\" would\n likely not be relevant.\n\n Administrative users authorized to review detailed error messages typically\n are the ISSO, ISSM, SA, and DBA. Other individuals or roles may be specified\n according to organization-specific needs, with appropriate approval.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.","check":"A mongod or mongos running with\n \"security.redactClientLogData\" redacts any message accompanying a given log\n event before logging.\n\n This prevents the mongod or mongos from writing potentially sensitive data\n stored on the database to the diagnostic log. Metadata such as error or\n operation codes, line numbers, and source file names are still visible in the\n logs.\n\n Verify that the MongoDB configuration file (default location: /etc/mongod.conf)\n contains the following:\n\n security:\n redactClientLogData: \"true\"\n\n If this parameter is not present, this is a finding.","fix":"Edit the MongoDB configuration file (default location:\n /etc/mongod.conf) and add the following parameter \"redactClientLogData\" in\n the security section of that file:\n\n security:\n redactClientLogData: \"true\"\n\n Stop/start (restart) any mongod or mongos using the MongoDB configuration file."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000267-DB-000163","gid":"V-81895","rid":"SV-96609r1_rule","stig_id":"MD3X-00-000530","fix_id":"F-88745r1_fix","cci":["CCI-001314"],"nist":["SI-11 b"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81895' do\n title \"MongoDB must reveal detailed error messages only to the ISSO, ISSM,\n SA, and DBA.\"\n desc \"If MongoDB provides too much information in error logs and\n administrative messages to the screen, this could lead to compromise. The\n structure and content of error messages need to be carefully considered by the\n organization and development team. The extent to which the information system\n is able to identify and handle error conditions is guided by organizational\n policy and operational requirements.\n\n Some default DBMS error messages can contain information that could aid an\n attacker in, among others things, identifying the database type, host address,\n or state of the database. Custom errors may contain sensitive customer\n information.\n\n It is important that detailed error messages be visible only to those who\n are authorized to view them; that general users receive only generalized\n acknowledgment that errors have occurred; and that these generalized messages\n appear only when relevant to the user's task. For example, a message along the\n lines of, \\\"An error has occurred. Unable to save your changes. If this problem\n persists, contact your help desk\\\" would be relevant. A message such as\n \\\"Warning: your transaction generated a large number of page splits\\\" would\n likely not be relevant.\n\n Administrative users authorized to review detailed error messages typically\n are the ISSO, ISSM, SA, and DBA. Other individuals or roles may be specified\n according to organization-specific needs, with appropriate approval.\n\n This calls for inspection of application source code, which will require\n collaboration with the application developers. It is recognized that in many\n cases, the database administrator (DBA) is organizationally separate from the\n application developers, and may have limited, if any, access to source code.\n Nevertheless, protections of this type are so important to the secure operation\n of databases that they must not be ignored. At a minimum, the DBA must attempt\n to obtain assurances from the development organization that this issue has been\n addressed, and must document what has been discovered.\n \"\n\n desc 'check', \"A mongod or mongos running with\n \\\"security.redactClientLogData\\\" redacts any message accompanying a given log\n event before logging.\n\n This prevents the mongod or mongos from writing potentially sensitive data\n stored on the database to the diagnostic log. Metadata such as error or\n operation codes, line numbers, and source file names are still visible in the\n logs.\n\n Verify that the MongoDB configuration file (default location: /etc/mongod.conf)\n contains the following:\n\n security:\n redactClientLogData: \\\"true\\\"\n\n If this parameter is not present, this is a finding.\"\n desc 'fix', \"Edit the MongoDB configuration file (default location:\n /etc/mongod.conf) and add the following parameter \\\"redactClientLogData\\\" in\n the security section of that file:\n\n security:\n redactClientLogData: \\\"true\\\"\n\n Stop/start (restart) any mongod or mongos using the MongoDB configuration file.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000267-DB-000163'\n tag \"gid\": 'V-81895'\n tag \"rid\": 'SV-96609r1_rule'\n tag \"stig_id\": 'MD3X-00-000530'\n tag \"fix_id\": 'F-88745r1_fix'\n tag \"cci\": ['CCI-001314']\n tag \"nist\": ['SI-11 b']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe yaml(input('mongod_conf')) do\n its(%w(security redactClientLogData)) { should cmp 'true' }\n end\nend\n","source_location":{"ref":"./controls/V-81895.rb","line":1},"id":"V-81895"},{"title":"The role(s)/group(s) used to modify database structure (including but\n not necessarily limited to tables, indexes, storage, etc.) and logic modules\n (stored procedures, functions, triggers, links to software external to MongoDB,\n etc.) must be restricted to authorized users.","desc":"If MongoDB were to allow any user to make changes to database\n structure or logic, then those changes might be implemented without undergoing\n the appropriate testing and approvals that are part of a robust change\n management process.\n\n Accordingly, only qualified and authorized individuals must be allowed to\n obtain access to information system components for purposes of initiating\n changes, including upgrades and modifications.\n\n Unmanaged changes that occur to the database software libraries or\n configuration can lead to unauthorized or compromised installations.","descriptions":{"default":"If MongoDB were to allow any user to make changes to database\n structure or logic, then those changes might be implemented without undergoing\n the appropriate testing and approvals that are part of a robust change\n management process.\n\n Accordingly, only qualified and authorized individuals must be allowed to\n obtain access to information system components for purposes of initiating\n changes, including upgrades and modifications.\n\n Unmanaged changes that occur to the database software libraries or\n configuration can lead to unauthorized or compromised installations.","check":"Run the following command to get the roles from a MongoDB\n database.\n\n For each database in MongoDB:\n\n use \n db.getRoles(\n {\n rolesInfo: 1,\n showPrivileges:true,\n showBuiltinRoles: true\n }\n )\n\n Run the following command to the roles assigned to users:\n\n use admin\n db.system.users.find()\n\n Analyze the output and if any roles or users have unauthorized access, this is\n a finding.","fix":"Use the following commands to remove unauthorized access to a\n MongoDB database.\n\n db.revokePrivilegesFromRole()\n db. revokeRolesFromUser()\n\n MongoDB commands for role management can be found here:\n https://docs.mongodb.com/v3.4/reference/method/js-role-management/"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000133-DB-000362","gid":"V-81857","rid":"SV-96571r1_rule","stig_id":"MD3X-00-000270","fix_id":"F-88707r1_fix","cci":["CCI-001499"],"nist":["CM-5 (6)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81857' do\n title \"The role(s)/group(s) used to modify database structure (including but\n not necessarily limited to tables, indexes, storage, etc.) and logic modules\n (stored procedures, functions, triggers, links to software external to MongoDB,\n etc.) must be restricted to authorized users.\"\n desc \"If MongoDB were to allow any user to make changes to database\n structure or logic, then those changes might be implemented without undergoing\n the appropriate testing and approvals that are part of a robust change\n management process.\n\n Accordingly, only qualified and authorized individuals must be allowed to\n obtain access to information system components for purposes of initiating\n changes, including upgrades and modifications.\n\n Unmanaged changes that occur to the database software libraries or\n configuration can lead to unauthorized or compromised installations.\n \"\n\n desc 'check', \"Run the following command to get the roles from a MongoDB\n database.\n\n For each database in MongoDB:\n\n use \n db.getRoles(\n {\n rolesInfo: 1,\n showPrivileges:true,\n showBuiltinRoles: true\n }\n )\n\n Run the following command to the roles assigned to users:\n\n use admin\n db.system.users.find()\n\n Analyze the output and if any roles or users have unauthorized access, this is\n a finding.\"\n desc 'fix', \"Use the following commands to remove unauthorized access to a\n MongoDB database.\n\n db.revokePrivilegesFromRole()\n db. revokeRolesFromUser()\n\n MongoDB commands for role management can be found here:\n https://docs.mongodb.com/v3.4/reference/method/js-role-management/\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000133-DB-000362'\n tag \"gid\": 'V-81857'\n tag \"rid\": 'SV-96571r1_rule'\n tag \"stig_id\": 'MD3X-00-000270'\n tag \"fix_id\": 'F-88707r1_fix'\n tag \"cci\": ['CCI-001499']\n tag \"nist\": ['CM-5 (6)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongo_session = mongo_command(username: input('username'), password: input('password'), host: input('mongod_hostname'), port: input('mongod_port'), ssl: input('ssl'), verify_ssl: input('verify_ssl'), ssl_pem_key_file: input('mongod_client_pem'), ssl_ca_file: input('mongod_cafile'), authentication_database: input('authentication_database'), authentication_mechanism: input('authentication_mechanism'))\n\n dbs = mongo_session.query(\"db.adminCommand('listDatabases')\")['databases'].map { |x| x['name'] }\n\n dbs.each do |db|\n db_command = \"db = db.getSiblingDB('#{db}');db.getUsers()\"\n results = mongo_session.query(db_command)\n\n results.each do |entry|\n describe \"Manually verify roles for User: `#{entry['user']}` within Database: `#{entry['db']}`\n Roles: #{entry['roles']}\" do\n skip\n end\n end\n end\n\n if dbs.empty?\n describe 'No databases found on the target' do\n skip\n end\n end\nend\n","source_location":{"ref":"./controls/V-81857.rb","line":1},"id":"V-81857"},{"title":"MongoDB must prevent unauthorized and unintended information transfer\n via shared system resources.","desc":"The purpose of this control is to prevent information, including\n encrypted representations of information, produced by the actions of a prior\n user/role (or the actions of a process acting on behalf of a prior user/role)\n from being available to any current user/role (or current process) that obtains\n access to a shared system resource (e.g., registers, main memory, secondary\n storage) after the resource has been released back to the information system.\n Control of information in shared resources is also referred to as object reuse.","descriptions":{"default":"The purpose of this control is to prevent information, including\n encrypted representations of information, produced by the actions of a prior\n user/role (or the actions of a process acting on behalf of a prior user/role)\n from being available to any current user/role (or current process) that obtains\n access to a shared system resource (e.g., registers, main memory, secondary\n storage) after the resource has been released back to the information system.\n Control of information in shared resources is also referred to as object reuse.","check":"Verify the permissions for the following database files or\n directories:\n\n MongoDB default configuration file: \"/etc/mongod.conf\"\n MongoDB default data directory: \"/var/lib/mongo\"\n\n If the owner and group are not both \"mongod\", this is a finding.\n\n If the file permissions are more permissive than \"755\", this is a finding.","fix":"Correct the permission to the files and/or directories that are\n in violation.\n\n MongoDB Configuration file (default location):\n chown mongod:mongod /etc/mongod.conf\n chmod 755 /etc/mongod.conf\n\n MongoDB data file directory (default location):\n chown -R mongod:mongod/var/lib/mongo\n chmod -R 755/var/lib/mongo"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000243-DB-000373","satisfies":["SRG-APP-000243-DB-000373","SRG-APP-000243-DB-000374"],"gid":"V-81887","rid":"SV-96601r1_rule","stig_id":"MD3X-00-000470","fix_id":"F-88737r1_fix","cci":["CCI-001090"],"nist":["SC-4"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81887' do\n title \"MongoDB must prevent unauthorized and unintended information transfer\n via shared system resources.\"\n desc \"The purpose of this control is to prevent information, including\n encrypted representations of information, produced by the actions of a prior\n user/role (or the actions of a process acting on behalf of a prior user/role)\n from being available to any current user/role (or current process) that obtains\n access to a shared system resource (e.g., registers, main memory, secondary\n storage) after the resource has been released back to the information system.\n Control of information in shared resources is also referred to as object reuse.\n \"\n\n desc 'check', \"Verify the permissions for the following database files or\n directories:\n\n MongoDB default configuration file: \\\"/etc/mongod.conf\\\"\n MongoDB default data directory: \\\"/var/lib/mongo\\\"\n\n If the owner and group are not both \\\"mongod\\\", this is a finding.\n\n If the file permissions are more permissive than \\\"755\\\", this is a finding.\"\n desc 'fix', \"Correct the permission to the files and/or directories that are\n in violation.\n\n MongoDB Configuration file (default location):\n chown mongod:mongod /etc/mongod.conf\n chmod 755 /etc/mongod.conf\n\n MongoDB data file directory (default location):\n chown -R mongod:mongod/var/lib/mongo\n chmod -R 755/var/lib/mongo\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000243-DB-000373'\n tag \"satisfies\": %w(SRG-APP-000243-DB-000373 SRG-APP-000243-DB-000374)\n tag \"gid\": 'V-81887'\n tag \"rid\": 'SV-96601r1_rule'\n tag \"stig_id\": 'MD3X-00-000470'\n tag \"fix_id\": 'F-88737r1_fix'\n tag \"cci\": ['CCI-001090']\n tag \"nist\": ['SC-4']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongodb_service_account = input('mongodb_service_account')\n mongodb_service_group = input('mongodb_service_group')\n\n if file(input('mongod_conf')).exist?\n describe file(input('mongod_conf')) do\n it { should_not be_more_permissive_than('0755') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\n else\n describe 'This control must be reviewed manually because the configuration\n file is not found at the location specified.' do\n skip 'This control must be reviewed manually because the configuration\n file is not found at the location specified.'\n end\n end\n\n if file(input('mongo_data_dir')).exist?\n describe directory(input('mongo_data_dir')) do\n it { should_not be_more_permissive_than('0755') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\n else\n describe 'This control must be reviewed manually because the Mongodb data\n directory is not found at the location specified.' do\n skip 'This control must be reviewed manually because the Mongodb data\n directory is not found at the location specified.'\n end\n end\nend\n","source_location":{"ref":"./controls/V-81887.rb","line":1},"id":"V-81887"},{"title":"If passwords are used for authentication, MongoDB must transmit only\n encrypted representations of passwords.","desc":"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, passwords need to be protected at all times, and encryption\n is the standard method for protecting passwords during transmission.\n\n DBMS passwords sent in clear text format across the network are vulnerable\n to discovery by unauthorized users. Disclosure of passwords may easily lead to\n unauthorized access to the database.","descriptions":{"default":"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, passwords need to be protected at all times, and encryption\n is the standard method for protecting passwords during transmission.\n\n DBMS passwords sent in clear text format across the network are vulnerable\n to discovery by unauthorized users. Disclosure of passwords may easily lead to\n unauthorized access to the database.","check":"In the MongoDB database configuration file (default location:\n/etc/mongod.conf), review the following parameters:\n\nnet:\nssl:\nmode: requireSSL\nPEMKeyFile: /etc/ssl/mongodb.pem\nCAFile: /etc/ssl/mongodbca.pem\n\nIf the \"CAFile\" parameter is not present, this is a finding.\n\nIf the \"allowInvalidCertificates\" parameter is found, this is a finding.\n\nnet:\nssl:\nallowInvalidCertificates: true","fix":"In the MongoDB database configuration file (default location:\n /etc/mongod.conf) ensure the following parameters following parameter are set\n and configured correctly:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n CAFile: /etc/ssl/mongodbca.pem\n\n Remove any occurrence of the \"allowInvalidCertificates\" parameter:\n\n net:\n ssl:\n allowInvalidCertificates: true\n\n Stop/start (restart) the mongod or mongos instance using this configuration."},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000172-DB-000075","satisfies":["SRG-APP-000172-DB-000075","SRG-APP-000175-DB-000067"],"gid":"V-81869","rid":"SV-96583r1_rule","stig_id":"MD3X-00-000340","fix_id":"F-88719r1_fix","cci":["CCI-000185","CCI-000197"],"nist":["IA-5 (2) (a)","IA-5 (1) (c)"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81869' do\n title \"If passwords are used for authentication, MongoDB must transmit only\n encrypted representations of passwords.\"\n desc \"The DoD standard for authentication is DoD-approved PKI certificates.\n Authentication based on User ID and Password may be used only when it is\n not possible to employ a PKI certificate, and requires AO approval.\n\n In such cases, passwords need to be protected at all times, and encryption\n is the standard method for protecting passwords during transmission.\n\n DBMS passwords sent in clear text format across the network are vulnerable\n to discovery by unauthorized users. Disclosure of passwords may easily lead to\n unauthorized access to the database.\n \"\n\n desc 'check', \"In the MongoDB database configuration file (default location:\n/etc/mongod.conf), review the following parameters:\n\nnet:\nssl:\nmode: requireSSL\nPEMKeyFile: /etc/ssl/mongodb.pem\nCAFile: /etc/ssl/mongodbca.pem\n\nIf the \\\"CAFile\\\" parameter is not present, this is a finding.\n\nIf the \\\"allowInvalidCertificates\\\" parameter is found, this is a finding.\n\nnet:\nssl:\nallowInvalidCertificates: true\"\n desc 'fix', \"In the MongoDB database configuration file (default location:\n /etc/mongod.conf) ensure the following parameters following parameter are set\n and configured correctly:\n\n net:\n ssl:\n mode: requireSSL\n PEMKeyFile: /etc/ssl/mongodb.pem\n CAFile: /etc/ssl/mongodbca.pem\n\n Remove any occurrence of the \\\"allowInvalidCertificates\\\" parameter:\n\n net:\n ssl:\n allowInvalidCertificates: true\n\n Stop/start (restart) the mongod or mongos instance using this configuration.\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000172-DB-000075'\n tag \"satisfies\": %w(SRG-APP-000172-DB-000075 SRG-APP-000175-DB-000067)\n tag \"gid\": 'V-81869'\n tag \"rid\": 'SV-96583r1_rule'\n tag \"stig_id\": 'MD3X-00-000340'\n tag \"fix_id\": 'F-88719r1_fix'\n tag \"cci\": %w(CCI-000185 CCI-000197)\n tag \"nist\": ['IA-5 (2) (a)', 'IA-5 (1) (c)']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n describe.one do\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl allowInvalidCertificates)) { should be nil }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl allowInvalidCertificates)) { should be false }\n end\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl mode)) { should cmp 'requireSSL' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl PEMKeyFile)) { should cmp '/etc/ssl/mongodb.pem' }\n end\n describe yaml(input('mongod_conf')) do\n its(%w(net ssl CAFile)) { should cmp '/etc/ssl/mongodbca.pem' }\n end\nend\n","source_location":{"ref":"./controls/V-81869.rb","line":1},"id":"V-81869"},{"title":"The audit information produced by MongoDB must be protected from\n unauthorized read access.","desc":"If audit data were to become compromised, then competent forensic\n analysis and discovery of the true source of potentially malicious system\n activity is difficult, if not impossible, to achieve. In addition, access to\n audit records provides information an attacker could potentially use to his or\n her advantage.\n\n To ensure the veracity of audit data, the information system and/or the\n application must protect audit information from any and all unauthorized\n access. This includes read, write, copy, etc.\n\n This requirement can be achieved through multiple methods which will depend\n upon system architecture and design. Some commonly employed methods include\n ensuring log files enjoy the proper file system permissions utilizing file\n system protections and limiting log data location.\n\n Additionally, applications with user interfaces to audit records should not\n allow for the unfettered manipulation of or access to those records via the\n application. If the application provides access to the audit data, the\n application becomes accountable for ensuring that audit information is\n protected from unauthorized access.\n\n Audit information includes all information (e.g., audit records, audit\n settings, and audit reports) needed to successfully audit information system\n activity.","descriptions":{"default":"If audit data were to become compromised, then competent forensic\n analysis and discovery of the true source of potentially malicious system\n activity is difficult, if not impossible, to achieve. In addition, access to\n audit records provides information an attacker could potentially use to his or\n her advantage.\n\n To ensure the veracity of audit data, the information system and/or the\n application must protect audit information from any and all unauthorized\n access. This includes read, write, copy, etc.\n\n This requirement can be achieved through multiple methods which will depend\n upon system architecture and design. Some commonly employed methods include\n ensuring log files enjoy the proper file system permissions utilizing file\n system protections and limiting log data location.\n\n Additionally, applications with user interfaces to audit records should not\n allow for the unfettered manipulation of or access to those records via the\n application. If the application provides access to the audit data, the\n application becomes accountable for ensuring that audit information is\n protected from unauthorized access.\n\n Audit information includes all information (e.g., audit records, audit\n settings, and audit reports) needed to successfully audit information system\n activity.","check":"Verify User ownership, Group ownership, and permissions on the\n \"\":\n\n > ls –ald \n\n If the User owner is not \"mongod\", this is a finding.\n\n If the Group owner is not \"mongod\", this is a finding.\n\n If the directory is more permissive than \"700\", this is a finding.\n\n (The path for the MongoDB auditLog directory will vary according to local\n circumstances. The auditLog directory will be found in the MongoDB\n configuration file whose default location is '/etc/mongod.conf'.)\n\n To find the auditLog directory name, view and search for the entry in the\n MongoDB configuration file for the auditLog.path:\n\n Example:\n\n auditLog:\n destination: file\n format: BSON\n path: /var/lib/mongo/auditLog.bson\n\n Given the example above, to find the auditLog directory name run the following\n command:\n\n > dirname /var/lib/mongo/auditLog.bson\n the output will be the \"\"\n\n /var/lib/mongo","fix":"Run these commands:\n\n \"chown mongod \"\n \"chgrp mongod \"\n \"chmod 700 <\"\n\n (The path for the MongoDB auditLog directory will vary according to local\n circumstances. The auditLog directory will be found in the MongoDB\n configuration file whose default location is '/etc/mongod.conf'.)\n\n To find the auditLog directory name, view and search for the entry in the\n MongoDB configuration file for the auditLog.path:\n\n Example:\n\n auditLog:\n destination: file\n format: BSON\n path: /var/lib/mongo/auditLog.bson\n\n Given the example above, to find the auditLog directory name run the following\n command:\n\n > dirname /var/lib/mongo/auditLog.bson\n the output will be the \"\"\n\n /var/lib/mongo"},"impact":0.5,"refs":[],"tags":{"severity":"medium","gtitle":"SRG-APP-000118-DB-000059","satisfies":["SRG-APP-000118-DB-000059","SRG-APP-000119-DB-000060","SRG-APP-000120-DB-000061"],"gid":"V-81849","rid":"SV-96563r1_rule","stig_id":"MD3X-00-000190","fix_id":"F-88699r1_fix","cci":["CCI-000162","CCI-000163","CCI-000164"],"nist":["AU-9"],"documentable":false,"severity_override_guidance":false},"code":"control 'V-81849' do\n title \"The audit information produced by MongoDB must be protected from\n unauthorized read access.\"\n desc \"If audit data were to become compromised, then competent forensic\n analysis and discovery of the true source of potentially malicious system\n activity is difficult, if not impossible, to achieve. In addition, access to\n audit records provides information an attacker could potentially use to his or\n her advantage.\n\n To ensure the veracity of audit data, the information system and/or the\n application must protect audit information from any and all unauthorized\n access. This includes read, write, copy, etc.\n\n This requirement can be achieved through multiple methods which will depend\n upon system architecture and design. Some commonly employed methods include\n ensuring log files enjoy the proper file system permissions utilizing file\n system protections and limiting log data location.\n\n Additionally, applications with user interfaces to audit records should not\n allow for the unfettered manipulation of or access to those records via the\n application. If the application provides access to the audit data, the\n application becomes accountable for ensuring that audit information is\n protected from unauthorized access.\n\n Audit information includes all information (e.g., audit records, audit\n settings, and audit reports) needed to successfully audit information system\n activity.\n \"\n\n desc 'check', \"Verify User ownership, Group ownership, and permissions on the\n \\\"\\\":\n\n > ls –ald \n\n If the User owner is not \\\"mongod\\\", this is a finding.\n\n If the Group owner is not \\\"mongod\\\", this is a finding.\n\n If the directory is more permissive than \\\"700\\\", this is a finding.\n\n (The path for the MongoDB auditLog directory will vary according to local\n circumstances. The auditLog directory will be found in the MongoDB\n configuration file whose default location is '/etc/mongod.conf'.)\n\n To find the auditLog directory name, view and search for the entry in the\n MongoDB configuration file for the auditLog.path:\n\n Example:\n\n auditLog:\n destination: file\n format: BSON\n path: /var/lib/mongo/auditLog.bson\n\n Given the example above, to find the auditLog directory name run the following\n command:\n\n > dirname /var/lib/mongo/auditLog.bson\n the output will be the \\\"\\\"\n\n /var/lib/mongo\"\n desc 'fix', \"Run these commands:\n\n \\\"chown mongod \\\"\n \\\"chgrp mongod \\\"\n \\\"chmod 700 <\\\"\n\n (The path for the MongoDB auditLog directory will vary according to local\n circumstances. The auditLog directory will be found in the MongoDB\n configuration file whose default location is '/etc/mongod.conf'.)\n\n To find the auditLog directory name, view and search for the entry in the\n MongoDB configuration file for the auditLog.path:\n\n Example:\n\n auditLog:\n destination: file\n format: BSON\n path: /var/lib/mongo/auditLog.bson\n\n Given the example above, to find the auditLog directory name run the following\n command:\n\n > dirname /var/lib/mongo/auditLog.bson\n the output will be the \\\"\\\"\n\n /var/lib/mongo\"\n\n impact 0.5\n tag \"severity\": 'medium'\n tag \"gtitle\": 'SRG-APP-000118-DB-000059'\n tag \"satisfies\": %w(SRG-APP-000118-DB-000059 SRG-APP-000119-DB-000060\n SRG-APP-000120-DB-000061)\n tag \"gid\": 'V-81849'\n tag \"rid\": 'SV-96563r1_rule'\n tag \"stig_id\": 'MD3X-00-000190'\n tag \"fix_id\": 'F-88699r1_fix'\n tag \"cci\": %w(CCI-000162 CCI-000163 CCI-000164)\n tag \"nist\": ['AU-9']\n tag \"documentable\": false\n tag \"severity_override_guidance\": false\n\n mongodb_auditlog_dir = yaml(input('mongod_conf'))['auditLog', 'path']\n mongodb_service_account = input('mongodb_service_account')\n mongodb_service_group = input('mongodb_service_group')\n\n describe file(mongodb_auditlog_dir) do\n it { should exist }\n end\n\n describe file(mongodb_auditlog_dir) do\n it { should_not be_more_permissive_than('0700') }\n its('owner') { should be_in mongodb_service_account }\n its('group') { should be_in mongodb_service_group }\n end\n\n describe command(\"dirname #{mongodb_auditlog_dir}\") do\n it { should cmp '/var/lib/mongo' }\n end\nend\n","source_location":{"ref":"./controls/V-81849.rb","line":1},"id":"V-81849"}],"groups":[{"title":null,"controls":["V-81843"],"id":"controls/V-81843.rb"},{"title":null,"controls":["V-81853"],"id":"controls/V-81853.rb"},{"title":null,"controls":["V-81885"],"id":"controls/V-81885.rb"},{"title":null,"controls":["V-81905"],"id":"controls/V-81905.rb"},{"title":null,"controls":["V-81915"],"id":"controls/V-81915.rb"},{"title":null,"controls":["V-81917"],"id":"controls/V-81917.rb"},{"title":null,"controls":["V-81901"],"id":"controls/V-81901.rb"},{"title":null,"controls":["V-81925"],"id":"controls/V-81925.rb"},{"title":null,"controls":["V-81911"],"id":"controls/V-81911.rb"},{"title":null,"controls":["V-81897"],"id":"controls/V-81897.rb"},{"title":null,"controls":["V-81863"],"id":"controls/V-81863.rb"},{"title":null,"controls":["V-81893"],"id":"controls/V-81893.rb"},{"title":null,"controls":["V-81907"],"id":"controls/V-81907.rb"},{"title":null,"controls":["V-81855"],"id":"controls/V-81855.rb"},{"title":null,"controls":["V-81909"],"id":"controls/V-81909.rb"},{"title":null,"controls":["V-81865"],"id":"controls/V-81865.rb"},{"title":null,"controls":["V-81867"],"id":"controls/V-81867.rb"},{"title":null,"controls":["V-81891"],"id":"controls/V-81891.rb"},{"title":null,"controls":["V-81929"],"id":"controls/V-81929.rb"},{"title":null,"controls":["V-81923"],"id":"controls/V-81923.rb"},{"title":null,"controls":["V-81871"],"id":"controls/V-81871.rb"},{"title":null,"controls":["V-81845"],"id":"controls/V-81845.rb"},{"title":null,"controls":["V-81851"],"id":"controls/V-81851.rb"},{"title":null,"controls":["V-81873"],"id":"controls/V-81873.rb"},{"title":null,"controls":["V-81889"],"id":"controls/V-81889.rb"},{"title":null,"controls":["V-81877"],"id":"controls/V-81877.rb"},{"title":null,"controls":["V-81919"],"id":"controls/V-81919.rb"},{"title":null,"controls":["V-81881"],"id":"controls/V-81881.rb"},{"title":null,"controls":["V-81913"],"id":"controls/V-81913.rb"},{"title":null,"controls":["V-81879"],"id":"controls/V-81879.rb"},{"title":null,"controls":["V-81899"],"id":"controls/V-81899.rb"},{"title":null,"controls":["V-81859"],"id":"controls/V-81859.rb"},{"title":null,"controls":["V-81921"],"id":"controls/V-81921.rb"},{"title":null,"controls":["V-81875"],"id":"controls/V-81875.rb"},{"title":null,"controls":["V-81927"],"id":"controls/V-81927.rb"},{"title":null,"controls":["V-81847"],"id":"controls/V-81847.rb"},{"title":null,"controls":["V-81883"],"id":"controls/V-81883.rb"},{"title":null,"controls":["V-81903"],"id":"controls/V-81903.rb"},{"title":null,"controls":["V-81861"],"id":"controls/V-81861.rb"},{"title":null,"controls":["V-81895"],"id":"controls/V-81895.rb"},{"title":null,"controls":["V-81857"],"id":"controls/V-81857.rb"},{"title":null,"controls":["V-81887"],"id":"controls/V-81887.rb"},{"title":null,"controls":["V-81869"],"id":"controls/V-81869.rb"},{"title":null,"controls":["V-81849"],"id":"controls/V-81849.rb"}],"sha256":"42cf40c6b367b47abff009d2dbb0b64cdc44f87f80221a1295e37fab59b330b1","status_message":"","status":"loaded","generator":{"name":"inspec","version":"4.37.30"}} From 1e90be61facf4d3fb808807e1eef87202534029f Mon Sep 17 00:00:00 2001 From: Aaron Lippold Date: Fri, 25 Jun 2021 20:25:36 +0000 Subject: [PATCH 27/32] - fixed the vanilla min threshold - made the threshold files well formed yaml - cleaned up local resource Signed-off-by: GitHub --- libraries/mongo_command.rb | 5 +---- threshold.hardened.yml | 5 +++-- threshold.vanilla.yml | 5 +++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libraries/mongo_command.rb b/libraries/mongo_command.rb index 40c0505..59919d7 100644 --- a/libraries/mongo_command.rb +++ b/libraries/mongo_command.rb @@ -140,9 +140,6 @@ def format_command(command) command += " --sslPEMKeyFile #{@ssl_pem_key_file}" unless @ssl_pem_key_file.nil? command += " --sslCAFile #{@ssl_ca_file}" unless @ssl_ca_file.nil? end - - - #puts command command end -end \ No newline at end of file +end diff --git a/threshold.hardened.yml b/threshold.hardened.yml index ca51121..7c6b487 100644 --- a/threshold.hardened.yml +++ b/threshold.hardened.yml @@ -1,2 +1,3 @@ -compliance: - min: 75 \ No newline at end of file +--- +error.total: 0 +compliance.min: 70 \ No newline at end of file diff --git a/threshold.vanilla.yml b/threshold.vanilla.yml index 2412d83..d240244 100644 --- a/threshold.vanilla.yml +++ b/threshold.vanilla.yml @@ -1,2 +1,3 @@ -compliance: - min: 13 \ No newline at end of file +--- +error.total: 0 +compliance.min: 2 \ No newline at end of file From be20660cf4b45d88934335ad42056ed581805906 Mon Sep 17 00:00:00 2001 From: Aaron Lippold Date: Fri, 25 Jun 2021 20:44:37 +0000 Subject: [PATCH 28/32] - fixed rubocop file Signed-off-by: GitHub --- .rubocop.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 73298a8..ced4093 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ --- AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.7 Exclude: - Gemfile - Rakefile @@ -16,7 +16,7 @@ AllCops: - 'vendor/**/*' - 'lib/bundles/inspec-init/templates/**/*' - 'www/demo/**/*' -AlignParameters: +Layout/ParameterAlignment: Enabled: true BlockDelimiters: Enabled: false @@ -30,7 +30,7 @@ HashSyntax: Enabled: true LineLength: Enabled: false -Layout/AlignHash: +Layout/HashAlignment: Enabled: false Layout/EmptyLineAfterMagicComment: Enabled: false @@ -57,8 +57,6 @@ Security/YAMLLoad: Enabled: false Style/AndOr: Enabled: false -Style/BracesAroundHashParameters: - Enabled: false Style/ClassAndModuleChildren: Enabled: false Style/ConditionalAssignment: From 44565fc6c33170c09742478866c3b989123ff5f0 Mon Sep 17 00:00:00 2001 From: Aaron Lippold Date: Fri, 25 Jun 2021 20:49:21 +0000 Subject: [PATCH 29/32] - added 'cookstyle' gem to the Gemfile Signed-off-by: GitHub --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f70badc..d29374c 100644 --- a/Gemfile +++ b/Gemfile @@ -8,4 +8,5 @@ gem 'inspec_tools' gem 'kitchen-sync' gem 'kitchen-vagrant' gem 'kitchen-docker' -gem 'kitchen-ec2' \ No newline at end of file +gem 'kitchen-ec2' +gem 'cookstyle' \ No newline at end of file From 72700a4e74e1fd6e06e859653821f327d32678f3 Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Sun, 27 Jun 2021 19:32:46 -0400 Subject: [PATCH 30/32] Input value updates Signed-off-by: Rony Xavier --- inspec.yml | 82 +++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/inspec.yml b/inspec.yml index fbd055f..4dd66be 100644 --- a/inspec.yml +++ b/inspec.yml @@ -9,53 +9,17 @@ version: 1.2.0 inspec_version: ">= 4.0" inputs: - - name: mongod_conf - description: 'MongoDB configuration file' - type: string - value: '/etc/mongod.conf' - required: true - - - name: mongo_data_dir - description: 'MongoDB Home Directory' - type: string - value: '/var/lib/mongo' - required: true - - - name: mongo_use_ldap - description: 'MongoDB is Using LDAP - True/False' - type: string - value: 'false' - required: true - - - name: mongo_use_saslauthd - description: 'MongoDB is Using SASLAUTHD - True/False' - type: string - value: 'false' - required: true - - - name: approved_mongo_packages - description: 'List of MongoDB Packages' - type: array - value: [ - 'mongodb-enterprise', - 'mongodb-enterprise-mongos', - 'mongodb-enterprise-server', - 'mongodb-enterprise-shell', - 'mongodb-enterprise-tools' - ] - required: true - - name: username description: 'User to log into the mongo database' type: string - value: nil + value: 'mongoadmin' required: true sensitive: true - name: password description: 'password to log into the mongo database' type: string - value: nil + value: 'mongoadmin' required: true sensitive: true @@ -99,6 +63,42 @@ inputs: type: string value: nil + - name: mongod_conf + description: 'MongoDB configuration file' + type: string + value: '/etc/mongod.conf' + required: true + + - name: mongo_data_dir + description: 'MongoDB Home Directory' + type: string + value: '/var/lib/mongo' + required: true + + - name: mongo_use_ldap + description: 'MongoDB is Using LDAP - True/False' + type: string + value: 'false' + required: true + + - name: mongo_use_saslauthd + description: 'MongoDB is Using SASLAUTHD - True/False' + type: string + value: 'false' + required: true + + - name: approved_mongo_packages + description: 'List of MongoDB Packages' + type: array + value: [ + 'mongodb-enterprise', + 'mongodb-enterprise-mongos', + 'mongodb-enterprise-server', + 'mongodb-enterprise-shell', + 'mongodb-enterprise-tools' + ] + required: true + - name: mongodb_service_account description: Mongodb Service Account type: array @@ -110,11 +110,11 @@ inputs: value: ["mongodb", "mongod"] - name: is_sensitive - description: MongoDB is deployed in a sensitive environment + description: Set to true if target is sensitive as described in control V-81875 and V-81919 type: boolean value: true - - name: x509_cert_file - description: x509 cert file location + - name: certificate_key_file + description: path to server certificate key file type: string value: "/etc/ssl/mongodb.pem" \ No newline at end of file From 7f832757bace6e28e302a50028a02293523e5ad6 Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Sun, 27 Jun 2021 22:01:47 -0400 Subject: [PATCH 31/32] Profile review updates Signed-off-by: Rony Xavier --- controls/V-81847.rb | 56 ++++++++++++++++++++++----------------------- controls/V-81849.rb | 40 ++++++++++++++++++-------------- controls/V-81851.rb | 2 +- controls/V-81865.rb | 22 +++++++++++------- controls/V-81867.rb | 8 +++---- controls/V-81869.rb | 6 ++--- controls/V-81871.rb | 28 +++++++++++++++-------- controls/V-81875.rb | 8 +++++-- controls/V-81877.rb | 2 +- controls/V-81897.rb | 2 +- controls/V-81905.rb | 12 +++++++--- controls/V-81907.rb | 12 +++++++--- controls/V-81915.rb | 2 +- controls/V-81917.rb | 14 ++++++------ controls/V-81919.rb | 34 +++++++++++++++------------ controls/V-81927.rb | 4 +--- inputs.yml | 35 ++++++++++------------------ inspec.yml | 8 +++---- 18 files changed, 160 insertions(+), 135 deletions(-) diff --git a/controls/V-81847.rb b/controls/V-81847.rb index 03ca75b..8be6930 100644 --- a/controls/V-81847.rb +++ b/controls/V-81847.rb @@ -45,44 +45,44 @@ tag "severity": 'medium' tag "gtitle": 'SRG-APP-000089-DB-000064' tag "satisfies": %w(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-000093-DB-000052 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) + SRG-APP-000090-DB-000065 SRG-APP-000091-DB-000066 + SRG-APP-000091-DB-000325 SRG-APP-000092-DB-000208 + SRG-APP-000093-DB-000052 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 "gid": 'V-81847' tag "rid": 'SV-96561r1_rule' tag "stig_id": 'MD3X-00-000040' tag "fix_id": 'F-88697r1_fix' tag "cci": %w(CCI-000130 CCI-000131 CCI-000132 CCI-000133 - CCI-000134 CCI-000135 CCI-000140 CCI-000166 CCI-000171 - CCI-000172 CCI-001462 CCI-001464 CCI-001487 CCI-001814 - CCI-001844 CCI-001851 CCI-001858) + CCI-000134 CCI-000135 CCI-000140 CCI-000166 CCI-000171 + CCI-000172 CCI-001462 CCI-001464 CCI-001487 CCI-001814 + CCI-001844 CCI-001851 CCI-001858) tag "nist": ['AU-3', 'AU-3', 'AU-3', 'AU-3', 'AU-3', 'AU-3 (1)', 'AU-5 b', - 'AU-10', 'AU-12 b', 'AU-12 c', 'AU-14 (2)', 'AU-14 (1)', 'AU-3', 'CM-5 (1)', - 'AU-3 (2)', 'AU-4 (1)', 'AU-5 (2)'] + 'AU-10', 'AU-12 b', 'AU-12 c', 'AU-14 (2)', 'AU-14 (1)', 'AU-3', 'CM-5 (1)', + 'AU-3 (2)', 'AU-4 (1)', 'AU-5 (2)'] tag "documentable": false tag "severity_override_guidance": false describe yaml(input('mongod_conf')) do - its(%w(auditLog destination)) { should cmp 'syslog' } + its(%w(auditLog destination)) { should_not be_nil } end describe yaml(input('mongod_conf')) do its(%w(auditLog filter)) { should be_nil } diff --git a/controls/V-81849.rb b/controls/V-81849.rb index 4cc4612..1f7684d 100644 --- a/controls/V-81849.rb +++ b/controls/V-81849.rb @@ -91,7 +91,7 @@ tag "severity": 'medium' tag "gtitle": 'SRG-APP-000118-DB-000059' tag "satisfies": %w(SRG-APP-000118-DB-000059 SRG-APP-000119-DB-000060 - SRG-APP-000120-DB-000061) + SRG-APP-000120-DB-000061) tag "gid": 'V-81849' tag "rid": 'SV-96563r1_rule' tag "stig_id": 'MD3X-00-000190' @@ -101,21 +101,27 @@ tag "documentable": false tag "severity_override_guidance": false - mongodb_auditlog_dir = yaml(input('mongod_conf'))['auditLog', 'path'] - mongodb_service_account = input('mongodb_service_account') - mongodb_service_group = input('mongodb_service_group') - - describe file(mongodb_auditlog_dir) do - it { should exist } - end - - describe file(mongodb_auditlog_dir) do - it { should_not be_more_permissive_than('0700') } - its('owner') { should be_in mongodb_service_account } - its('group') { should be_in mongodb_service_group } - end - - describe command("dirname #{mongodb_auditlog_dir}") do - it { should cmp '/var/lib/mongo' } + if yaml(input('mongod_conf'))['auditLog', 'destination'].eql?('file') + mongodb_auditlog_path = command("dirname #{yaml(input('mongod_conf'))['auditLog', 'path']}").stdout + mongodb_service_account = input('mongodb_service_account') + mongodb_service_group = input('mongodb_service_group') + + describe "AuditLog destination path: #{mongodb_auditlog_path}" do + subject { directory(mongodb_auditlog_path) } + it { should exist } + end + + if directory(mongodb_auditlog_path).exist? + describe directory(command("dirname #{mongodb_auditlog_path}")) do + it { should_not be_more_permissive_than('0700') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } + end + end + else + impact 0.0 + describe 'Auditlog destination type `file` not in use; Control Non Applicable;' do + skip + end end end diff --git a/controls/V-81851.rb b/controls/V-81851.rb index 9be1b6c..2202f27 100644 --- a/controls/V-81851.rb +++ b/controls/V-81851.rb @@ -58,7 +58,7 @@ tag "severity": 'medium' tag "gtitle": 'SRG-APP-000121-DB-000202' tag "satisfies": %w(SRG-APP-000121-DB-000202 SRG-APP-000122-DB-000203 - SRG-APP-000122-DB-000204) + SRG-APP-000122-DB-000204) tag "gid": 'V-81851' tag "rid": 'SV-96565r1_rule' tag "stig_id": 'MD3X-00-000220' diff --git a/controls/V-81865.rb b/controls/V-81865.rb index a6896d6..1c80eae 100644 --- a/controls/V-81865.rb +++ b/controls/V-81865.rb @@ -45,13 +45,19 @@ tag "documentable": false tag "severity_override_guidance": false - describe 'MongoDB Server should be configured with a non-default authentication Mechanism' do - subject { processes('mongod') } - its('commands.join') { should match /authenticationMechanisms/ } - end - - describe 'MongoDB Server authentication Mechanism' do - subject { processes('mongod').commands.join } - it { should_not match /SCRAM-SHA1|MONGODB-CR|PLAIN/ } + if processes('mongod').commands.join =~ /GSSAPI|PLAIN/ + describe 'Manually verify MongoDB server enforces the DoD standards for password complexity and lifetime' do + skip + end + else + describe 'MongoDB Server should be configured with a non-default authentication Mechanism' do + subject { processes('mongod') } + its('commands.join') { should match /authenticationMechanisms/ } + end + + describe 'MongoDB Server authentication Mechanism' do + subject { processes('mongod').commands.join } + it { should_not match /SCRAM-SHA|MONGODB-CR/ } + end end end diff --git a/controls/V-81867.rb b/controls/V-81867.rb index 6cb92cf..feb1632 100644 --- a/controls/V-81867.rb +++ b/controls/V-81867.rb @@ -57,10 +57,8 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w(security authorization)) { should cmp 'enabled' } - end - describe yaml(input('mongod_conf')) do - its(%w(security clusterAuthMode)) { should cmp 'x509' } + describe 'MongoDB Server authentication Mechanism' do + subject { processes('mongod').commands.join } + it { should match /MONGODB-X509/ } end end diff --git a/controls/V-81869.rb b/controls/V-81869.rb index f00985c..7662ab3 100644 --- a/controls/V-81869.rb +++ b/controls/V-81869.rb @@ -71,10 +71,8 @@ describe yaml(input('mongod_conf')) do its(%w(net ssl mode)) { should cmp 'requireSSL' } end + describe yaml(input('mongod_conf')) do - its(%w(net ssl PEMKeyFile)) { should cmp '/etc/ssl/mongodb.pem' } - end - describe yaml(input('mongod_conf')) do - its(%w(net ssl CAFile)) { should cmp '/etc/ssl/mongodbca.pem' } + its(%w(net ssl CAFile)) { should_not be_nil } end end diff --git a/controls/V-81871.rb b/controls/V-81871.rb index 110a9a7..c2db68a 100644 --- a/controls/V-81871.rb +++ b/controls/V-81871.rb @@ -64,23 +64,31 @@ mongodb_service_account = input('mongodb_service_account') mongodb_service_group = input('mongodb_service_group') - describe file(mongod_pem) do + describe "Mongod SSL PEMKeyFile: #{mongod_pem}" do + subject { file(mongod_pem) } it { should exist } end - describe file(mongod_pem) do - it { should_not be_more_permissive_than('0600') } - its('owner') { should be_in mongodb_service_account } - its('group') { should be_in mongodb_service_group } + if file(mongod_pem).exist? + describe "Mongod SSL PEMKeyFile: #{mongod_pem}" do + subject { file(mongod_pem) } + it { should_not be_more_permissive_than('0600') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } + end end - describe file(mongod_cafile) do + describe "Mongod SSL CAFile: #{mongod_cafile}" do + subject { file(mongod_cafile) } it { should exist } end - describe file(mongod_cafile) do - it { should_not be_more_permissive_than('0600') } - its('owner') { should be_in mongodb_service_account } - its('group') { should be_in mongodb_service_group } + if file(mongod_cafile).exist? + describe "Mongod SSL CAFile: #{mongod_cafile}" do + subject { file(mongod_cafile) } + it { should_not be_more_permissive_than('0600') } + its('owner') { should be_in mongodb_service_account } + its('group') { should be_in mongodb_service_group } + end end end diff --git a/controls/V-81875.rb b/controls/V-81875.rb index 3922eb2..5965097 100644 --- a/controls/V-81875.rb +++ b/controls/V-81875.rb @@ -63,8 +63,8 @@ tag "severity": 'high' tag "gtitle": 'SRG-APP-000179-DB-000114' tag "satisfies": %w(SRG-APP-000179-DB-000114 SRG-APP-000514-DB-000381 - SRG-APP-000514-DB-000382 SRG-APP-000514-DB-000383 - SRG-APP-000416-DB-000380) + SRG-APP-000514-DB-000382 SRG-APP-000514-DB-000383 + SRG-APP-000416-DB-000380) tag "gid": 'V-81875' tag "rid": 'SV-96589r1_rule' tag "stig_id": 'MD3X-00-000380' @@ -78,6 +78,10 @@ describe yaml(input('mongod_conf')) do its(%w(net ssl FIPSMode)) { should cmp 'true' } end + + describe file('/proc/sys/crypto/fips_enabled') do + its('content') { should cmp 1 } + end else describe 'The system is not a classified environment, therefore for this control is NA' do skip 'The system is not a classified environment, therefore for this control is NA' diff --git a/controls/V-81877.rb b/controls/V-81877.rb index 053ced0..8f79427 100644 --- a/controls/V-81877.rb +++ b/controls/V-81877.rb @@ -76,7 +76,7 @@ tag "severity": 'medium' tag "gtitle": 'SRG-APP-000180-DB-000115' tag "satisfies": %w(SRG-APP-000180-DB-000115 SRG-APP-000211-DB-000122 - SRG-APP-000211-DB-000124) + SRG-APP-000211-DB-000124) tag "gid": 'V-81877' tag "rid": 'SV-96591r1_rule' tag "stig_id": 'MD3X-00-000390' diff --git a/controls/V-81897.rb b/controls/V-81897.rb index 57542f7..f83529d 100644 --- a/controls/V-81897.rb +++ b/controls/V-81897.rb @@ -61,7 +61,7 @@ tag "severity": 'medium' tag "gtitle": 'SRG-APP-000311-DB-000308' tag "satisfies": %w(SRG-APP-000311-DB-000308 SRG-APP-000313-DB-000309 - SRG-APP-000313-DB-000310) + SRG-APP-000313-DB-000310) tag "gid": 'V-81897' tag "rid": 'SV-96611r1_rule' tag "stig_id": 'MD3X-00-000540' diff --git a/controls/V-81905.rb b/controls/V-81905.rb index 0a412ed..b266516 100644 --- a/controls/V-81905.rb +++ b/controls/V-81905.rb @@ -60,8 +60,14 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w(auditLog destination)) { should_not cmp 'file' } - its(%w(auditLog destination)) { should_not be_nil } + if yaml(input('mongod_conf'))['auditLog', 'destination'].eql?('file') + describe "Manually verify sufficient space is allocated to the storage volume hosting the file identified in the MongoDB configuration #{yaml(input('mongod_conf'))['auditLog', 'path']} to support audit file peak demand." do + skip + end + else + impact 0.0 + describe 'Auditlog destination type `file` not in use; Control Non Applicable;' do + skip + end end end diff --git a/controls/V-81907.rb b/controls/V-81907.rb index b137682..9d92348 100644 --- a/controls/V-81907.rb +++ b/controls/V-81907.rb @@ -49,8 +49,14 @@ tag "documentable": false tag "severity_override_guidance": false - describe yaml(input('mongod_conf')) do - its(%w(auditLog destination)) { should_not cmp 'file' } - its(%w(auditLog destination)) { should_not be_nil } + if yaml(input('mongod_conf'))['auditLog', 'destination'].eql?('file') + describe 'Manually verify MongoDB must provide a warning to appropriate support staff when allocated audit record storage volume reaches 75% of maximum audit record storage capacity.' do + skip + end + else + impact 0.0 + describe 'Auditlog destination type `file` not in use; Control Non Applicable;' do + skip + end end end diff --git a/controls/V-81915.rb b/controls/V-81915.rb index 19367e5..37147fd 100644 --- a/controls/V-81915.rb +++ b/controls/V-81915.rb @@ -41,7 +41,7 @@ tag "documentable": false tag "severity_override_guidance": false - if input('mongo_use_saslauthd') == 'true' && input('mongo_use_ldap') == 'true' + if input('mongo_use_saslauthd') == true && input('mongo_use_ldap') == true describe processes('saslauthd') do its('commands.join') { should match /-t\s/ } end diff --git a/controls/V-81917.rb b/controls/V-81917.rb index 49373c6..acebae0 100644 --- a/controls/V-81917.rb +++ b/controls/V-81917.rb @@ -43,15 +43,15 @@ tag "severity_override_guidance": false # Process flag takes precedence over the conf file - x509_conf = yaml(input('mongod_conf'))['net', 'tls', 'certificateKeyFile'] - x509_process_flag = processes('mongod').commands.join.gsub('--tlsCertificateKeyFile', '').strip + certificate_key_file_conf = yaml(input('mongod_conf'))['net', 'tls', 'certificateKeyFile'] + certificate_key_file_flag = processes('mongod').commands.join.scan(/--tlsCertificateKeyFile\s([^:]*?)\s/).join - x509_cert_file = input('x509_cert_file') unless input('x509_cert_file').nil? - x509_cert_file = x509_conf unless x509_conf.nil? - x509_cert_file = x509_process_flag unless x509_process_flag.nil? + certificate_key_file = input('certificate_key_file') unless input('certificate_key_file').nil? + certificate_key_file = certificate_key_file_conf unless certificate_key_file_conf.nil? + certificate_key_file = certificate_key_file_flag unless certificate_key_file_flag.empty? - if file(x509_cert_file).exist? - describe x509_certificate(x509_cert_file) do + if file(certificate_key_file).exist? + describe x509_certificate(certificate_key_file) do its('issuer_dn') { should eq input('authorized_certificate_authority') } end else diff --git a/controls/V-81919.rb b/controls/V-81919.rb index 8998040..bc16b70 100644 --- a/controls/V-81919.rb +++ b/controls/V-81919.rb @@ -60,21 +60,27 @@ tag "documentable": false tag "severity_override_guidance": false - describe.one do - describe yaml(input('mongod_conf')) do - its(%w(security kmip serverName)) { should_not be_nil } - its(%w(security kmip port)) { should_not be_nil } - its(%w(security kmip port)) { should_not be_nil } - its(%w(security kmip serverCAFile)) { should_not be_nil } - its(%w(security kmip clientCertificateFile)) { should_not be_nil } - its(%w(security enableEncryption)) { should cmp 'true' } + if input('is_sensitive') + describe.one do + describe yaml(input('mongod_conf')) do + its(%w(security kmip serverName)) { should_not be_nil } + its(%w(security kmip port)) { should_not be_nil } + its(%w(security kmip port)) { should_not be_nil } + its(%w(security kmip serverCAFile)) { should_not be_nil } + its(%w(security kmip clientCertificateFile)) { should_not be_nil } + its(%w(security enableEncryption)) { should cmp 'true' } + end + describe processes('mongod') do + its('commands.join') { should match /--enableEncryption/ } + its('commands.join') { should match /--kmipServerName/ } + its('commands.join') { should match /--kmipPort/ } + its('commands.join') { should match /--kmipServerCAFile/ } + its('commands.join') { should match /--kmipClientCertificateFile/ } + end end - describe processes('mongod') do - its('commands.join') { should match /--enableEncryption/ } - its('commands.join') { should match /--kmipServerName/ } - its('commands.join') { should match /--kmipPort/ } - its('commands.join') { should match /--kmipServerCAFile/ } - its('commands.join') { should match /--kmipClientCertificateFile/ } + else + describe 'The system is not a classified environment, therefore for this control is NA' do + skip 'The system is not a classified environment, therefore for this control is NA' end end end diff --git a/controls/V-81927.rb b/controls/V-81927.rb index b9a1c0d..cb273fb 100644 --- a/controls/V-81927.rb +++ b/controls/V-81927.rb @@ -73,9 +73,7 @@ installed_tools = [] tools.each do |tool| - if command(tool).exist? - installed_tools << tool - end + installed_tools << tool if command(tool).exist? end describe "Manually review that the use presence of tools `#{installed_tools}.to_s` is authorized and the users have the required training." do diff --git a/inputs.yml b/inputs.yml index d2ac3e5..7240bb0 100644 --- a/inputs.yml +++ b/inputs.yml @@ -1,19 +1,3 @@ -mongod_conf: '/etc/mongod.conf' -mongo_data_dir: '/var/lib/mongo' - -mongod_hostname: 'MONGODB' - -mongo_use_ldap: 'false' -mongo_use_saslauthd: 'false' - -approved_mongo_packages: [ - 'mongodb-enterprise', - 'mongodb-enterprise-mongos', - 'mongodb-enterprise-server', - 'mongodb-enterprise-shell', - 'mongodb-enterprise-tools' -] - username: 'mongoadmin' password: 'mongoadmin' mongod_hostname: '127.0.0.1' @@ -24,13 +8,18 @@ mongod_client_pem: null mongod_cafile: null authentication_database: null authentication_mechanism: null - +mongod_conf: '/etc/mongod.conf' +mongo_data_dir: '/var/lib/mongo' +mongo_use_ldap: false +mongo_use_saslauthd: false +approved_mongo_packages: [ + 'mongodb-enterprise', + 'mongodb-enterprise-mongos', + 'mongodb-enterprise-server', + 'mongodb-enterprise-shell', + 'mongodb-enterprise-tools' + ] mongodb_service_account: ["mongodb", "mongod"] mongodb_service_group: ["mongodb", "mongod"] -db_owners: ["mongodb", "mongod"] -mongodb_service_account: ['mongod', 'mongodb'] -mongodb_service_group: ['mongod', 'mongodb'] - is_sensitive: true - -x509_cert_file: "/etc/ssl/mongodb.pem" \ No newline at end of file +certificate_key_file: "/etc/ssl/mongodb.pem" \ No newline at end of file diff --git a/inspec.yml b/inspec.yml index 196ae64..5fe6b46 100644 --- a/inspec.yml +++ b/inspec.yml @@ -69,14 +69,14 @@ inputs: - name: mongo_use_ldap description: 'MongoDB is Using LDAP - True/False' - type: string - value: 'false' + type: boolean + value: false required: true - name: mongo_use_saslauthd description: 'MongoDB is Using SASLAUTHD - True/False' - type: string - value: 'false' + type: boolean + value: false required: true - name: approved_mongo_packages From b049070083c01dd9d473261f6402aa08c6d33667 Mon Sep 17 00:00:00 2001 From: Rony Xavier Date: Sun, 27 Jun 2021 22:05:38 -0400 Subject: [PATCH 32/32] Profile metadata updates Signed-off-by: Rony Xavier --- README.md | 168 ++++++++++++++++++++++++++++++++--------------------- inspec.yml | 2 +- 2 files changed, 104 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 6bcb9a5..7ce0670 100644 --- a/README.md +++ b/README.md @@ -13,71 +13,107 @@ Latest versions and installation options are available at the [InSpec](http://in The following inputs must be configured in an inputs ".yml" file for the profile to run correctly for your specific environment. More information about InSpec inputs can be found in the [InSpec Profile Documentation](https://www.inspec.io/docs/reference/profiles/). ```yaml -# MongoDB configuration file -mongod_conf: '' - -# MongoDB Home Directory' -mongo_data_dir: '' - -# MongoDB Server PEM File' -mongod_pem: '' - -# MongoDB CA File -mongod_cafile: '' - -# MongoDB Client PEM File -mongod_client_pem: '' - -# MongoDB Audit Log File -mongod_auditlog: '' - -# MongoDB SASLAUTHD File -saslauthd: '' - -# MongoDB is Running in Docker Environment - True/False -is_docker: '' - -# MongoDB is Using PKI Authentication - True/False -mongo_use_pki: '' - -# MongoDB is Using LDAP - True/False -mongo_use_ldap: '' - -# MongoDB is Using SASLAUTHD - True/False -mongo_use_saslauthd: '' - -# List of MongoDB Redhat Packages -mongodb_redhat_packages: [] - -# List of MongoDB Debian Packages -mongodb_debian_packages: [] - -# User to log into the mongo database -user: '' - -# password to log into the mongo database -password: '' - -# List of authorized users of the admn database -admin_db_users: [] - -# List of authorized users of the admn database -config_db_users: [] - -# List of authorized users of the admn database -myUserAdmin_allowed_role: [] - -# List of authorized users of the admn database -mongoadmin_allowed_role: [] - -# List of authorized users of the admn database -mongodb_admin_allowed_role: [] - -# List of authorized users of the admn database -appAdmin_allowed_role: [] - -# List of authorized users of the admn database -accountAdmin01_allowed_role: [] + - name: username + description: 'User to log into the mongo database' + value: null + sensitive: true + + - name: password + description: 'Password to log into the mongo database' + value: null + sensitive: true + + - name: mongod_hostname + description: 'Hostname for mongodb database' + type: string + value: '127.0.0.1' + + - name: mongod_port + description: 'Port number for the mongodb database' + type: string + value: '27017' + + - name: ssl + description: 'Is ssl enabled' + type: boolean + value: false + + - name: verify_ssl + description: 'Flag for sslAllowInvalidCertificates' + type: boolean + value: false + + - name: mongod_client_pem + description: 'PEM file location on the scan target' + value: null + + - name: mongod_cafile + description: 'CAFILE location on the scan target' + value: null + + - name: authentication_database + description: 'Flag for authentication database' + value: null + + - name: authentication_mechanism + description: 'Flag for authentication mechanism' + value: null + + - name: mongod_conf + description: 'MongoDB configuration file' + type: string + value: '/etc/mongod.conf' + required: true + + - name: mongo_data_dir + description: 'MongoDB Home Directory' + type: string + value: '/var/lib/mongo' + required: true + + - name: mongo_use_ldap + description: 'MongoDB is Using LDAP - True/False' + type: boolean + value: false + required: true + + - name: mongo_use_saslauthd + description: 'MongoDB is Using SASLAUTHD - True/False' + type: boolean + value: false + required: true + + - name: approved_mongo_packages + description: 'List of MongoDB Packages' + type: array + value: [ + 'mongodb-enterprise', + 'mongodb-enterprise-mongos', + 'mongodb-enterprise-server', + 'mongodb-enterprise-shell', + 'mongodb-enterprise-tools' + ] + required: true + + - name: mongodb_service_account + description: 'Mongodb Service Account' + type: array + value: ["mongodb", "mongod"] + + - name: mongodb_service_group + description: 'Mongodb Service Group' + type: array + value: ["mongodb", "mongod"] + + - name: is_sensitive + description: 'Set to true if target is sensitive as described in control V-81875 and V-81919' + type: boolean + value: true + + - name: certificate_key_file + description: 'Path to server certificate key file' + type: string + value: "/etc/ssl/mongodb.pem" ``` # Running This Baseline Directly from Github @@ -124,6 +160,8 @@ The JSON InSpec results file may also be loaded into a __[full heimdall server]( ## Authors * Alicia Sturtevant - [asturtevant](https://github.com/asturtevant) +* Mohamed El-Sharkawi - [HackerShark](https://github.com/HackerShark) +* Rony Xavier - [rx294](https://github.com/rx294) ## Special Thanks * Mohamed El-Sharkawi - [HackerShark](https://github.com/HackerShark) diff --git a/inspec.yml b/inspec.yml index 5fe6b46..8bcfb86 100644 --- a/inspec.yml +++ b/inspec.yml @@ -52,7 +52,7 @@ inputs: value: null - name: authentication_mechanism - description: 'Flag for authenticaiton mechanism' + description: 'Flag for authentication mechanism' value: null - name: mongod_conf