Skip to content
Open
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
30 changes: 15 additions & 15 deletions docs/compliance-standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ STIGs are cybersecurity methodologies for standardizing security configuration w

The [SANS SCORE Firewall Checklist](https://www.sans.org/media/score/checklists/FirewallChecklist.pdf) (prepared by Krishni Naidu) is a practical security audit checklist containing 24 numbered security elements for firewall configuration and management. It covers ruleset management, application-layer controls, logging, patching, DMZ architecture, anti-spoofing, port security, remote access, traffic filtering, and availability.

The current SANS plugin defines 4 controls with placeholder check logic. The checklist has been fully analyzed and 16 additional controls are planned for implementation, covering the complete SANS checklist.
The SANS plugin defines SANS-FW-001 to SANS-FW-025. The four controls in the table below were implemented first; the sections after it map the rest of the checklist. Some controls, such as SANS-FW-010 and SANS-FW-011, cannot be decided from config.xml and report Unknown.

#### Implemented SANS Controls

| Control ID | SANS # | Category | Title | Severity | Status |
| ----------- | ------ | ---------------------- | --------------------------- | -------- | ----------- |
| SANS-FW-001 | 1, 9 | Access Control | Default Deny Policy | High | Placeholder |
| SANS-FW-002 | 1 | Rule Management | Explicit Rule Configuration | Medium | Placeholder |
| SANS-FW-003 | 6 | Network Segmentation | Network Zone Separation | High | Placeholder |
| SANS-FW-004 | 4 | Logging and Monitoring | Comprehensive Logging | Medium | Placeholder |
| SANS-FW-001 | 1, 9 | Access Control | Default Deny Policy | High | Implemented |
| SANS-FW-002 | 1 | Rule Management | Explicit Rule Configuration | Medium | Implemented |
| SANS-FW-003 | 6 | Network Segmentation | Network Zone Separation | High | Implemented |
| SANS-FW-004 | 4 | Logging and Monitoring | Comprehensive Logging | Medium | Implemented |

#### Planned SANS Controls

Expand Down Expand Up @@ -96,6 +96,8 @@ The following controls map to specific SANS SCORE Firewall Checklist items and a
| SANS-FW-016 | 13 | FTP Server Isolation | Medium | Partial | Check that FTP-related (TCP 21) pass rules route to DMZ/separate interface, not internal network |
| SANS-FW-019 | 16 | NAT / IP Masquerading | High | Full | Verify outbound NAT configured on WAN; check `NATConfig.OutboundMode`; ensure internal IPs are not exposed externally |

SANS-FW-003 counts only enabled network interfaces as zones. Loopback devices (lo0 and any assigned lo1 and up), interface groups and the VPN pseudo-interfaces OPNsense registers (the OpenVPN and WireGuard groups, enc0) do not count. Assigned VLAN, bridge, LAGG, OpenVPN, WireGuard and IPsec VTI devices do.

##### Server Protection and Availability (SANS Checklist #19, #22, #23, #24)

| Control ID | SANS # | Title | Severity | Implementability | Description |
Expand Down Expand Up @@ -137,7 +139,6 @@ See the [Firewall Security Controls Reference](firewall-security-controls-refere

- **Implemented** - Check logic evaluates config.xml data and produces compliant/non-compliant results
- **Unknown** - Control is defined but the required data is not available in config.xml (OS-level or model gap); the check always returns Unknown and no finding is emitted
- **Placeholder** - Control is defined with placeholder check logic that always returns compliant; real analysis will be added in a future release

#### Planned Firewall Security Controls

Expand Down Expand Up @@ -312,12 +313,12 @@ The audit engine performs the following checks per plugin:

#### SANS Compliance Checks

All four SANS checks currently use placeholder logic:
The SANS checks look at the following:

1. **Default Deny Policy (SANS-FW-001)** - Placeholder: always returns compliant
2. **Explicit Rule Configuration (SANS-FW-002)** - Placeholder: always returns compliant
3. **Network Zone Separation (SANS-FW-003)** - Placeholder: always returns compliant
4. **Comprehensive Logging (SANS-FW-004)** - Placeholder: always returns compliant
1. **Default Deny Policy (SANS-FW-001)** - Looks for an enabled any-to-any pass rule with no enabled block or reject rule.
2. **Explicit Rule Configuration (SANS-FW-002)** - Looks for enabled pass rules without a description.
3. **Network Zone Separation (SANS-FW-003)** - Counts enabled network interfaces; at least two are required.
4. **Comprehensive Logging (SANS-FW-004)** - Looks for remote syslog that carries filter or authentication logging.

#### Firewall Security Compliance Checks

Expand Down Expand Up @@ -462,10 +463,9 @@ Additional DISA Firewall SRG controls under consideration:

### Planned Features

1. **Real SANS Check Logic**: Replace placeholder stubs with actual analysis
2. **Automated Remediation**: Generate configuration fixes
3. **Compliance Monitoring**: Track compliance over time
4. **Integration**: SIEM and ticketing system integration
1. **Automated Remediation**: Generate configuration fixes
2. **Compliance Monitoring**: Track compliance over time
3. **Integration**: SIEM and ticketing system integration

## References

Expand Down
2 changes: 2 additions & 0 deletions docs/firewall-security-controls-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ The following controls are planned for future releases, organized by security do

**Note:** Configuration inventory controls use `Type: "inventory"` and are excluded from compliance evaluation. They are rendered in a separate "Configuration Notes" section of audit reports and do not affect pass/fail compliance status.

FIREWALL-063 counts enabled network interfaces only. Loopback devices, interface groups and the VPN pseudo-interfaces OPNsense registers (the OpenVPN and WireGuard groups, enc0) are not counted, the same rule SANS-FW-003 applies to zones.

## References

- General network security best practices
Expand Down
54 changes: 54 additions & 0 deletions internal/analysis/zones.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package analysis

import (
"regexp"

common "github.com/EvilBit-Labs/opnDossier/pkg/model"
)

// interfaceTypeGroup is the <type> OPNsense gives the entry it registers under
// <interfaces> for an interface group.
const interfaceTypeGroup = "group"

// loopbackDevice matches a loopback device name. OPNsense lets the operator
// create lo1 and up (Interfaces: Devices: Loopback, loopback_devices in
// loopback.inc) and assign one like any other device, with no virtual flag.
var loopbackDevice = regexp.MustCompile(`^lo\d+$`)

// IsNetworkZone reports whether iface is an enabled interface that carries a
// network of its own, and so can stand for a security zone.
//
// OPNsense writes pseudo-interfaces into <interfaces> on every save
// (plugins_interfaces in plugins.inc): lo0 always (loopback.inc), one entry
// per interface group (pf.inc), the OpenVPN and WireGuard groups while those
// services are enabled, and enc0 while IPsec is. Each is enabled and marked
// virtual, and OPNsense itself leaves virtual entries out wherever it wants
// the real interfaces (legacy_config_get_interfaces(['virtual' => false]) in
// interfaces.inc and console.inc). Counted as zones, lo0 alone made a
// firewall with only a WAN look segmented. A group entry is also left out by
// its type, in case one was written without the virtual flag: it stands for
// its members, which are counted on their own. An assigned loopback device is
// left out too: it reaches no network beyond the firewall itself. VLAN,
// bridge, LAGG, OpenVPN and WireGuard devices assigned as interfaces count.
func IsNetworkZone(iface common.Interface) bool {
return iface.Enabled && !iface.Virtual && iface.Type != interfaceTypeGroup &&
!loopbackDevice.MatchString(iface.PhysicalIf)
}

// CountNetworkZones returns how many of cfg's interfaces are network zones
// (see IsNetworkZone).
func CountNetworkZones(cfg *common.CommonDevice) int {
if cfg == nil {
return 0
}

var n int

for _, iface := range cfg.Interfaces {
if IsNetworkZone(iface) {
n++
}
}

return n
}
57 changes: 57 additions & 0 deletions internal/analysis/zones_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package analysis_test

import (
"testing"

"github.com/EvilBit-Labs/opnDossier/internal/analysis"
common "github.com/EvilBit-Labs/opnDossier/pkg/model"
"github.com/stretchr/testify/assert"
)

func TestIsNetworkZone(t *testing.T) {
t.Parallel()

tests := []struct {
name string
iface common.Interface
want bool
}{
{name: "enabled network", iface: common.Interface{Name: "lan", Enabled: true, Type: "static"}, want: true},
{name: "disabled network", iface: common.Interface{Name: "opt1", Type: "static"}},
{name: "loopback", iface: common.Interface{Name: "lo0", Enabled: true, Type: "none", Virtual: true}},
{name: "group", iface: common.Interface{Name: "mgmt", Enabled: true, Type: "group", Virtual: true}},
{name: "group without virtual flag", iface: common.Interface{Name: "mgmt", Enabled: true, Type: "group"}},
{name: "IPsec VTI", iface: common.Interface{Name: "ipsec1", Enabled: true, Type: "none"}, want: true},
{name: "assigned loopback", iface: common.Interface{Name: "opt1", PhysicalIf: "lo1", Enabled: true}},
{name: "VLAN", iface: common.Interface{Name: "opt2", PhysicalIf: "vtnet0_vlan10", Enabled: true}, want: true},
{name: "bridge", iface: common.Interface{Name: "opt3", PhysicalIf: "bridge0", Enabled: true}, want: true},
{name: "LAGG", iface: common.Interface{Name: "opt4", PhysicalIf: "lagg0", Enabled: true}, want: true},
{name: "OpenVPN", iface: common.Interface{Name: "opt5", PhysicalIf: "ovpns1", Enabled: true}, want: true},
{name: "WireGuard", iface: common.Interface{Name: "opt6", PhysicalIf: "wg0", Enabled: true}, want: true},
{
name: "device named like loopback",
iface: common.Interface{Name: "opt7", PhysicalIf: "lo1x", Enabled: true},
want: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.want, analysis.IsNetworkZone(tt.iface))
})
}
}

