Concepts#

This page explains how Fireman looks at a policy. The rest of the docs assume it.

Rules run in order#

A policy is an ordered list of rules, sorted by order_id (gaps are fine: 10, 20, 30 is the usual style). A packet is handled by the first rule that matches it; later rules never see it. Every question Fireman answers comes down to this first-match rule.

The residual walk#

Fireman walks a policy once, top to bottom, and after each rule it keeps four sets of traffic:

accepted

Everything accepted so far.

denied

Everything denied so far.

effective

What this rule actually decided: its own traffic, minus whatever earlier rules had already taken.

residual

What no rule has matched yet.

The residual starts as all traffic. For rule i with traffic T:

effective(i) = T ∩ residual(i-1)
residual(i)  = residual(i-1) − effective(i)
accepted(i)  = accepted(i-1) ∪ effective(i)    if rule i accepts
denied(i)    = denied(i-1)   ∪ effective(i)    if rule i denies
        flowchart LR
    R0["residual: all traffic"] --> A["rule 10"]
    A -- "effective(10)" --> D1["accepted / denied"]
    A -- "residual(10)" --> B["rule 20"]
    B -- "effective(20)" --> D2["accepted / denied"]
    B -- "residual(20)" --> C["…"]
    C --> Z["implicit deny"]
    

A rule whose effective set is empty never fires. Everything below is read off these sets.

The five anomalies#

The examples use made-up rules in the order they are matched. Every finding names the rule and its related rules: the ones that cause it. Run any of them through fireman classify and you get exactly the finding shown.

Shadowed#

The rule never fires (its effective set is empty), and earlier rules give some of its traffic the other action.

order_id

action

sources

destinations

services

10

accept

any

10.0.0.0/24

tcp 22

20

deny

192.0.2.0/24

10.0.0.0/24

tcp 22

Rule 20 is shadowed by rule 10. Someone wanted to block 192.0.2.0/24, and the block does nothing. This is almost always a bug: the fix is to move the rule up.

Redundant#

Removing the rule changes nothing. There are two ways this happens.

The rule never fires, and the earlier rules that took its traffic gave it the same action:

order_id

action

sources

destinations

services

10

accept

any

10.0.0.0/24

tcp 22

20

accept

192.0.2.0/24

10.0.0.0/24

tcp 22

Rule 20 is redundant, related to rule 10.

Or the rule does fire, but if it were gone, the later rules would give the same traffic the same action:

order_id

action

sources

destinations

services

10

accept

192.0.2.0/24

10.0.0.0/24

tcp 22

20

accept

any

10.0.0.0/24

tcp 22

Rule 10 is redundant, related to rule 20. Only explicit rules count here, never the implicit deny (see below), so a deny rule at the end of a policy is not flagged just because the implicit deny would have dropped the same traffic.

Correlated#

The rule overlaps the effective set of an earlier rule with the other action, so the order of the two decides what the overlap gets.

order_id

action

sources

destinations

services

10

deny

192.0.2.0/24

any

tcp 22

20

accept

any

10.0.0.0/24

tcp 22

Rule 20 is correlated with rule 10: SSH from 192.0.2.0/24 to 10.0.0.0/24 is denied, but swap the rules and it would be accepted. Neither rule contains the other, so it’s worth checking that the order is the one you meant.

Generalization#

Like correlated, but the rule also contains the whole of the earlier rule’s traffic. It is always reported together with correlated.

order_id

action

sources

destinations

services

10

deny

192.0.2.0/24

10.0.0.0/24

tcp 22

20

accept

any

10.0.0.0/24

tcp 22

Rule 20 is a generalization of rule 10. This is the classic “exception first, then the broad rule” pattern and is often exactly what was intended. Fireman reports it so you can confirm it.

Empty#

The rule matches no traffic at all, so it can never fire. It gets this one finding, with no related rules. This happens when a group’s exclude covers its whole include:

order_id

action

sources

destinations

services

10

accept

lab-not-lan

any

tcp 22

Here lab-not-lan includes 10.1.0.0/16 and excludes 10.0.0.0/8, which holds all of it. Fix the group or delete the rule.

The implicit deny#

Most firewalls drop anything no rule matches. Fireman does the same by adding a final deny-all rule after the last one, so every packet gets a decision. It is never classified, never shows up as a related rule, and never makes a rule redundant. Reports call it implicit deny.

If your firewall has no such default, pass --no-implicit-deny. Traffic no rule matches is then left undecided, and place and covered show it as undecided.

Traffic as BDDs#

Each rule’s traffic is a set of packets, and a packet here is 88 bits: source address (32), destination address (32), port (16) and protocol (8). Fireman stores these sets as binary decision diagrams (BDDs, through the oxidd library), which keep large sets small and make union, intersection, difference and the “is it empty?” test exact and fast. That is why groups with excludes, negated fields, port ranges and overlapping prefixes need no special cases. ICMP keeps its type and code in the port bits; other protocols without ports leave them free. For very large estates the --bdd-nodes option sets the node ceiling.

Scopes and name lookup#

Objects live in a scope: the global scope, or one firewall. A firewall’s own objects override global objects with the same name, as long as the kind (address or service) stays the same.

Lookup is lexical, like variables in a program:

  • In a firewall’s rules and groups, a name means the firewall’s own object if it has one, else the global one.

  • A global group only ever sees global objects. A firewall override never changes what a global group matches.

The sample estate shows both. The global group dmz-hosts is the DMZ minus web-servers. Firewall edge overrides web-servers with two of the three servers:

addresses:
  - name: web-servers
    values: [192.168.10.10, 192.168.10.11, 192.168.10.12]
groups:
  - name: dmz-hosts
    kind: address
    include: [dmz]
    exclude: [web-servers]
firewalls:
  - name: edge
    addresses:
      - name: web-servers
        values: [192.168.10.10, 192.168.10.11]

In edge’s rules, web-servers means the two servers. dmz-hosts still excludes all three, even when an edge rule uses it, because the group is global and resolves its names globally.

Workspaces and the findings cache#

fireman load validates your files and stores the result as a named workspace (default unless you pass --name) in .fireman/fireman.db, under the directory you run it from. The other commands take no input files: they read the workspace. Loading the same name again replaces it. If a loaded file changes, disappears or can’t be read afterwards, commands print a warning and carry on with the stored copy until you load again.

fireman classify also keeps a findings cache in the same database. Each firewall gets a digest, a hash of the Fireman version, the implicit-deny setting, the global objects and that firewall. A firewall whose digest is already cached is not recomputed; the others are compiled one at a time, each in its own BDD manager, so memory stays at one firewall’s worth. Because the digest covers every input, the cache is never stale. --no-cache recomputes everything, and fireman cache clear deletes the database, workspaces included.