Skip to content

Commit 4b67c2d

Browse files
committed
feat: expand security check: add other passwd and group files
Currently only `/etc/passwd` is checked to have the right permissions, but there are other files that contain unix account related configuration: - /etc/passwd- (a backup file for /etc/passwd) - /etc/group (contains group configuration and membership) - /etc/group- (a backup file for /etc/group-) While the control requires `/etc/passwd` and `/etc/group` to exist, the rules for their backup counterparts are a bit more relaxed. The checks will be skipped, if those files do not exist. Signed-off-by: Claudius Heine <[email protected]>
1 parent 5d29e31 commit 4b67c2d

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

controls/os_spec.rb

+60
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,63 @@
334334
it { should_not be_readable.by('other') }
335335
end
336336
end
337+
338+
control 'os-17' do
339+
impact 1.0
340+
title 'Check owner and permissions for /etc/group'
341+
desc 'Check periodically the owner and permissions for /etc/group'
342+
describe file('/etc/group') do
343+
it { should exist }
344+
it { should be_file }
345+
it { should be_owned_by 'root' }
346+
its('group') { should eq 'root' }
347+
it { should_not be_executable }
348+
it { should be_writable.by('owner') }
349+
it { should be_readable.by('owner') }
350+
it { should_not be_writable.by('group') }
351+
it { should be_readable.by('group') }
352+
it { should_not be_writable.by('other') }
353+
it { should be_readable.by('other') }
354+
end
355+
end
356+
357+
control 'os-18' do
358+
impact 1.0
359+
title 'Check owner and permissions for /etc/passwd-'
360+
desc 'Check periodically the owner and permissions for /etc/passwd-'
361+
only_if('/etc/passwd- exists') do
362+
file('/etc/passwd-').exist?
363+
end
364+
describe file('/etc/passwd-') do
365+
it { should be_file }
366+
it { should be_owned_by 'root' }
367+
its('group') { should eq 'root' }
368+
it { should_not be_executable }
369+
it { should be_writable.by('owner') }
370+
it { should be_readable.by('owner') }
371+
it { should_not be_writable.by('group') }
372+
it { should be_readable.by('group') }
373+
it { should_not be_writable.by('other') }
374+
it { should be_readable.by('other') }
375+
end
376+
end
377+
378+
control 'os-19' do
379+
impact 1.0
380+
title 'Check owner and permissions for /etc/group-'
381+
desc 'Check periodically the owner and permissions for /etc/group-'
382+
only_if('/etc/group- exists') do
383+
file('/etc/group-').exist?
384+
end
385+
describe file('/etc/group-') do
386+
it { should be_owned_by 'root' }
387+
its('group') { should eq 'root' }
388+
it { should_not be_executable }
389+
it { should be_writable.by('owner') }
390+
it { should be_readable.by('owner') }
391+
it { should_not be_writable.by('group') }
392+
it { should be_readable.by('group') }
393+
it { should_not be_writable.by('other') }
394+
it { should be_readable.by('other') }
395+
end
396+
end

0 commit comments

Comments
 (0)