func TestCountNetworkZones(t *testing.T) {
t.Parallel()

assert.Zero(t, analysis.CountNetworkZones(nil))
assert.Equal(t, 1, analysis.CountNetworkZones(&common.CommonDevice{
Interfaces: []common.Interface{
{Name: "lo0", Enabled: true, Virtual: true},
{Name: "wan", Enabled: true},
{Name: "lan"},
},
}))
}
23 changes: 6 additions & 17 deletions internal/plugins/firewall/checks_inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strings"

"github.com/EvilBit-Labs/opnDossier/internal/analysis"
"github.com/EvilBit-Labs/opnDossier/internal/compliance"
"github.com/EvilBit-Labs/opnDossier/internal/constants"
common "github.com/EvilBit-Labs/opnDossier/pkg/model"
Expand Down Expand Up @@ -95,19 +96,15 @@ func (fp *Plugin) dhcpInventoryDescription(device *common.CommonDevice) string {
return strings.Join(parts, "; ")
}

// checkActiveInterfaces reports whether enabled interfaces exist.
// checkActiveInterfaces reports whether enabled interfaces exist. Like the
// count below, it leaves out loopback, interface groups and the other
// pseudo-interfaces OPNsense registers (analysis.IsNetworkZone).
func (fp *Plugin) checkActiveInterfaces(device *common.CommonDevice) checkResult {
if device == nil {
return checkResult{Result: false, Known: true}
}

for _, iface := range device.Interfaces {
if iface.Enabled {
return checkResult{Result: true, Known: true}
}
}

return checkResult{Result: false, Known: true}
return checkResult{Result: analysis.CountNetworkZones(device) > 0, Known: true}
}

