Runtime Shields with eBPF: Blocking the Exploit While the Patch Lands
Between a CVE going public and your server running the patch there are days, sometimes weeks, when the service is exposed and you cannot restart it. A runtime shield does not fix the code: it closes the specific path that reaches the flaw, and it is a few dozen lines of eBPF.
What a Runtime Shield Is (and Isn't)
A shield is a program hooked into the kernel that decides, operation by operation, whether to let through or cut a behavior you know is dangerous. It does not modify your application and it does not replace the patch: it covers the exploit path while the fix is tested and rolled out. When the patch lands, the shield is removed.
This week's reference case: on November 23, 2026, OpenAI and Cisco introduced Shirudo, an open source eBPF-based runtime that loads signed shields into the kernel. According to the vendors, a shield generated with Codex blocked an attempt to exploit Java4Shell against a production Elasticsearch without restarting the service. Those are controlled vendor tests, not an independent benchmark.
Shirudo's Four Controls, as a Reference
- Live protection: blocks paths without a restart, with an observation mode before enforcement.
- Machine-speed defense: agents investigate and write shields; the human team decides what ships and signs it.
- Trusted deployment: shields are signed and verified before loading, and the eBPF verifier validates the program.
- Hardware verification: a TPM keeps an auditable record of shields loaded and removed.
Now the part the headlines skip: Shirudo is pre-release, with no stable versions. It needs a kernel with the bpf-next signed loader ABI plus its own patches, and TPM 2.0 is mandatory. It only accepts BPF loaded by signed loaders, so Falco, Cilium or bpftrace cannot load their programs on a target as-is. That is why it is not today's recipe: it is the reference case. This tutorial uses standard eBPF LSM, which runs on a regular kernel.
Read also
Check Whether Your Kernel Allows It
Before writing a single line, check whether the kernel supports what you need. Two things are required: a kernel built with BPF LSM, and the bpf module inside the active LSM list.
cat /sys/kernel/security/lsm
If the output does not include bpf, the program will not attach, however well written it is. To confirm the build option, check the config of the running kernel. And watch for a classic trap: if you boot with the lsm= parameter, you must name every LSM you want active, because that parameter overrides the compiled order. A compiled-in LSM missing from the list simply does not run. Capability checks always come first and IMA/EVM at the end; the first denial stops the walk and the rest never see the call.
Check the production kernel, not the one on your laptop:
uname -r && bpftool version
Your First Shield: Close the Path, Not the App
BPF_PROG_TYPE_LSM programs attach to the same hooks SELinux or AppArmor use. On a hook that returns an integer, the program returns 0 to allow or a negative errno to deny. It receives ret as its last argument, which is what the previous program returned on that hook or 0 if it is the first; by convention, if ret is not 0 you return it unchanged rather than override someone else's denial.
A minimal shield for the typical case — a web service that should never spawn a shell — attaches to lsm/bprm_check_security and returns -EPERM when the binary path matches the pattern you are after. The exec is cut before the process exists. The shield touches neither the application nor the running service.
The BPF C Program
// SPDX-License-Identifier: GPL-2.0
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
char LICENSE[] SEC("license") = "GPL";
SEC("lsm/bprm_check_security")
int BPF_PROG(block_shell, struct linux_binprm *bprm, int ret)
{ if (ret) return ret; /* real path comparison goes here */ return 0; }
The section name is the hook, without the security_ prefix. The license must be GPL-compatible or the kernel rejects the program. The comparison is not "sh" on its own: it is the full path suffix you want closed, or you take down half the box. And bprm->filename is a kernel pointer, so it is read with bpf_probe_read_kernel_str; check in your kernel's helper list that this helper is allowed for LSM programs. If you cannot confirm it, treat the snippet as a sketch, not buildable code.
To load it, the shortest route is generating the skeleton with bpftool gen skeleton and attaching with bpf_program__attach_lsm. At the syscall level the program loads with attach type BPF_LSM_MAC and the hook's target_btf_id, and attaches with BPF_LINK_CREATE. Detaching means destroying the bpf_link. Confirm what is actually loaded with bpftool prog list and bpftool link list: if it is not there, it is not protecting anything.
Observation Mode: Count Before You Block
Nobody blocks in production without counting first. The first version of the shield should increment a counter in a BPF map and always return 0. Leave it for 24 or 48 hours and look at which processes would have died.
bpftool map dump name counter
If legitimate processes show up — cron, a backup, a deploy — the pattern is wrong and the shield would have taken the service down. Only when the match list is exactly what you expect do you enable enforcement, and you do it through a flag in an array map so you can disable it without detaching anything.
Measure the cost too. The hook runs on hot paths such as file_open or socket_connect; do not promise overhead numbers you have not measured under real load. Keep the program short: no long loops, no unnecessary reads.
The Limits No Shield Covers
A hook can only reject what passes through it. Some operations never call an LSM hook — Shirudo's documentation uses mount_setattr(2) as the example — and the shield is blind there. With standard BPF LSM, root can also detach the program, and a kernel exploit or a module signed with a key the kernel trusts walks past every check made in that kernel. Shirudo solves it with signed loaders and TPM-held keys, and even then its threat model says explicitly where it stops.
Nor does it cover your application logic: an SSRF, an IDOR or a well-formed SQL injection needs to execute nothing unusual. That is what other layers are for, such as basic Linux hardening, a UFW firewall or blocking AI agents at the HTTP layer. A shield is one layer, not the wall.
Checklist for the Day It Happens
- Confirm the CVE and the exact exploit path. Without the path identified, there is no shield to write.
- Verify kernel, config and LSM list on the real server, not on a test box.
- Inventory the legitimate processes that cross the hook.
- Ship in observation mode and count through at least one full cron and deploy cycle.
- Enable enforcement behind a reversible flag and document how to turn it off in one command.
- Keep the patch on the calendar. The shield is not the destination.
The line that sums it up is in Shirudo's own FAQ: a shield covers the time until the machine runs a kernel with the fix. It buys you days, not a free pass on patching. And if you do have to do this under pressure, have the procedure written beforehand: our guide to upgrading PHP without downtime follows the same principle, change live and stay able to roll back.

