Skip to content

Commit 51ae37f

Browse files
committed
More robust firewall detection on FreeBSD?
1 parent 957c9de commit 51ae37f

File tree

1 file changed

+44
-18
lines changed

1 file changed

+44
-18
lines changed

cmd/agent/checks.yaml

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ checks:
110110
firewall:
111111
description: "Verify system firewall is enabled"
112112
darwin:
113+
# macOS Application Firewall provides sufficient protection for compliance
113114
- output: /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
114115
includes: "disabled|off"
115116
remediation:
116-
- Enable the firewall
117+
- Enable the Application Firewall for network protection
117118
- Go to System Preferences > Security & Privacy > Firewall
118119
- Click "Turn On Firewall"
120+
- Note: This enables the application-layer firewall which is sufficient for security compliance
119121
linux:
120122
- output: ufw status
121123
includes: "Status: inactive"
@@ -130,33 +132,57 @@ checks:
130132
remediation:
131133
- Configure iptables rules for basic protection
132134
freebsd:
133-
# Try sudo first, then doas
134-
- output: sudo pfctl -s info 2>/dev/null || doas pfctl -s info 2>/dev/null
135-
includes: "Status: Disabled"
135+
# Try sudo first, then doas, then direct access
136+
- output: (sudo pfctl -s info 2>/dev/null || doas pfctl -s info 2>/dev/null || pfctl -s info 2>/dev/null) | grep -i status
137+
includes: "Disabled"
136138
remediation:
137-
- Enable PF firewall with 'sudo pfctl -e'
138-
- Configure /etc/pf.conf
139+
- Enable PF firewall with 'sudo pfctl -e' or 'doas pfctl -e'
140+
- Configure /etc/pf.conf with appropriate rules
139141
- Add pf_enable="YES" to /etc/rc.conf
142+
- Start with 'service pf start'
143+
# Also check if PF is even loaded in the kernel
144+
- output: kldstat | grep -q pf.ko && echo "loaded" || echo "not loaded"
145+
includes: "not loaded"
146+
remediation:
147+
- Load PF kernel module with 'sudo kldload pf'
148+
- Add pf_load="YES" to /boot/loader.conf for persistence
149+
# Check if ipfw is being used instead of pf
150+
- output: (sudo ipfw list 2>/dev/null || doas ipfw list 2>/dev/null || ipfw list 2>/dev/null) | head -1
151+
excludes: "00001|65535"
152+
remediation:
153+
- IPFW firewall appears to be inactive or not configured
154+
- Add firewall rules with 'ipfw add' commands
155+
- Configure /etc/rc.conf with firewall_enable="YES"
140156
openbsd:
141-
# OpenBSD primarily uses doas
142-
- output: doas pfctl -s info
143-
includes: "Status: Disabled"
157+
# OpenBSD has PF enabled by default, check if it's actually filtering
158+
- output: (doas pfctl -s info 2>/dev/null || pfctl -s info 2>/dev/null) | grep -i status
159+
includes: "Disabled"
160+
remediation:
161+
- Enable PF firewall with 'doas pfctl -e' or 'pfctl -e'
162+
- Configure /etc/pf.conf with appropriate rules
163+
- PF is typically enabled by default on OpenBSD
164+
# Check if there are any actual rules loaded
165+
- output: (doas pfctl -sr 2>/dev/null || pfctl -sr 2>/dev/null) | wc -l
166+
includes: "^0$"
144167
remediation:
145-
- Enable PF firewall with 'doas pfctl -e'
146-
- Configure /etc/pf.conf
168+
- No PF rules are loaded
169+
- Configure firewall rules in /etc/pf.conf
170+
- Load rules with 'doas pfctl -f /etc/pf.conf'
147171
netbsd:
148-
- output: sudo npfctl show 2>/dev/null || npfctl show
149-
includes: "inactive"
172+
- output: (sudo npfctl show 2>/dev/null || doas npfctl show 2>/dev/null || npfctl show 2>/dev/null) | grep -i config
173+
includes: "inactive|empty"
150174
remediation:
151175
- Enable NPF firewall
152-
- Configure /etc/npf.conf
176+
- Configure /etc/npf.conf with firewall rules
153177
- Add npf=YES to /etc/rc.conf
178+
- Start with 'service npf start'
154179
dragonfly:
155-
- output: sudo pfctl -s info 2>/dev/null || doas pfctl -s info 2>/dev/null
156-
includes: "Status: Disabled"
180+
- output: (sudo pfctl -s info 2>/dev/null || doas pfctl -s info 2>/dev/null || pfctl -s info 2>/dev/null) | grep -i status
181+
includes: "Disabled"
157182
remediation:
158-
- Enable PF firewall with 'sudo pfctl -e'
159-
- Configure /etc/pf.conf
183+
- Enable PF firewall with 'sudo pfctl -e' or 'doas pfctl -e'
184+
- Configure /etc/pf.conf with appropriate rules
185+
- Add pf_enable="YES" to /etc/rc.conf
160186
illumos:
161187
- output: ipfstat -io
162188
includes: "empty list"

0 commit comments

Comments
 (0)