// interfaceInventoryDescription builds a human-readable description of active interfaces.
Expand All @@ -116,13 +113,5 @@ func (fp *Plugin) interfaceInventoryDescription(device *common.CommonDevice) str
return "No interfaces configured"
}

var enabled int

for _, iface := range device.Interfaces {
if iface.Enabled {
enabled++
}
}

return fmt.Sprintf("%d enabled interface(s)", enabled)
return fmt.Sprintf("%d enabled network interface(s)", analysis.CountNetworkZones(device))
}
2 changes: 1 addition & 1 deletion internal/plugins/firewall/checks_inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestFirewallPlugin_InventoryChecks_Interfaces(t *testing.T) {
require.NotNil(t, f, "expected FIREWALL-063 inventory finding")
assert.Equal(t, "inventory", f.Type)
assert.Equal(t, "info", f.Severity)
assert.Contains(t, f.Description, "2 enabled interface(s)")
assert.Contains(t, f.Description, "2 enabled network interface(s)")
})

t.Run("no finding when all interfaces disabled", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/plugins/firewall/controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func newControlDefinitions() []compliance.Control {
{
ID: "FIREWALL-063",
Title: "Active Interface Summary",
Description: "Reports enabled interfaces and their types",
Description: "Reports how many network interfaces are enabled",
Category: "Configuration Inventory",
Severity: "info",
Rationale: "Interface inventory enables network topology documentation",
Expand Down
43 changes: 43 additions & 0 deletions internal/plugins/firewall/interface_inventory_zones_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package firewall_test

import (
"testing"

"github.com/EvilBit-Labs/opnDossier/internal/plugins/firewall"
common "github.com/EvilBit-Labs/opnDossier/pkg/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// TestFirewallPlugin_InterfaceInventory_SkipsPseudoInterfaces pins that the
// interface inventory counts the interfaces SANS-FW-003 counts. lo0 and the
// group entries OPNsense writes into <interfaces> are not network interfaces.
func TestFirewallPlugin_InterfaceInventory_SkipsPseudoInterfaces(t *testing.T) {
t.Parallel()

lo0 := common.Interface{Name: "lo0", Enabled: true, Type: "none", Virtual: true}
group := common.Interface{Name: "mgmt", Enabled: true, Type: "group", Virtual: true}

t.Run("counts only the network", func(t *testing.T) {
t.Parallel()

device := &common.CommonDevice{Interfaces: []common.Interface{lo0, group, {Name: "wan", Enabled: true}}}

findings, _, err := firewall.NewPlugin().RunChecks(device)
require.NoError(t, err)

f := inventoryFindingByRef(findings, controlInterfaceInventory)
require.NotNil(t, f)
assert.Contains(t, f.Description, "1 enabled network interface(s)")
})

t.Run("no finding with pseudo-interfaces only", func(t *testing.T) {
t.Parallel()

device := &common.CommonDevice{Interfaces: []common.Interface{lo0, group}}

findings, _, err := firewall.NewPlugin().RunChecks(device)
require.NoError(t, err)
assert.Nil(t, inventoryFindingByRef(findings, controlInterfaceInventory))
})
}
15 changes: 5 additions & 10 deletions internal/plugins/sans/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,17 @@ func (sp *Plugin) checkExplicitRules(device *common.CommonDevice) checkResult {
return checkResult{Result: true, Known: true}
}

// checkZoneSeparation verifies the device has at least 2 enabled interfaces
// for network zone separation.
// checkZoneSeparation verifies the device has at least 2 enabled network
// interfaces for network zone separation. Loopback, interface groups and the
// other pseudo-interfaces OPNsense registers are not zones
// (analysis.IsNetworkZone).
func (sp *Plugin) checkZoneSeparation(device *common.CommonDevice) checkResult {
if device == nil {
return checkResult{Result: false, Known: true}
}

enabledCount := 0
for _, iface := range device.Interfaces {
if iface.Enabled {
enabledCount++
}
}

//nolint:mnd // Zone separation requires at minimum 2 interfaces (e.g., WAN + LAN)
return checkResult{Result: enabledCount >= 2, Known: true}
return checkResult{Result: analysis.CountNetworkZones(device) >= 2, Known: true}
}

// checkComprehensiveLogging verifies syslog is enabled with at least
Expand Down
Loading
Loading