Post

The Safety Was On

A control that reported itself as protection while blocking nothing, how we caught it by reading the kernel instead of the dashboard, and why the desktop agent keys on file hashes instead of names.

The Safety Was On

A control reported itself active while it was blocking nothing, and we only caught it by measuring what it did instead of reading what it said about itself. Detection was working. Enforcement wasn’t, and nothing we had built could tell.

It was internal only: our own cluster, 11 of 18 nodes, no customers. Monitor mode was a deliberate choice, because a sensor that blocks at the first suspicious step never records the whole attack. The mistake was that nothing verified the mode. The deny list still held block rows in late August and none three weeks later, and the dashboards said “protected” for somewhere between eight days and a month.

Every fix came after that measurement: counting armed entries from the kernel map, a canary with a negative control, stricter red-team scoring, and blocking split from watching and keyed on file hashes. Then in November we got it wrong a third time.

What the Map Said

Every sixty seconds, every sensor on the cluster logged the same healthy line:

1
deny list snapshot applied: 18 comm + 18 path entries

The sensor’s enforcement half is a BPF LSM program on bprm_check_security that consults a deny list before any binary executes. The malware pipeline feeds the list: a sample is detonated in a sandbox, and a strong enough verdict puts a row on every sensor. The LSM was attached, the maps were populated, the snapshot was fresh, and every dashboard called that “protected.”

In September we stopped asking whether the map was loaded and asked what it said. bpftool reads the kernel’s copy directly:

1
2
3
4
5
$ bpftool map dump name DENY_LIST
key: 6d 61 69 6e 2e 6d 69 70 73 ...   value: 00 00 00 00
key: 57 54 46 00 ...                  value: 00 00 00 00
...
Found 18 elements

The value is the action: 0 is monitor, 1 is block, and the kernel returns -EPERM only on 1. Every value was zero, on all five sensors we sampled, across both CPU architectures and three sites: 36 monitor, 0 block. Our own choices had put it there, but this was the first time anyone had looked.

A populated map reads exactly like an armed one. The snapshot log counted entries. It never said what they were set to.

Why Nothing Could Tell

None of our checks could tell monitor from block. The fileless-exec test exited 0 on a failed exec, so a real deny would have passed too. No unit test asserted EPERM. The red-team runner built for this was suspended (it still is), and it counted “detected but not blocked” as success. The enforcement-lost alert fired only when the hook failed to attach. The sensor reported capable and active separately. The missing third axis was armed.

The first fix made nothing deny. It made the state impossible to misread. Each sensor now recounts armed entries from the map on every apply. The heartbeat carries that count, and an unreported count is NULL, never 0. Posture reads enforced only when the LSM is attached and at least one entry is armed. The snapshot line now says 18 comm (0 armed/block, 18 monitor).

The Other Way to Be Wrong

Three weeks earlier we had found the opposite failure. The sensor keeps two maps, one keyed on the executable path and one on the basename alone, and every entry wrote a key to both. So a rule written as “block /workspace/hello” was enforced as “block anything named hello, anywhere on the host.”

Three block rows had that shape: hello, sample and t1620_memfd, all auto-promoted at 95 to 100 percent confidence from sandbox detonations of benign Arch packages, and loaded on every node. We expired them. Later that same day the automated promoter minted sample again, at block. A revocation with no guard behind it buys hours.

The fix was block narrowly, monitor broadly. The API downgrades an automated block to monitor when the basename is common on real hosts or the evidence is sandbox-only. On the sensor every key still detects, but a basename key only blocks when the entry has no path or its name is a sample hash, which can’t collide with a real binary.

Live Fire

We wanted one real -EPERM from the fleet. The canary arms a single synthetic entry: a sentinel name nothing real uses, scoped to one throwaway namespace, on two nodes (one amd64, one Raspberry Pi 4).

It is gated on a negative control: before arming anything, the same exec must succeed. Without that, a pod that never starts and a working deny look identical. The first live run failed its own control and refused to arm, because the sentinel was a BusyBox copy that printed applet not found and exited 127 with nothing armed. The control did exactly what it was there for.

On the second run the sentinel ran, was refused with EPERM once armed, and ran again after disarm. Both targets reported one armed entry, and all 16 other nodes stayed at zero. The result that convinced us was in a sibling namespace on the same node: the identical file at the identical path ran. A deny that fires everywhere proves the hook works. A deny that fires in exactly one namespace proves the scope works.

That was the first deny we had ever observed from the fleet’s BPF LSM path. The fleet went back to monitor afterwards. This time that was a decision, made on September 30 with the map in front of us. Six days later the automated promoters were allowed to arm their own rows.

