Slide 1

Slide 1 text

eBPF for Security Observability Liz Rice | @lizrice Chief Open Source Officer, Isovalent

Slide 2

Slide 2 text

@lizrice

Slide 3

Slide 3 text

@lizrice What is ? extended Berkeley Packet Filter

Slide 4

Slide 4 text

@lizrice What is ? Makes the kernel programmable

Slide 5

Slide 5 text

@lizrice userspace kernel app event system calls eBPF program Run custom code in the kernel

Slide 6

Slide 6 text

@lizrice SEC("kprobe/sys_execve") int hello(void *ctx) { bpf_trace_printk("Hello World!"); return 0; } $ sudo ./hello bash-20241 [004] d... 84210.752785: 0: Hello World! bash-20242 [004] d... 84216.321993: 0: Hello World! bash-20243 [004] d... 84225.858880: 0: Hello World! Info about process that called execve syscall + userspace code to load eBPF program eBPF Hello World

Slide 7

Slide 7 text

Dynamic changes to kernel behaviour

Slide 8

Slide 8 text

Dynamic tracing tools

Slide 9

Slide 9 text

@lizrice userspace kernel Tracing tool event eBPF program Use eBPF to collect event metrics eBPF Map metrics load Gather & show metrics

Slide 10

Slide 10 text

@lizrice eBPF tracing tools from iovisor/bcc

Slide 11

Slide 11 text

@lizrice eBPF tracing - opensnoop ~/bcc/libbpf-tools$ sudo ./opensnoop PID COMM FD ERR PATH 5040 node 21 0 /proc/5132/cmdline 5040 node 21 0 /proc/6460/cmdline 5040 node 21 0 /proc/6460/cmdline 6461 opensnoop 18 0 /etc/localtime 5040 node 21 0 /proc/5132/cmdline 5040 node 21 0 /proc/6460/cmdline 5060 node 23 0 /home/liz/.vscode-server/data/User/workspaceStorage/48b53 5040 node 21 0 /proc/5132/cmdline 5040 node 21 0 /proc/6460/cmdline 5040 node 21 0 /proc/5132/cmdline 5040 node 21 0 /proc/6460/cmdline …

Slide 12

Slide 12 text

eBPF and Kubernetes

Slide 13

Slide 13 text

@lizrice userspace kernel pod container pod container container One kernel per host

Slide 14

Slide 14 text

@lizrice userspace kernel networking access files create containers One kernel per host pod container pod container container

Slide 15

Slide 15 text

@lizrice userspace kernel app app pods networking access files create containers Kernel aware of everything on the host

Slide 16

Slide 16 text

@lizrice userspace app kernel app pods networking access files create containers eBPF programs can be aware of everything

Slide 17

Slide 17 text

@lizrice $ kubectl gadget trace open NODE NAMESPACE POD CONTAINER PID COMM FD ERR PATH kind-2-control-plane default xwing spaceship 361876 vi 3 0 /etc/passwd eBPF tracing on Kubernetes - Inspektor Gadget Kubernetes info

Slide 18

Slide 18 text

@lizrice eBPF observability tools -

Slide 19

Slide 19 text

@lizrice eBPF observability tools - Cilium Hubble

Slide 20

Slide 20 text

eBPF observability

Slide 21

Slide 21 text

eBPF security observability

Slide 22

Slide 22 text

@lizrice Security observability

Slide 23

Slide 23 text

@lizrice Security observability

Slide 24

Slide 24 text

@lizrice What activity do we care about for security? eBPF programs

Slide 25

Slide 25 text

@lizrice Syscall checks within the kernel

Slide 26

Slide 26 text

@lizrice TOCTTOU vulnerabilities with syscalls For more details ● Leo Di Donato & KP Singh at CN eBPF Day 2021 ● Rex Guo & Junyuan Zeng at DEFCON 29 on Phantom attacks Attacker changes params after inspection

