Skip to content

eBPF-based security platform

docs: compare shirudo with live patch services, WAFs and host filtering

Daniel Borkmanneb0b230e4b59
diff --git a/Documentation/concepts/comparisons.rst b/Documentation/concepts/comparisons.rst
index 1d02cd33..f87bc616 100644
--- a/Documentation/concepts/comparisons.rst
+++ b/Documentation/concepts/comparisons.rst
@@ -9,7 +9,12 @@ How shirudo compares
====================
shirudo combines mechanisms that also exist on their own: signed BPF,
-the BPF LSM, kernel keyrings, dm-verity and TPM measurement. Each of the
+the BPF LSM, kernel keyrings, dm-verity and TPM measurement. A upatch
+can target the kernel or user space. In user space, a BPF upatch
+attaches to a program's functions through uprobes, and a upatch for a
+language runtime works inside it, as a Java agent upatch does in the
+JVMs that load it (:doc:`/upatches/write/attach-kinds`,
+:doc:`/upatches/write/java-agents`). Each of the
approaches below solves part of the problem shirudo addresses: change
what a running kernel does without a reboot, keep control of which code
runs, and be able to prove it later. For each, this page says what it
@@ -27,26 +32,45 @@ structures through shadow variables. A live patch is a kernel module,
built from a source patch with kpatch-build or with ``klp-build`` from
the kernel tree's ``scripts/livepatch/``.
+Vendors build live patches for the kernels they ship or support, among
+them Canonical Livepatch, Oracle Ksplice and TuxCare KernelCare. A host
+runs the vendor's client, which fetches the patches and loads them as
+kernel modules. Any other kernel needs each patch built against each of
+its builds, by a pipeline of one's own.
+
A live patch can replace any function that ftrace can trace, so it can
carry the fix itself. It is native kernel code: no verifier checks it, it
is built for one kernel build, and who may load it is decided by module
-signature enforcement and lockdown. The livepatch subsystem does not
-measure the patches it applies into the TPM, though IMA can measure
-module loads.
-
-shirudo complements live patching. A upatch cannot replace a function
-body. It can refuse a call before the function runs, at an LSM hook, a
-``security_*`` function, a system call entry, a function marked for
-error injection or a function the kernel build tagged because it returns
-errors, and it can observe or filter
-(:doc:`/upatches/write/attach-kinds`). In exchange, the BPF verifier checks
-every program, CO-RE lets one artifact load on more than one kernel
-build, and each load and unload is measured. A target can run both
-when every livepatch module is signed with a key the kernel trusts,
-since shirudo refuses unsigned modules
-(:doc:`/operate/plan/interoperability`). Used together, a upatch blocks
-a vulnerable path until a live patch or a fixed kernel is in place, and
-a signed unload directive removes it then.
+signature enforcement and lockdown. Where neither is enforced, root can
+load any module and change the running kernel at will. The livepatch
+subsystem does not measure the patches it applies into the TPM, though
+IMA can measure module loads.
+
+shirudo complements live patching. A BPF upatch cannot replace a
+function body. It can refuse a call before the function runs, at an LSM
+hook, a ``security_*`` function, a system call entry, a function marked
+for error injection or a function the kernel build tagged because it
+returns errors, and it can observe or filter
+(:doc:`/upatches/write/attach-kinds`). In exchange, the BPF verifier
+checks every program, CO-RE lets one artifact load on more than one
+kernel build, and each load and unload is measured. upatches also reach
+user space, through ``uprobe`` programs, LSM programs that confine a
+process whatever its runtime, and Java agent upatches.
+
+A target can run both when every livepatch module is signed with a key
+the kernel trusts, since shirudo refuses unsigned modules
+(:doc:`/operate/plan/interoperability`). Such a module runs outside
+shirudo's checks, and its register does not record it. Used together, a
+upatch blocks a vulnerable path until a live patch or a fixed kernel is
+in place, and a signed unload directive removes it then. Kernel live
+patches are planned as a upatch payload too, signed, delivered and
+measured as BPF and Java agent upatches are, tracked in `issue 83
+<https://github.com/shirudo-dev/shirudo/issues/83>`__.
+
+Both need a prepared kernel. A live patch loads only on the build it was
+made for. shirudo needs one boot into a kernel with the signed-loader ABI
+and the carried patches (:doc:`/internals/kernel-patches`), from a
+measured UKI. After that boot, upatches load and unload without another.
IMA and IPE
-----------
@@ -95,12 +119,19 @@ may detach them. An engine's protection of itself depends on what its
own policy covers, and its agent, which takes policy changes at runtime,
is part of what a host must trust.
+Without shirudo, a BPF LSM program loaded on a stock kernel can refuse
+the same call a upatch refuses. Root, and an attacker who gains root,
+can detach it or load a program that undoes it, and no record a remote
+verifier can trust shows either.
+
shirudo is a BPF LSM policy too, with a fixed purpose: it governs
``bpf()`` itself, so that only signed loaders install BPF, and it guards
its own links, maps and state. It takes no policy at runtime. Every
change is a signed artifact that a one-shot command loads and the
register records. An engine that loads its own programs cannot run on
-an enforcing target. Its hooks and its logic can be written as upatches
+an enforcing target, and neither can a detection tool such as Falco
+with its eBPF driver (:doc:`/operate/plan/interoperability`). An
+engine's hooks and its logic can be written as upatches
with the ``lsm``, ``fentry`` or ``kprobe`` attach kinds, and a policy
change then becomes a signed build.
@@ -162,7 +193,10 @@ has any, live as long as the process holds them.
The daemon and its channel are part of the host's trusted computing
base and of its attack surface. Root can stop the process. What it
-reports is its own account unless hardware vouches for it.
+reports is its own account unless hardware vouches for it. When the
+kernel parts are native code that reads content the service sends, one
+faulty update reaches every host at once, and a fault in kernel code
+can crash each of them.
For delivering and enforcing BPF on a target, shirudo takes this
model's place. The target runs no daemon and listens on no socket.
@@ -177,6 +211,47 @@ infrastructure that already runs the fleet. Its own limits are in
:doc:`/security/threat-model`: root can run every command of the
runtime binary (R2), and telemetry has no proof of origin (R17).
+A BPF upatch passes the BPF verifier before it loads. The verifier
+refuses a program that could reach memory out of bounds or never
+return, so such a fault stops the load, not the kernel. It does not
+judge what a program decides (:doc:`/concepts/background/bpf`), and no
+verifier checks a Java agent upatch. A upatch that refuses the wrong
+calls refuses them on every target that loads it. Tree operations can
+select their targets by node label, so a rollout can go in stages
+(:doc:`/operate/run/deliver-packages`).
+
+Web application firewalls and intrusion prevention
+--------------------------------------------------
+
+A web application firewall or an intrusion prevention system filters
+traffic before it reaches the application. Its rules match the requests
+or packets of known exploits, and vendors publish new rules, often
+called virtual patches, when an advisory comes out. Runtime application
+self-protection works inside the process instead, usually as an agent
+that the runtime loads.
+
+A filter on the network path sees only what it can parse. It reads
+encrypted traffic only where TLS ends at it, and an exploit that
+encodes its payload another way, or arrives by another path, passes. A
+rule stays until someone removes it, after the fix as before.
+
+shirudo complements these. A upatch acts where the vulnerable code
+runs. At a kernel hook it refuses the operation an exploit needs,
+whatever bytes carried the exploit. A Java agent upatch works inside
+the JVM, as runtime self-protection does, signed and measured like
+every upatch. A upatch also stays until someone removes it. There is no
+expiry, so a signed unload directive or a tree ``delete`` takes it back
+once the targets run the fix (R16 in :doc:`/security/threat-model`).
+
+Network filtering ships as upatches too. BPF networking programs filter
+a host's traffic at layers 2 to 4 (:doc:`/upatches/write/attach-kinds`).
+A upatch can drop a flood in the driver, before the network stack
+spends work on it, or redirect packets to another interface, such as one
+in front of a WAF. Networking upatches complement DDoS scrubbing
+upstream, and firewalls and network policies on switches or DPUs. Each
+of these is one layer of defense, and a upatch adds one on the host
+itself (:ref:`defense-in-depth`).
+
Summary
-------
@@ -206,6 +281,10 @@ Summary
* - Agents with daemons
- Policy and code over a management channel
- Takes the agent's place for BPF delivery, without a daemon
+ * - Web application firewalls and intrusion prevention
+ - Requests and packets of known exploits, on the network path
+ - Complements: acts where the vulnerable code runs, and filters
+ traffic on the host
Related
-------
diff --git a/Documentation/index.rst b/Documentation/index.rst
index 26649ae2..00b89bb0 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -78,6 +78,8 @@ Properties
The :doc:`security/threat-model` states where each of these mechanisms
stops.
+.. _defense-in-depth:
+
Defense in depth
----------------