Skip to content

Commit

Permalink
Merge pull request #150 from dev-sec/cron
Browse files Browse the repository at this point in the history
add cron permissions hardening
  • Loading branch information
rndmh3ro authored Feb 22, 2021
2 parents df6b952 + 559b167 commit 11e04dd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions controls/os_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,23 @@
end
end
end

control 'os-13' do
impact 1.0
title 'Protect cron directories and files'
desc 'The cron directories and files should belong to root.'

cron_files = ['/etc/crontab', '/etc/cron.hourly', '/etc/cron.daily', '/etc/cron.weekly', '/etc/cron.monthly', '/etc/cron.d']

cron_files.each do |cron_file|
next unless file(cron_file).exist?

describe file(cron_file) do
it { should be_owned_by 'root' }
it { should_not be_writable.by('group') }
it { should_not be_writable.by('other') }
it { should_not be_readable.by('group') }
it { should_not be_readable.by('other') }
end
end
end

0 comments on commit 11e04dd

Please sign in to comment.