Slide 27

Slide 27 text

@lizrice Need to make the check at the right place

Slide 28

Slide 28 text

@lizrice Linux Security Modules ● Stable interface ● Safe places to make checks

Slide 29

Slide 29 text

@lizrice BPF LSM ● Stable interface ● Safe places to make checks + eBPF benefits ● Dynamic ● Protect pre-existing processes

Slide 30

Slide 30 text

@lizrice $ sudo ./chmoddemo & [1] 7631 $ sudo cat /sys/kernel/debug/tracing/trace_pipe chmod-7776 [001] d... 38197.342160: bpf_trace_printk: lsm path_chmod liz BPF LSM hook has kernel info populated SEC("lsm/path_chmod") int BPF_PROG(path_chmod, const struct path *path, umode_t mode) { bpf_printk("lsm path_chmod %s\n", path->dentry->d_iname); return 0; } Filename known to kernel

Slide 31

Slide 31 text

@lizrice BPF LSM ● Stable interface ● Safe places to make checks + eBPF benefits ● Dynamic ● Protect pre-existing processes But needs kernel 5.7+ & Kubernetes context?

Slide 32

Slide 32 text

How stable is the Linux kernel?

Slide 33

Slide 33 text

@lizrice Cilium Tetragon ● Safe places to make checks + eBPF benefits ● Dynamic ● Protect pre-existing processes Uses kernel knowledge to hook into sufficiently stable functions Adds Kubernetes context

Slide 34

Slide 34 text

@lizrice Photo credit: Bibafu A Tetragonisca angustula bee guarding the nest-entrance

Slide 35

Slide 35 text

@lizrice apiVersion: cilium.io/v1alpha1 kind: TracingPolicy metadata: name: "etc-files" spec: kprobes: - call: "fd_install" … matchArgs: - index: 1 operator: "Prefix" values: - "/etc/" … Cilium Tetragon tracing policy + Policy “follows” file descriptor through read, write & close events

Slide 36

Slide 36 text

@lizrice $ kubectl logs ds/tetragon -c export-stdout -f | tetragon observe 🚀 process default/xwing /usr/bin/vi /etc/passwd 📬 open default/xwing /usr/bin/vi /etc/passwd 📪 close default/xwing /usr/bin/vi 📬 open default/xwing /usr/bin/vi /etc/passwd 📝 write default/xwing /usr/bin/vi /etc/passwd 1275 bytes 📪 close default/xwing /usr/bin/vi 💥 exit default/xwing /usr/bin/vi /etc/passwd 0 Cilium Tetragon observe Policy events Kubernetes info

Slide 37

Slide 37 text

@lizrice Combined network and runtime visibility

Slide 38

Slide 38 text

eBPF preventative runtime security

Slide 39

Slide 39 text

@lizrice Network policy → eBPF programs drop packets

Slide 40

Slide 40 text

@lizrice Preventative actions from user space

Slide 41

Slide 41 text

@lizrice Preventative actions from kernel

Slide 42

Slide 42 text

@lizrice $ kubectl logs ds/tetragon -c export-stdout -f | tetragon observe 🚀 process default/xwing /usr/bin/vi /etc/passwd 📬 open default/xwing /usr/bin/vi /etc/passwd 📪 close default/xwing /usr/bin/vi 📬 open default/xwing /usr/bin/vi /etc/passwd 📝 write default/xwing /usr/bin/vi /etc/passwd 1269 bytes 💥 exit default/xwing /usr/bin/vi /etc/passwd SIGKILL Cilium Tetragon observe Killed before write

Slide 43

Slide 43 text

eBPF security observability ● Dynamic instrumentation - zero app modifications ● Contextual information, Kubernetes identity-aware ● Option for runtime enforcement from the kernel

Slide 44

Slide 44 text

Thank you! cilium/tetragon @ciliumproject cilium.io | ebpf.io @lizrice