eBPF-based security platform
bpf: count a traced exec of shirudo as ExecTraced
Daniel Borkmannd3b9de48d0d1
diff --git a/bpf/seal.c b/bpf/seal.cindex 3bf7810d..72e9422e 100644--- a/bpf/seal.c+++ b/bpf/seal.c@@ -41,8 +41,9 @@ int BPF_PROG(shirudo_seal_bprm_check_security,real_inode = bpf_real_data_inode(bprm->file);trusted = real_inode == BPF_CORE_READ(bprm, file, f_inode) &&shirudo_file_runtime(bprm->file);- if (trusted && (BPF_CORE_READ(task, ptrace) ||- shirudo_task_has_seccomp(task)))+ if (trusted && BPF_CORE_READ(task, ptrace))+ return shirudo_tamper_deny(SHIRUDO_TAMPER_EXEC_TRACED, -EACCES);+ if (trusted && shirudo_task_has_seccomp(task))return -EACCES;authority = bpf_task_storage_get(&shirudo_tasks, task, NULL,BPF_LOCAL_STORAGE_GET_F_CREATE);diff --git a/testing/functional/tamperproof/t6137-traced-exec.sh b/testing/functional/tamperproof/t6137-traced-exec.shindex 1c6be5e7..c3317838 100755--- a/testing/functional/tamperproof/t6137-traced-exec.sh+++ b/testing/functional/tamperproof/t6137-traced-exec.sh@@ -3,10 +3,9 @@# Copyright (c) 2026 Authors of shirudo## t6137 -- no traced task can exec shirudo, so no tracer carries over-# into it. The seal's exec check refuses it with EACCES before the-# admission check, which would refuse it with EPERM and count it as-# ExecTraced, is reached. The traced exec is of the runtime binary-# itself, not of the wrapper script that starts it.+# into it; the seal's exec check refuses it with EACCES and counts it as+# ExecTraced. The traced exec is of the runtime binary itself, not of the+# wrapper script that starts it.cd "$(dirname "$0")/../..". ./integration-lib.sh@@ -39,16 +38,25 @@ if os.WIFSTOPPED(status):EOF}+counter() {+ "$SHIRUDO_BIN" status --json | python3 -c '+import json, sys+print(json.load(sys.stdin)["tamper_attempts"]["counters"][sys.argv[1]])+' "$1"+}+test_expect_success 'a traced task execs an ordinary program' '[ "$(traced_exec "$ENV" true)" = ran ]'-test_expect_success 'a traced task cannot exec shirudo' '+test_expect_success 'a traced task cannot exec shirudo, and the refusal is counted' '+ before=$(counter ExecTraced) &&out=$(traced_exec "$BIN" version) &&[ "$out" = 13 ] || {echo "traced exec of $BIN: ${out:-no outcome}"false- }+ } &&+ [ "$(counter ExecTraced)" = $((before + 1)) ]'test_expect_success 'shirudo still runs untraced' '