Repository navigation
fix(sans): count only network interfaces as zones for SANS-FW-003 - #1024
intigenesis wants to merge 5 commits into
Conversation
OPNsense writes pseudo-interfaces into <interfaces> on every save: lo0 always, one entry per interface group, the OpenVPN and WireGuard groups while those services run, and enc0 while IPsec does. Each is enabled, so SANS-FW-003 (Network Zone Separation) counted lo0 as a second zone and passed on a firewall whose only network was WAN. The interface inventory finding counted them the same way. Both now count through analysis.IsNetworkZone, which leaves out interfaces marked virtual, as OPNsense does when it wants its real interfaces, and interface group entries. An IPsec VTI is not marked virtual and still counts. Signed-off-by: intigenesis <313311150+intigenesis@users.noreply.github.com>
OPNsense lets the operator create loopback devices lo1 and up and assign one as an optN interface. The assignment carries no virtual flag, so a WAN-only firewall with an assigned loopback still passed SANS-FW-003. IsNetworkZone now also leaves out an interface whose device is a loopback device. Tests pin that VLAN, bridge, LAGG, OpenVPN and WireGuard devices assigned as interfaces still count. The interface inventory text now says it counts network interfaces, and the compliance docs no longer describe SANS-FW-003 as a placeholder that always passes. Signed-off-by: intigenesis <313311150+intigenesis@users.noreply.github.com>
FIREWALL-063 was described as reporting enabled interfaces and their types. It reports a count, and since the SANS-FW-003 zone change that count leaves out loopback devices, interface groups and the VPN pseudo-interfaces. Update the control description and the controls reference to match. Signed-off-by: intigenesis <313311150+intigenesis@users.noreply.github.com>
Replace the "Implemented SANS Controls" rows and the SANS checks list with text that holds for every SANS check as implemented, and describe what SANS-FW-003 does not count as a zone at the end of the Network Architecture subsection instead. In the controls reference, restore the Configuration Inventory table and state the FIREWALL-063 counting rule in a paragraph below it. Signed-off-by: intigenesis <313311150+intigenesis@users.noreply.github.com>
The SANS intro still said the plugin defines four placeholder controls, the status key still defined a Placeholder status no control carries, and Planned Features still listed replacing placeholder stubs. Replace them with the shared text the other branches carry. Signed-off-by: intigenesis <313311150+intigenesis@users.noreply.github.com>
|
No actionable comments were generated in the recent review. Summary by CodeRabbit
WalkthroughThe change adds shared classification and counting for enabled network interfaces. Firewall inventory and SANS-FW-003 use the network-zone count. Tests cover interface exclusions and included devices, and documentation describes the updated counting rules and SANS control status. ChangesNetwork Zone Counting
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested labels: Merge Risk:
|
Merge Protections🔴 1 of 4 protections blocking · waiting on 🙋 you
🔴 🚦 Auto-queueThis rule is failing.When all merge protections are satisfied and these conditions match, this pull request will be queued automatically.
Show 3 satisfied protections🟢 Enforce conventional commitRequire conventional commit format per https://www.conventionalcommits.org/en/v1.0.0/. Skipped for dependabot and dosubot.
🟢 Full CI must passAll CI checks must pass. Activates for non-bot authors, or dependabot when files exist outside .github/workflows/.
🟢 Do not merge outdated PRsMake sure PRs are within 10 commits of the base branch before merging
|
|
Tick the box to add this pull request to the merge queue (same as
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Pull Request
Description
OPNsense writes pseudo-interfaces into
<interfaces>on every save (plugins_interfacesinplugins.inc):lo0always, one entry per interface group, the OpenVPN and WireGuard group entries while those services run, andenc0while IPsec does. Each is enabled and marked<virtual>1</virtual>. SANS-FW-003 (Network Zone Separation) counted every enabled interface, so lo0 made a firewall whose only network is WAN pass. The interface inventory finding counted them the same way.Both now count through a new
analysis.IsNetworkZone, which leaves out interfaces marked virtual, as OPNsense itself does when it wants its real interfaces (legacy_config_get_interfaces(['virtual' => false])), interface group entries, which stand for their members, and interfaces assigned to a loopback device (lo1and up, which the operator can create and assign with no virtual flag). An IPsec VTI is registered without the virtual flag and is a routed interface to a remote network, so it still counts, as do assigned VLAN, bridge, LAGG, OpenVPN and WireGuard devices. The inventory text now reads "N enabled network interface(s)".Five commits:
fix(sans): count only network interfaces as zones for SANS-FW-003adds the predicate and uses it in SANS-FW-003 and the interface inventory.fix(sans): leave assigned loopback devices out of SANS-FW-003 zonesadds the loopback case, the "network interface(s)" inventory wording, and tests that pin which assigned devices count.docs(firewall): describe FIREWALL-063 as a count of network interfacesupdates the control's description.docs(compliance): use the shared SANS check text and move zone notesrewrites the "Implemented SANS Controls" rows and the SANS checks list, and adds the zone paragraph to the Network Architecture subsection and a FIREWALL-063 paragraph to the controls reference.docs(compliance): drop the remaining SANS placeholder textupdates the SANS intro, the status key and Planned Features.The compliance standards page described all four implemented SANS controls as placeholders that always return compliant. It now marks SANS-FW-001 to SANS-FW-004 as Implemented and says what each one looks at, and it drops the Placeholder status from the status key and "Real SANS Check Logic" from Planned Features. The SANS intro now says the plugin defines SANS-FW-001 to SANS-FW-025, and that some of them report Unknown.
pfSense does not write lo0 or group entries into
<interfaces>; the same predicate applies to it unchanged.Type of Change
Related Issues
Testing
Pre-submission Checklist
gofmt)golangci-lint)go test ./...)go mod tidy)Test Commands Executed
Test Results
All of the above pass. With the previous SANS and inventory checks, the four WAN-only cases of
TestSANSPlugin_ZoneSeparation_PseudoInterfacesAreNotZones(with lo0, with an interface group, with the VPN pseudo-interfaces, with an assigned loopback) and both cases ofTestFirewallPlugin_InterfaceInventory_SkipsPseudoInterfacesfail. The cases for assigned VLAN, bridge, LAGG, OpenVPN and WireGuard devices pass before and after. No golden file changes.With
testdata/sample.config.5.xmledited to disable LAN (the repro in the issue),opndossier audit wan-only.xml --mode blue --format json -o audit.json --forcereports SANS-FW-003 asPASSand2 enabled interface(s)before the change, andFAILand1 enabled network interface(s)after it.Changes Made
Files Modified
internal/analysis/zones.go(new):IsNetworkZoneandCountNetworkZonesinternal/plugins/sans/checks.go:checkZoneSeparationcounts network zonesinternal/plugins/firewall/checks_inventory.go: the interface inventory check and its description count network interfacesdocs/compliance-standards.md: SANS intro; SANS-FW-001 to SANS-FW-004 status and descriptions in the "Implemented SANS Controls" table and the SANS checks list; zone paragraph in the Network Architecture subsection; Placeholder removed from the status key; "Real SANS Check Logic" removed from Planned Featuresdocs/firewall-security-controls-reference.md: a paragraph on what FIREWALL-063 counts, below the Configuration Inventory tableinternal/plugins/firewall/controls.go: FIREWALL-063 descriptioninternal/analysis/zones_test.go,internal/plugins/sans/zone_separation_test.go,internal/plugins/firewall/interface_inventory_zones_test.go;checks_inventory_test.goupdated for the new wordingKey Changes
virtualandtypeset.Review Checklist
For Reviewers
For Contributors
feat/,fix/,docs/, etc.)Documentation
Documentation Updates
README.md
CONTRIBUTING.md
docs/development/standards.md
docs/development/architecture.md
Project specification files
docs/compliance-standards.md: the SANS intro, the SANS-FW-001 to SANS-FW-004 rows and checks list, the zone paragraph, the status key and Planned Features.docs/firewall-security-controls-reference.md: a paragraph on what FIREWALL-063 counts and leaves out.API Changes
None in
pkg/.internal/analysisgainsIsNetworkZoneandCountNetworkZones.Breaking Changes
None.
Migration Guide
Not applicable.
Security Considerations
Closes a false pass on a high-severity control: a single-network firewall read as segmented.
Performance Impact
None.
Acceptance Criteria
Additional Notes
The red-mode enumeration count (
enumeration_data.interfaces) and the blue configuration summary count every configured interface, lo0 included. They count configured interfaces rather than enabled zones, and are left for a separate change.The FIREWALL-063 row in the summary table of
docs/firewall-security-controls-reference.mdstill reads "Reports enabled interfaces and their types" on this branch. The dnsmasq PR rewrites that row to describe the count, so this PR leaves it alone and the two merge cleanly; the paragraph below the table states which interfaces are counted.Labels
bug-fixAI disclosure
Used Claude Code (
claude-opus-5-5) to draft the SANS-FW-003 zone counting fix and its tests. All changes reviewed locally before push. Followed process perAI_POLICY.md.