Skip to content

Commit f5418ba

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 d51d334 commit f5418ba

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
@@ -218,6 +218,66 @@
218218
end
219219
end
220220

221+
control 'os-03c' do
222+
impact 1.0
223+
title 'Check owner and permissions for /etc/group'
224+
desc 'Check periodically the owner and permissions for /etc/group'
225+
describe file('/etc/group') do
226+
it { should exist }
227+
it { should be_file }
228+
it { should be_owned_by 'root' }
229+
its('group') { should eq 'root' }
230+
it { should_not be_executable }
231+
it { should be_writable.by('owner') }
232+
it { should_not be_writable.by('group') }
233+
it { should_not be_writable.by('other') }
234+
it { should be_readable.by('owner') }
235+
it { should be_readable.by('group') }
236+
it { should be_readable.by('other') }
237+
end
238+
end
239+
240+
control 'os-03d' do
241+
impact 1.0
242+
title 'Check owner and permissions for /etc/passwd-'
243+
desc 'Check periodically the owner and permissions for /etc/passwd-'
244+
only_if('/etc/passwd- exists') do
245+
file('/etc/passwd-').exist?
246+
end
247+
describe file('/etc/passwd-') do
248+
it { should be_file }
249+
it { should be_owned_by 'root' }
250+
its('group') { should eq 'root' }
251+
it { should_not be_executable }
252+
it { should be_writable.by('owner') }
253+
it { should_not be_writable.by('group') }
254+
it { should_not be_writable.by('other') }
255+
it { should be_readable.by('owner') }
256+
it { should be_readable.by('group') }
257+
it { should be_readable.by('other') }
258+
end
259+
end
260+
261+
control 'os-03e' do
262+
impact 1.0
263+
title 'Check owner and permissions for /etc/group-'
264+
desc 'Check periodically the owner and permissions for /etc/group-'
265+
only_if('/etc/group- exists') do
266+
file('/etc/group-').exist?
267+
end
268+
describe file('/etc/group-') do
269+
it { should be_owned_by 'root' }
270+
its('group') { should eq 'root' }
271+
it { should_not be_executable }
272+
it { should be_writable.by('owner') }
273+
it { should_not be_writable.by('group') }
274+
it { should_not be_writable.by('other') }
275+
it { should be_readable.by('owner') }
276+
it { should be_readable.by('group') }
277+
it { should be_readable.by('other') }
278+
end
279+
end
280+
221281
control 'os-04' do
222282
impact 1.0
223283
title 'Dot in PATH variable'

0 commit comments

Comments
 (0)