Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all kernel parameter checks related to net.ipv6 conditional #155

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions controls/3_1_network_parameters_host_only.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

title '3.1 Network Parameters (Host Only)'

ipv6 = command('test -f /proc/net/if_inet6').exit_status

control 'cis-dil-benchmark-3.1.1' do
title 'Ensure IP forwarding is disabled'
desc "The net.ipv4.ip_forward flag is used to tell the system whether it can forward packets or not.\n\nRationale: Setting the flag to 0 ensures that a system with multiple interfaces (for example, a hard proxy), will never be able to forward packets, and therefore, never serve as a router."
Expand All @@ -27,10 +29,12 @@
tag cis: 'distribution-independent-linux:3.1.1'
tag level: 1

%w(
net.ipv4.ip_forward
net.ipv6.conf.all.forwarding
).each do |kp|
parameters = ['net.ipv4.ip_forward']
if ipv6.zero?
parameters += ['net.ipv6.conf.all.forwarding']
end

parameters.each do |kp|
describe kernel_parameter(kp) do
its('value') { should_not be_nil }
its('value') { should cmp 0 }
Expand Down
40 changes: 28 additions & 12 deletions controls/3_2_network_parameters_host_and_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

title '3.2 Network Parameters (Host and Router)'

ipv6 = command('test -f /proc/net/if_inet6').exit_status

control 'cis-dil-benchmark-3.2.1' do
title 'Ensure source routed packets are not accepted'
desc "In networking, source routing allows a sender to partially or fully specify the route packets take through a network. In contrast, non-source routed packets travel a path determined by routers in the network. In some cases, systems may not be routable or reachable from some locations (e.g. private addresses vs. Internet routable), and so source routed packets would need to be used.\n\nRationale: Setting net.ipv4.conf.all.accept_source_route and net.ipv4.conf.default.accept_source_route to 0 disables the system from accepting source routed packets. Assume this system was capable of routing packets to Internet routable addresses on one interface and private addresses on another interface. Assume that the private addresses were not routable to the Internet routable addresses and vice versa. Under normal routing circumstances, an attacker from the Internet routable addresses could not use the system as a way to reach the private address systems. If, however, source routed packets were allowed, they could be used to gain access to the private address systems as the route could be specified, rather than rely on routing protocols that did not allow this routing."
Expand All @@ -27,12 +29,18 @@
tag cis: 'distribution-independent-linux:3.2.1'
tag level: 1

%w(
net.ipv4.conf.all.accept_source_route
net.ipv4.conf.default.accept_source_route
net.ipv6.conf.all.accept_source_route
net.ipv6.conf.default.accept_source_route
).each do |kp|
parameters = [
'net.ipv4.conf.all.accept_source_route',
'net.ipv4.conf.default.accept_source_route',
]
if ipv6.zero?
parameters += [
'net.ipv6.conf.all.accept_source_route',
'net.ipv6.conf.default.accept_source_route',
]
end

parameters.each do |kp|
describe kernel_parameter(kp) do
its(:value) { should_not be_nil }
its(:value) { should eq 0 }
Expand All @@ -48,12 +56,18 @@
tag cis: 'distribution-independent-linux:3.2.2'
tag level: 1

%w(
net.ipv4.conf.all.accept_redirects
net.ipv4.conf.default.accept_redirects
net.ipv6.conf.all.accept_redirects
net.ipv6.conf.default.accept_redirects
).each do |kp|
parameters = [
'net.ipv4.conf.all.accept_redirects',
'net.ipv4.conf.default.accept_redirects',
]
if ipv6.zero?
parameters += [
'net.ipv6.conf.all.accept_redirects',
'net.ipv6.conf.default.accept_redirects',
]
end

parameters.each do |kp|
describe kernel_parameter(kp) do
its(:value) { should_not be_nil }
its(:value) { should eq 0 }
Expand Down Expand Up @@ -165,4 +179,6 @@
its(:value) { should eq 0 }
end
end

only_if { ipv6.zero? }
end