Skip to content

Commit

Permalink
3-5 Fix loopback address match
Browse files Browse the repository at this point in the history
Fix regression introduced since ad53969,
in this CIS checks 3.5.1.4 and 3.5.2.4 were updated to filter open ports
with address `127.0.0.1` to `127.` which never matches.

Update filtering to check for a full IPv4 address corresponding to
CIDR 127.0.0.0/8

Signed-off-by: Ivo van Doorn <[email protected]>
  • Loading branch information
IvDoorn committed Dec 4, 2023
1 parent c5174f9 commit 95a2a7a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controls/3_5_firewall_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
tag cis: 'distribution-independent-linux:3.5.1.4'
tag level: 1

port.where { address !~ /^(127\.|::1)$/ }.ports.each do |port|
port.where { address !~ /^(127\.[0-9]+\.[0-9]+\.[0-9]+|::1)$/ }.ports.each do |port|
describe "Firewall rule should exist for port #{port}" do
subject { ip6tables.retrieve_rules.any? { |s| s =~ /\s--(dport|dports) #{port}\s/ } }
it { should be true }
Expand Down Expand Up @@ -214,7 +214,7 @@
tag cis: 'distribution-independent-linux:3.5.2.4'
tag level: 1

port.where { address !~ /^(127\.|::1)$/ }.ports.each do |port|
port.where { address !~ /^(127\.[0-9]+\.[0-9]+\.[0-9]+|::1)$/ }.ports.each do |port|
describe "Firewall rule should exist for port #{port}" do
subject { iptables.retrieve_rules.any? { |s| s =~ /\s--(dport|dports) #{port}\s/ } }
it { should be true }
Expand Down

0 comments on commit 95a2a7a

Please sign in to comment.