Skip to content

Report firewall reality, and implement the managed-SHA flag apply already calls - #16

Merged
lr00rl merged 1 commit into
mainfrom
feat/guard-reality
Aug 19, 2026
Merged

Report firewall reality, and implement the managed-SHA flag apply already calls#16
lr00rl merged 1 commit into
mainfrom
feat/guard-reality

Conversation

@lr00rl

@lr00rl lr00rl commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Closes the agent-side gap behind NetGuard: a /proc-based collector (listeners with owning process, interfaces, canonical managed-table hash, foreign tables, nft version) posted every poll to /api/agent/guard-reality, plus the --guard-managed-sha one-shot the server's apply script has always invoked but the agent never implemented. Canonicalization ignores nft handle renumbering so drift means a real change. Agent version 0.3.4. Full suite green.

…lled

Two halves of NetGuard have been finished on the server for months and
unreachable from a node the whole time.

The reality panel showed 35 machines as "never reported" because nothing
ever posted a snapshot: the agent had no collector. And the apply script
the server generates calls `lattice-agent --guard-managed-sha` to record
what it installed — a flag this binary did not implement, so every
NetGuard apply came back without the canonical hash the server needs and
the drift anchor could never be anything but unknown.

The collector reads /proc rather than shelling out to ss or lsof, which
are not installed on a minimal box: listening TCP and UDP sockets with
their owning process where /proc/<pid>/fd is readable, interfaces with
their addresses, the live managed table's canonical hash, the foreign
nftables tables that are in force but not ours, and the nft version. All
of it is read-only and best-effort — a host without nft or without root
still reports listeners and interfaces, because a partial snapshot is
what distinguishes "I can see this machine but not its ruleset" from a
machine that is gone.

The canonical hash strips handle numbers, trailing whitespace and blank
lines before hashing, and keeps rule order, which is what makes drift
mean anything: nft reassigns handles on every reload, so hashing them
raw would report drift on a table nobody touched. --guard-managed-sha
and the periodic report compute it with the same function, so the value
recorded at apply time is comparable with the value observed later by
construction.

Tested: address decoding (little-endian per word, v4-mapped v6, garbage
rejected), LISTEN-only filtering for TCP versus every bound UDP socket, a
missing /proc file reading as no sockets, handle-insensitive but
rule-sensitive canonicalization, and the exact wire shape the server's
handler decodes. Full agent suite green.
Not-tested: against a live nftables ruleset (this host has no nft; the
release verification on a fleet node covers it).
@lr00rl
lr00rl merged commit 5c5c451 into main Aug 19, 2026
1 check passed
@lr00rl
lr00rl deleted the feat/guard-reality branch August 19, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant