Tamper counters#
Each point at which one of shirudo’s guards refuses a caller has a
counter. The guard adds one to it when it refuses. One point counts
what it lets through: SealSignal, a signal to a shirudo task from a
task without authority, which no hook refuses. The counters live in
the array map shirudo_tamper, which init creates, freezes and
pins at /run/shirudo/bpffs/tamper at every boot, so they count this
boot’s refusals. No task resets them from userspace; only the hooks add
to them. Threat T10 of the Threat model explains their purpose.
Refusals of changes to the running kernel count apart, as
Integrity counters.
Counters#
The name and the meaning are what shirudo status prints. The hooks
are the section names of the BPF programs in bpf/ that move the
counter.
Counter |
Meaning |
Hooks and condition |
Errno |
|---|---|---|---|
|
program load that is not a signed loader |
|
|
|
loader-type program load without a signature |
|
|
|
program load whose signature the kernel did not verify |
|
|
|
program signed against a keyring of the wrong kind |
|
|
|
program signed against a keyring that is not the anchor |
|
|
|
map creation by another executable |
|
|
|
map update or freeze by another executable |
|
|
|
writable map descriptor for another executable |
|
|
|
test run of a program by another executable |
|
|
|
link or raw tracepoint attach by another executable |
|
|
|
pin of a BPF object by another executable |
|
|
|
detach, update, delete or unclassified bpf() command |
|
|
|
executable change through PR_SET_MM |
|
|
|
write, unlink, revoke or invalidate on the anchor keyring |
|
|
|
unlink of a pin in the private bpffs |
|
|
|
rename of a pin in the private bpffs |
|
|
|
xattr change on a pin in the private bpffs |
|
|
|
unmount of the private bpffs |
|
|
|
unmount of a mount above the private bpffs |
|
|
|
move, mount over or remount of the private bpffs |
|
|
|
write open of a sealed file |
|
|
|
unlink of a sealed file or removal of a sealed directory |
|
|
|
rename of or over a sealed file, or of or over a directory above the state root |
|
|
|
truncate, chmod, chown, utimes or chattr of a sealed file |
|
|
|
xattr or ACL change on a sealed file |
|
|
|
seal or policy label changed by another executable |
|
|
|
ptrace of a shirudo task |
|
|
|
perf event bound to a shirudo task |
|
|
|
exec of shirudo by a traced task |
|
|
|
entry into a sealed directory, or a sealed inode linked |
|
|
|
program attached to a perf event by another executable |
|
|
|
directory or link made in the private bpffs by another executable |
|
|
|
overlay copy-up of a sealed inode |
|
|
|
kexec image or initramfs load |
|
|
|
extension of shirudo’s TPM NV index by another executable |
|
|
|
protected TPM mutation by an unauthorized task |
|
|
|
pin, map, link or XDP program opened by another executable |
|
|
|
signal to a shirudo task (let through) |
|
none |
|
core dump of a shirudo task, which acts without authority |
Any hook that asks for runtime authority, the first time a marked task that is dumping core asks: the task loses its authority for good, and the hook refuses the operation and moves its own counter |
the hook’s |
|
uprobe in a shirudo task, which acts without authority |
Any hook that asks for runtime authority, the first time a marked task whose memory a uprobe reached asks: the task loses its authority for good, and the hook refuses the operation and moves its own counter |
the hook’s |
|
XFS attribute change by file handle, which passes no xattr hook |
|
|
|
exec of the runtime binary by a task that shares its file system context |
|
|
|
resource limit of a shirudo task changed by another task |
|
|
Unless the row says every caller, a task with runtime authority is not refused and moves nothing.
Note
Every ptrace mode against a shirudo task is refused, but only an
attach-mode access is counted. A read-mode probe, such as journald
reading /proc/<pid>/exe for a log line or ps reading
/proc/<pid>/stat, or a read of environ, maps or the
fd links, is refused silently: the caller gets EACCES and may
log it, but SealPtrace and the keepalive do not move. Honest
system services make read-mode checks against every process that
logs, so counting them would make a healthy node read as tampered.
Refusals without a counter#
A zero counter does not mean nobody tried. These refusals move no counter:
Refusal |
Where |
|---|---|
The kernel’s own signature errors at |
The kernel, before |
rmdir in the private bpffs |
|
Inode and mount operations on the |
The |
Unmount, move, mount over and remount of the runtime and config image mounts |
|
Device-mapper control ioctls |
|
A dm-verity mapping that is already recorded, or whose root cannot be read |
|
Exec of a runtime file under a seccomp filter, and an exec for which task storage cannot be allocated |
|
A read-mode ptrace access check against a shirudo task, such as
a read of |
|
A fork that cannot copy a task mark |
|
A new inode under a marked directory that cannot receive the label |
|
Executable mappings of an authorized task that are writable or not from the runtime image |
|
Refusals by another LSM ordered before |
The kernel calls no BPF program for an operation another LSM already refused |
shirudo’s own refusals, such as |
Userspace |
Reading the counters#
Read the counters with shirudo status started from the runtime
image, the way the drop-in that shirudo-gen-runtime --unit-output
generates starts init. A binary outside the runtime image cannot
open the counter map, and its attempt moves ObjGet.
shirudo status prints the section Tamper attempts (this
boot): with one line per counter that is not zero: its name, its
count and its meaning. It prints none when every counter is zero,
none recorded before init before init has pinned the map, and
unavailable: with the error when the map cannot be read.
shirudo status --json carries every counter under
tamper_attempts, with the sum in total and each counter by name
in counters, so a collector’s keys stay the same from one record to
the next. The value is null before init has pinned the map.
The keepalive, shirudo status --otel, carries every counter in the
tamper list of its body, zeros included and in the order of this
page, and the TPM quotes the body. The list is null, and bit 3 of
the body’s flags set, when the counters cannot be read.
What a non-zero counter means#
A counter that moved means that a guard refused an operation this boot.
The refusal is what moved it: the operation did not happen. The one
exception is SealSignal, which counts a signal the seal delivered:
the task it went to may have been stopped, and the next upatch load or unload
and shirudo status find what a stopped load left. SealCoreDump
counts a shirudo task that dumped core, after a crash or after an exec
that failed past its point of no return, which root can bring about
with a small stack limit; the dump did not get the task’s authority.
SealUprobe counts a shirudo task whose memory a uprobe reached, one
that root set through tracefs or perf on the runtime binary or on a
library it maps.
A non-zero counter does not mean:
That the target is compromised. A refused attempt is an attempt.
That root made the attempt.
lsm/bpfruns before the kernel checks capabilities, so an unprivileged process moves the counters ofbpf()commands.That a foreign program made it.
BpfCommand,Kexec,BpffsUmount,BpffsUmountAbove,BpffsMount,SealCopyUpand a malformed TPM command count refusals of shirudo’s own tasks too, and a shirudo binary outside the runtime image movesObjGet.That the operation was the one the meaning names.
PerfAttachcounts the ioctl number on any file, whatever the device.
A counter does not change the verdict of shirudo status. It is the
target’s own account, like the rest of the status, and it travels
unauthenticated to the collector. Only shirudo attest verify is
evidence. To act on a counter, see
Respond to a tampered target.