What It Actually Stops

Then we held the canary armed and tried to get around it.

1
2
3
4
5
6
$ cp /tmp/kub0-lsm-canary /tmp/kub0-lsm-renamed && /tmp/kub0-lsm-renamed
ran
$ /bin/sh /tmp/kub0-lsm-canary
ran
$ /tmp/kub0-lsm-canary
Permission denied

A renamed copy matches neither map. Handing the script to sh makes the exec /bin/sh, which the critical-binary allowlist exempts. A name-and-path deny list stops one thing: an already-detonated sample running again under its sandbox name. The armed rows on the fleet were exactly that, which made their blast radius about zero and their protective value about the same.

Enforcement has to key on what the file is, not what it’s called.

The Third Time

So the sensors now hash each file as it is about to execute and refuse it when the sha256 is on the deny list: BPF LSM where the kernel has it, fanotify on the few Raspberry Pi nodes where it doesn’t. On October 21 the gate started with 48 block digests.

Rows written by the automated promoter carried a 30-day lifetime. The first of those 48 expired on October 31, and by the evening of November 1 the gate held none, on all 16 sensors that run it. It went on logging content gate: on=true. The armed count we had built for exactly this read 13, because it counted name-keyed rows, and a name is not a digest. That was the real miss: we added a second gate and left the metric counting the first one. For four days neither the log nor that metric showed an empty gate. Only the line counting digest keys did, and nothing alerted on it.

We found it on November 5, from the desktop: its gate is fed from the same list, and its status said loaded, not armed, zero keys. The 48 rows went back in with no expiry, rows that identify a sample by its hash no longer get a lifetime at all, and any change in the digest count now raises an alert of its own. Same lesson, third time: the number you watch has to count the thing that blocks.

The Desktop Shape

The kub0 agent is the desktop port of that gate. It started as per-app network visibility for Linux, with a one-key per-app firewall block, in an Omarchy panel. When a file is about to execute, the kernel holds it on fanotify until the system daemon answers, and the daemon refuses if the sha256 of the file’s bytes is on the deny list. Renaming a sample doesn’t change its hash, and neither does moving it.

One thing to know before installing: the gate checks hashes only once it has a non-empty deny list, your organization’s or a local file (KUB0_EXEC_GATE_DENY_FILE). Until then it is loaded and idle, and it says so. After everything above, we were not going to ship a gate that looks armed when it isn’t.

It inherits the lessons:

  • Armed before the network. It arms at boot from the last list it saw, and says how old that list is.
  • Fail-open, and it says so. A late answer, a full queue or a read error allows the exec, but “wanted to deny and couldn’t” is counted as its own outcome, never folded into “allowed.”
  • No claiming what you aren’t. The desktop heartbeat reports lsm_active: false, because fanotify is not an LSM.

Its limits are in the README under “Honest limitations.” Two worth knowing: the gate holds execs, so a script handed to an interpreter is judged as the interpreter’s exec, and an app block stops an honest app’s traffic, not a hostile one.

The Advisory

0.5.2 shipped with a security advisory against our own earlier versions: GHSA-f4hv-9rmw-x2mh. The Omarchy plugin marketplace’s review of 0.5.1 found four local weaknesses and reported them privately, and we reproduced each one with a test before fixing it. One fits this post a little too well: the install script downloaded the release tarball and the checksum it was verified against from the same release. Against anyone who could replace the release, it was a check that could not fail. The digests are now pinned in the plugin’s own source, and the script refuses anything else.

Trying It

kub0 is listed in the Omarchy plugin marketplace, reviewed and verified by its maintainers. It needs a setup step the marketplace can’t do for you, so add it from a terminal:

1
omarchy plugin add https://github.com/kub0-ai/kub0-agent --enable

The panel offers to install the daemon or build it from source. With no account, nothing leaves the machine that wasn’t already leaving. kub0 accounts aren’t open to the public yet, so the org deny list is for orgs that already have one. The gate’s self-test (sudo bash tests/execgate-selftest.sh) proves it end to end on any root Linux host with no server at all.

The panel, world map, flag set and /proc monitor started as Christopher Dwyer’s omarchy-snitch (MIT). His commits are in the history unchanged.

The lesson we paid for three times: count what the map says, not what it holds. A populated map reads exactly like an armed one.


Previously: Three Bugs Nobody Filed covered running 88 eBPF policies on ARM64. The Autoimmune Response covered the detection engine’s defenses turning on its own pipeline. Which App Opened That Connection? introduced the kub0 agent. This post covers the deny path that reported itself as protection while it was only watching, and what it took to make it fire.

This post is licensed under CC BY 4.0 by the author.