Skip to content
Merged
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
16 changes: 16 additions & 0 deletions docs/fleet.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ connections; the walk-through leaves egress open and does not apply them.
The proposal is written beside the policy, never into it. Note the second line:
both groups are IPv4 only, so the narrowed term no longer admits IPv6.

A narrowing that would cut traffic the flows show is marked `CONTRADICTED` by
`diff --flows`, with the flows it would cut, and `-o sh` writes it as a comment
no grep can run.

Before a policy is deployed, the question is what it would break now: check
it against the latest traffic, not the window it was tightened on.

```sh
firru tighten --policy policies/pol/dc1.yml --defs def --flows-file flows.jsonl --check --since -30min
```

It lists, per source, the flows the policy would refuse: to a port no term
covers, or from a source a term leaves out. Each is a decision for the
reviewer: a term or a source to add, or a connection the policy is right to
refuse.

## 7. Apply what you accept

```sh
Expand Down
2 changes: 0 additions & 2 deletions examples/fleet-zones/expected/transcript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ Host: ws3 IPs: ['10.20.3.23', '2001:db8:20:3::17']
egress: 160 flows across 4 service buckets
Written: policies/tightened/db1.yml (2 changed, 1 log-drop candidate)
Written: policies/tightened/dc1.yml (4 changed, 19 log-drop candidates)
Written: policies/tightened/dc1.blocked.yml (1 would-be-blocked flows)
Written: policies/tightened/files1.yml (1 changed, 9 log-drop candidates)
Written: policies/tightened/files1.blocked.yml (1 would-be-blocked flows)
Written: policies/tightened/jump1.yml (0 changed, 2 log-drop candidates)
Written: policies/tightened/mail1.yml (1 changed, 5 log-drop candidates)
Written: policies/tightened/ns1.yml (1 changed, 1 log-drop candidate)
Expand Down
23 changes: 21 additions & 2 deletions examples/lspr24/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# make ladder the block-early counterfactual against red-team traffic
# make enforced-diff the synthesized policy against what the network did
# make hourly d2 an hour at a time, for the hosts in reports/hourly/
# make check-live the night-trained policies against d2's first hour, for
# the same hosts, into reports/check/
#
# Committed, because regenerating them needs the 7 GB download and the point
# is that a reader who has not downloaded anything can inspect the output:
Expand Down Expand Up @@ -121,8 +123,8 @@ data/flows/.complete: $(LSPR24)
python lspr24_to_flows.py $(LSPR24) --store data/flows
touch $@

# Narrow each term's sources to what the learn window shows, and report what
# that would have blocked and which rules never matched. The window is
# Narrow each term's sources to what the learn window shows, and mark the
# rules that never matched as log-drop candidates. The window is
# attack-free, so a source set derived from it is not shaped by the intrusion.
# No --flows-file: with a window and none named, tighten reads firru.toml's
# store.
Expand Down Expand Up @@ -184,6 +186,23 @@ hourly: flows
python3 hourly.py --old policies/r1-synthesized --new policies/r2-tightened \
--window d2 --defs def/ --out reports/hourly/ $(HOURLY_HOSTS)

# The same check for the policy as a whole: what each host's policy, trained
# on the night window, would refuse of the first hour of live traffic. That
# is `tighten --check`, the question to ask before a deploy, and its answer
# includes ports no term covers, which a diff of two policies cannot show.
LIVE_SINCE ?= d2 08:00
LIVE_UNTIL ?= d2 09:00
check-live: flows
@mkdir -p reports/check
@for h in $(HOURLY_HOSTS); do \
{ echo "# policies/r2-tightened/$$h.yml, trained on the $(LEARN) window,"; \
echo "# checked against $(LIVE_SINCE) to $(LIVE_UNTIL) (make check-live)"; \
firru tighten --policy policies/r2-tightened/$$h.yml --defs def/ --check \
--since "$(LIVE_SINCE)" --until "$(LIVE_UNTIL)" 2>/dev/null; \
} > reports/check/$$h.txt; \
echo "reports/check/$$h.txt"; \
done


# Everything `make all` writes, so that `make clean all` followed by
# `git status` shows nothing: the committed outputs are exactly what the two
Expand Down
43 changes: 41 additions & 2 deletions examples/lspr24/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ firru merge-zones --hosts 'policies/<variant>/*.yml' --defs def/ --outdir zones/
| `loot-ossec/` | the measured loot, as the archive has it |
| `loot-assumed/` | the same with `assumptions.yml` applied: what the policies are built from |
| `policies/r1-synthesized/` | from the sockets: 460 service terms over 59 hosts |
| `policies/r2-tightened/` | sources narrowed against the night window: 178 terms, each with `# was:`, and beside them `*.blocked.yml` (27 hosts: flows the narrowing would deny); a term nothing matched says `log-drop candidate` |
| `policies/r2-tightened/` | sources narrowed against the night window: 178 terms, each with `# was:`; a term nothing matched says `log-drop candidate`. What the narrowing would deny is `firru diff` with `--flows` |
| `policies/r3-apparent/` | INFERRED from traffic: the policy that appears to have been running |
| `policies/r4-block-early/` | r2 with every service the night window never saw removed: 269 of 460 terms, on 51 hosts |
| `reports/` | precomputed reports, so the results read without the dataset: `hourly/`, one host's d2 an hour at a time (`make hourly`) |
| `reports/` | precomputed reports, so the results read without the dataset: `hourly/`, one host's d2 an hour at a time (`make hourly`); `check/`, the night-trained policy against d2's first hour (`make check-live`) |
| `zones/<variant>/` | each variant merged per network, the form a firewall takes |

Every policy and zone file compiles with Aerleon against `def/`. Files are
Expand Down Expand Up @@ -225,6 +225,45 @@ out a narrowing it contradicts instead of emitting it. On www the cut is the
point only for the red-team share; narrowing a public web server to the
clients of one night closes it to its users.

### The check before a deploy

`make check-live` asks the question to ask before deploying: what would each
host's policy, trained on the night window, refuse of the first live hour,
08:00-09:00 on d2? It is `firru tighten --check`, which reads the whole policy
rather than a change to it, so it also reports traffic to a port no term
covers. The hourly diffs above cannot show that: they compare two policies,
and a port neither has a term for is in neither. The results are in
[`reports/check/`](reports/check/):

| host | refused, 08:00-09:00 | mostly |
| --- | --- | --- |
| dc1 (Windows DC) | 1,216 flows, 21 sources | dynamic RPC from the other DC and 14 domain hosts, the organisers' Kerberos and LDAP from the DMZ, and `tcp/134`, the listener nothing explains |
| k8s-worker01 | 274 flows, 9 sources | the cluster's own traffic: 10249 and IP-in-IP between the nodes, and high ports from the control plane |
| www | 146 flows, 2 sources | HTTP and HTTPS from the internet: its users |
| salt-master | 46 flows, 2 sources | the organisers on 4505 and 9999 |
| gas-hmi (OT) | 41 flows, 2 sources | dynamic RPC from an unnamed host in its subnet and from salt-master |

Each line is a decision for the reviewer before the policy is deployed: a
term or a source to add, or a connection the policy is right to refuse.

dc1's dynamic RPC is the first kind. A domain member reaches a DC's endpoint
mapper and is then handed a port from the dynamic range, which no snapshot of
listening sockets holds, so the loot gives synthesis nothing to write a term
from. A site states it as a rule instead (`dynamic_rules` in its
`heuristics.py`, `firru.src_heuristics`): the DC's dynamic range, from the
domain's members. This example does not, because the capture does not say
who the members are. The beg DCs' Kerberos and LDAP clients are the
workstations, mail and the other DC, but also owncloud, which uses both, and
lemonldapng and k8s-worker02, which bind over LDAP alone. Which of those are
joined to the domain is a site's to state, and the check shows what leaving it
unstated costs.

owncloud's LDAP to dc1 is a source to add, and the plainest case
of what a training window is. owncloud asks dc1 over LDAP 664 times on d1 and
176 times on d2, and dc1 answers 659 of the 849. It never asks at night, so
the policy trained on the night has no owncloud in it, and the first live
hour refuses a client that is there every working day.

### Block-early

`make ladder` synthesizes from the loot, tightens on the attack-free `night`
Expand Down
3 changes: 0 additions & 3 deletions examples/lspr24/block_early.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ def main():
dropped_by_host = collections.Counter()

for path in sorted(pathlib.Path(args.policy).glob("*.yml")):
# tighten writes its reports beside the policies; they are R2's.
if path.name.endswith((".blocked.yml", ".dead.yml", ".groups.yml")):
continue
with open(path) as fh:
doc = _rt.load(fh)
tok = path.stem
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading