Creta es un proyecto de investigación destinado a detectar vulnerabilidades del kernel de Linux utilizando eBPF. KRIe está lejos de ser una estrategia a prueba de balas: desde las restricciones relacionadas con eBPF hasta la detección posterior a la explotación que puede depender de un kernel infectado para señalar un evento de seguridad, está claro que los atacantes motivados eventualmente podrán eludirlo. Dicho esto, el objetivo del proyecto es hacerles la vida más difícil a los atacantes y, en última instancia, evitar que los exploits listos para usar exploten kernels vulnerables.
Se utiliza KRIe CO-RE (compilar una vez – ejecutar en cualquier lugar) Hazlo compatible con una amplia gama de versiones del kernel.Si su kernel no exporta su información de depuración BTF, KRIe intentará obtener la Centro BTFSi su kernel no está disponible en BTFHub, pero ha podido generar datos BTF manualmente para su kernel, puede proporcionarlos en el archivo de configuración (consulte a continuación).
Tabla de Contenidos
Requisitos del sistema
El proyecto se desarrolló en Ubuntu Focal 20.04 (Linux kernel 5.15) y se probó en versiones anteriores hasta Ubuntu Bionic 18.04 (Linux kernel 4.15).
- Golang 1.18+
- (Opcional) Se espera que los encabezados del kernel se instalen en
lib/modules/$(uname -r)
renovarMakefile
De lo contrario, su posición. - (opcional) clang & llvm 14.0.6+
Se requieren campos opcionales para recompilar programas eBPF.
Hospedarse
- Dado que KRIe está construido usando CORE, no necesita reconstruir los programas eBPF. Dicho esto, si aún desea reconstruir los programas eBPF, puede usar el siguiente comando:
# ~ make build-ebpf
- Para compilar KRIE, ejecute:
# ~ make build
- Para instalar KRIE (copiar a /usr/bin/krie) ejecute:
# ~ make install
empezando
KRIe debe ejecutarse como root.correr sudo krie -h
consigue ayuda.
# ~ krie -h
Usage:
krie [flags]
Flags:
--config string KRIe config file (default "./cmd/krie/run/config/default_config.yaml")
-h, --help help for krie
configuración
## Log level, options are: panic, fatal, error, warn, info, debug or trace
log_level: debug
## JSON output file, leave empty to disable JSON output.
output: "/tmp/krie.json"
## BTF information for the current kernel in .tar.xz format (required only if KRIE isn't able to locate it by itself)
vmlinux: ""
## events configuration
events:
## action taken when an init_module event is detected
init_module: log
## action taken when an delete_module event is detected
delete_module: log
## action taken when a bpf event is detected
bpf: log
## action taken when a bpf_filter event is detected
bpf_filter: log
## action taken when a ptrace event is detected
ptrace: log
## action taken when a kprobe event is detected
kprobe: log
## action taken when a sysctl event is detected
sysctl:
action: log
## Default settings for sysctl programs (kernel 5.2+ only)
sysctl_default:
block_read_access: false
block_write_access: false
## Custom settings for sysctl programs (kernel 5.2+ only)
sysctl_parameters:
kernel/yama/ptrace_scope:
block_write_access: true
kernel/ftrace_enabled:
override_input_value_with: "1\n"
## action taken when a hooked_syscall_table event is detected
hooked_syscall_table: log
## action taken when a hooked_syscall event is detected
hooked_syscall: log
## kernel_parameter event configuration
kernel_parameter:
action: log
periodic_action: log
ticker: 1 # sends at most one event every [ticker] second(s)
list:
- symbol: system/kprobes_all_disarmed
expected_value: 0
size: 4
# - symbol: system/selinux_state
# expected_value: 256
# size: 2
# sysctl
- symbol: system/ftrace_dump_on_oops
expected_value: 0
size: 4
- symbol: system/kptr_restrict
expected_value: 0
size: 4
- symbol: system/randomize_va_space
expected_value: 2
size: 4
- symbol: system/stack_tracer_enabled
expected_value: 0
size: 4
- symbol: system/unprivileged_userns_clone
expected_value: 0
size: 4
- symbol: system/unprivileged_userns_apparmor_policy
expected_value: 1
size: 4
- symbol: system/sysctl_unprivileged_bpf_disabled
expected_value: 1
size: 4
- symbol: system/ptrace_scope
expected_value: 2
size: 4
- symbol: system/sysctl_perf_event_paranoid
expected_value: 2
size: 4
- symbol: system/kexec_load_disabled
expected_value: 1
size: 4
- symbol: system/dmesg_restrict
expected_value: 1
size: 4
- symbol: system/modules_disabled
expected_value: 0
size: 4
- symbol: system/ftrace_enabled
expected_value: 1
size: 4
- symbol: system/ftrace_disabled
expected_value: 0
size: 4
- symbol: system/sysctl_protected_fifos
expected_value: 1
size: 4
- symbol: system/sysctl_protected_hardlinks
expected_value: 1
size: 4
- symbol: system/sysctl_protected_regular
expected_value: 2
size: 4
- symbol: system/sysctl_protected_symlinks
expected_value: 1
size: 4
- symbol: system/sysctl_unprivileged_userfaultfd
expected_value: 0
size: 4
## action to check when a register_check fails on a sensitive kernel space hook point
register_check: log