Skip to content

Commit

Permalink
bug fix cpu flags and change default for net.ipv4.conf.all.log_martians
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Apr 29, 2016
1 parent 007a08f commit bb7c532
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions controls/sysctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
title 'Disable log martians'
desc 'log_martians can cause a denial of service attack to the host'
describe kernel_parameter('net.ipv4.conf.all.log_martians') do
its(:value) { should eq 0 }
its(:value) { should eq 1 }

This comment has been minimized.

Copy link
@rjhornsby

rjhornsby Jan 4, 2017

@chris-rock I'm confused about this change. If the intended behavior is to disable the logging[1], then wouldn't we want the parameter net.ipv4.conf.all.log_martians to be zero/off/false?

The test matches what the chef-os-hardening cookbook sets by default[2], but doesn't appear to match the title or the description here?

I'm not sure if that means the title/description should be updated to match the test, or if the cookbook should default this to 0 and the test was correct before? If we're talking about hardening, I'm leaning toward the title/description are right, and the cookbook+test are backwards?

It gets even more dicey because the CIS level 1 standards say the martian logging should be on[3a][3b]. The Chef base/os compliance profile says the logging should be off, matching the description of this test, if not the dev-sec cookbook and test itself.

Edit: Corrected last sentence.

[1] https://www.cyberciti.biz/faq/linux-log-suspicious-martian-packets-un-routable-source-addresses/
[2] https://github.com/dev-sec/chef-os-hardening/blob/master/attributes/sysctl.rb#L125-L126
[3a] https://github.com/Huddle/cis_centos6/blob/master/recipes/sysctl.rb#L30-L32
[3b] https://benchmarks.cisecurity.org/tools2/linux/cis_red_hat_enterprise_linux_6_benchmark_v1.1.0.pdf (page 78, section 4.2.4)

end
end

Expand Down Expand Up @@ -338,17 +338,17 @@
title 'CPU No execution Flag or Kernel ExecShield'
desc 'Kernel features and CPU flags provide a protection against buffer overflows. The CPU NX Flag and the kernel parameter exec-shield prevents code execution on a per memory page basis. If the CPU supports the NX-Flag then this should be used instead of the kernel parameter exec-shield.'

# parse for cpu flags
flags = parse_config_file('/proc/cpuinfo', assignment_re: /^([^:]*?)\s+:\s+(.*?)$/).flags
flags ||= ''
flags = flags.split(' ')

describe '/proc/cpuinfo' do
it 'Flags should include NX' do
expect(flags).to include('nx')
end
end

# parse for cpu flags
flags = parse_config_file('/proc/cpuinfo', assignment_re: /^([^:]*?)\s+:\s+(.*?)$/).flags
flags ||= ''
flags = flags.split(' ')

unless flags.include?('nx')
# if no nx flag is present, we require exec-shield
describe kernel_parameter('kernel.exec-shield') do
Expand Down

0 comments on commit bb7c532

Please sign in to comment.