Skip to content

Commit 1840dbb

Browse files
authored
feat: add rules to check noexec, nosuid and nodev mount options (#164)
Setting the `noexec`, `nosuid` and `nodev` mount options for mount points where those features are not required, limits possible attack vectors. Closes: #163 Signed-off-by: Claudius Heine <[email protected]>
1 parent e503f97 commit 1840dbb

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

controls/os_spec.rb

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,40 @@
4141

4242
cpuvulndir = '/sys/devices/system/cpu/vulnerabilities/'
4343

44+
# Overview of necessary mount options to be checked:
45+
#
46+
#---------------------------------------------------------
47+
# Mount point nodev noexec nosuid
48+
# /boot v v v
49+
# /dev v v
50+
# /dev/shm v v v
51+
# /home v v
52+
# /run v v
53+
# /tmp v v v
54+
# /var v v
55+
# /var/log v v v
56+
# /var/log/audit v v v
57+
# /var/tmp v v v
58+
#---------------------------------------------------------
59+
60+
mount_exec_blocklist = attribute(
61+
'mount_exec_blocklist',
62+
value: ['/boot', '/dev', '/dev/shm', '/tmp', '/var/log', '/var/log/audit', '/var/tmp'],
63+
description: 'List of mountspoints where \'noexec\' mount option shoud be set'
64+
)
65+
66+
mount_suid_blocklist = attribute(
67+
'mount_suid_blocklist',
68+
value: ['/boot', '/dev', '/dev/shm', '/home', '/run', '/tmp', '/var', '/var/log', '/var/log/audit', '/var/tmp'],
69+
description: 'List of mountpoints where \'nosuid\' mount option shoud be set'
70+
)
71+
72+
mount_dev_blocklist = attribute(
73+
'mount_dev_blocklist',
74+
value: ['/boot', '/dev/shm', '/home', '/run', '/tmp', '/var', '/var/log', '/var/log/audit', '/var/tmp'],
75+
description: 'List of mountpoints where \'nodev\' mount option shoud be set'
76+
)
77+
4478
control 'os-01' do
4579
impact 1.0
4680
title 'Trusted hosts login'
@@ -282,3 +316,45 @@
282316
end
283317
end
284318
end
319+
320+
control 'os-14' do
321+
impact 1.0
322+
title 'Check mountpoints for noexec mount options'
323+
desc 'Use the noexec mount options to limit attack vectors via mount points'
324+
325+
mount_exec_blocklist.each do |mnt_point|
326+
next unless mount(mnt_point).mounted?
327+
328+
describe mount(mnt_point) do
329+
its('options') { should include('noexec') }
330+
end
331+
end
332+
end
333+
334+
control 'os-15' do
335+
impact 1.0
336+
title 'Check mountpoints for nosuid mount options'
337+
desc 'Use the nosuid mount options to limit attack vectors via mount points'
338+
339+
mount_suid_blocklist.each do |mnt_point|
340+
next unless mount(mnt_point).mounted?
341+
342+
describe mount(mnt_point) do
343+
its('options') { should include('nosuid') }
344+
end
345+
end
346+
end
347+
348+
control 'os-16' do
349+
impact 1.0
350+
title 'Check mountpoints for nodev mount options'
351+
desc 'Use the nodev mount options to limit attack vectors via mount points'
352+
353+
mount_dev_blocklist.each do |mnt_point|
354+
next unless mount(mnt_point).mounted?
355+
356+
describe mount(mnt_point) do
357+
its('options') { should include('nodev') }
358+
end
359+
end
360+
end

0 commit comments

Comments
 (0)