-
Notifications
You must be signed in to change notification settings - Fork 0
Kernel Hook Points
KB's eBPF instrumentation layer (kb-core/ebpf/) currently implements six hook points, one per behavioral dimension (see Zone Model And Scoring). Events are emitted into a shared ring buffer for zero-copy delivery to userspace (kbd_sensor).
| Hook | Type | Dimension | Weight | Source file |
|---|---|---|---|---|
| Process lifecycle (fork/exec/exit) | tracepoint:sched | PROCESS | 20% | kb_process.bpf.c |
| Syscall entry | tracepoint:raw_syscalls:sys_enter | SYSCALL | 25% | kb_syscall.bpf.c |
| Credential commit | kprobe:commit_creds | PRIVILEGE | 20% | kb_privilege.bpf.c |
| Sensitive file open | tracepoint:syscalls:sys_enter_openat (LSM planned) | FILE | 10% | kb_file.bpf.c |
| Network connect/bind | tracepoint:syscalls:sys_enter_connect / sys_enter_bind | NETWORK | 10% | kb_network.bpf.c |
| Memory map/protect | tracepoint:syscalls:sys_enter_mmap / sys_enter_mprotect | MEMORY | 15% | kb_memory.bpf.c |
All six are also combined into a single unified object, kbd_sensor.bpf.c, which is the actual production sensor — the individual per-hook binaries above remain useful for isolated testing/debugging (see kb-core).
commit_creds is hooked to snapshot uid/gid/euid/cap_effective per-pid and diff against the previous snapshot on every call. An event is only emitted when credentials actually changed; escalation is flagged when new_uid < old_uid or new_euid == 0.
kb_memory.bpf.c flags:
-
RWX mappings (
PROT_READ | PROT_WRITE | PROT_EXECall set) — classic shellcode staging. - Anonymous + executable mappings.
-
W^X violations on
mprotect— addingPROT_EXECto an existing mapping (write-then-execute is a canonical exploit pattern).
Currently checks path prefixes for /etc/shadow, /etc/passwd, /etc/sudoers, /root/, and (standalone collector only) /.ssh/. See Event Contract for the exact behavior difference between the standalone collector and the unified sensor.
The following were identified as high-value gaps in docs/architecture/hookpoints.md and are tracked as future work, not current behavior:
Process & Execution
-
kprobe:do_execveat_common— catchesexecveat()(exec from file descriptor), a common LOLBin evasion vector -
tracepoint:sched:sched_process_ptrace— ptrace attachment detection (debugger/injection) -
kprobe:kernel_clone— lower-level than sched tracepoints; catches flags likeCLONE_NEWUSER
Privilege & Credential
-
kprobe:security_capable— fires on every capability check, not just changes -
kprobe:set_user— UID transitions bypassingcommit_credsin some paths -
kprobe:override_creds/kprobe:revert_creds— abusable for temporary escalation
Memory & Code Injection
-
kprobe:__do_mmap— finer-grained anonymous+exec detection -
uprobeonlibc:dlopen— dynamic library injection into running processes -
kprobe:process_vm_writev— direct cross-process memory write (near-exclusively used for injection)
File & Filesystem
-
kprobe:vfs_writeon/proc/*/mem— writing to another process's memory via procfs -
lsm:inode_rename— file rename tricks (log tampering, binary swapping) -
kprobe:security_inode_create— file creation in sensitive directories (/etc,/bin,/lib) -
lsm:file_openon/etc/passwd,/etc/sudoers,/root/.ssh/— targeted credential surveillance
Network
-
kprobe:tcp_connect— full socket struct including dest IP/port before syscall return -
kprobe:udp_sendmsg— DNS exfiltration / C2-over-UDP thattracepoint:netmay miss -
lsm:socket_bindon privileged ports — listener setup by a non-privileged process post-escalation
Kernel Integrity
-
kprobe:kallsyms_lookup_name— rootkit symbol-resolution technique -
kprobe:ftrace_set_filter— tampering with KB's own tracing subsystem -
kprobe:module_put/kprobe:try_module_get— LKM reference-count monitoring
Timers & Scheduling (Persistence Detection)
-
kprobe:mod_timer— unusual timer registration (persistence callbacks) -
tracepoint:irq:softirq_entryon unusual vectors — deferred-execution tricks
Highest-value gaps flagged in the docs:
process_vm_writev,security_capable,do_execveat_common, and the/proc/*/memwrite hook — these cover injection and privilege-probing patterns the current hook set leaves partially blind to.
See also: Cross Kernel Portability for how new hooks should be written to remain CO-RE compatible, and kb-core for the build system.
~ Team Kernel Borderlands
Kernel Borderlands
Overview
- Architecture
- Zone Model And Scoring
- Event Contract
- Wire Protocol
- Kernel Hook Points
- Cross Kernel Portability
Getting Started
Subsystems
Project