原文:The Tetragon Authors / Cilium 的 Filename access、Network observability 和 Monitor Process Credentials changes at the System Call layer。原页未署个人作者。译编:未完纪。
这组三篇用例分别观察容器里的文件访问、TCP 活动与 UID/GID 变更请求。本文合并翻译三篇的正文说明、操作、输出与限制,在同一条审计主线中展开,并将策略链接固定到 Tetragon v1.7.0。版本调整和额外审阅标为译注;输出均为上游示例,不是本次实测。

实验边界与准备
译注:以下操作适合已安装 Tetragon 的隔离、单节点 Kubernetes 实验环境。应用 TracingPolicy 会让具有相关内核权限的 Tetragon 加载 eBPF 观测逻辑;确认集群上下文和访问权限后再操作。这里不安装或更改生产集群,也没有实际加载策略。Tetragon、tetra CLI、CRD 和内核需互相兼容。
教程里的 main 链接会变化。本文改用已读取的 v1.7.0 YAML,并先下载到本地,检查后应用;清理使用同一文件。网页并不等于固定发布版文档:文件访问页含 2026-02-20 的内核兼容补充,网络与凭据页的显示修改时间为 2023-12-01。
凭据用例要求部署官方演示应用,并确认 Pod 已运行。原文使用:
kubectl create -f https://raw.githubusercontent.com/cilium/cilium/v1.15.3/examples/minikube/http-sw-app.yaml
kubectl get pods -A
部分 Pod 可能要等待依赖就绪。原文给出的状态示例是:
NAMESPACE NAME READY STATUS RESTARTS AGE
default deathstar-54bb8475cc-6c6lc 1/1 Running 0 2m54s
default deathstar-54bb8475cc-zmfkr 1/1 Running 0 2m54s
default tiefighter 1/1 Running 0 2m54s
default xwing 1/1 Running 0 2m54s
kube-system tetragon-sdwv6 2/2 Running 0 27m
静态审阅:已读该 v1.15.3 演示清单;其中镜像含摘要,但实际的 xwing 镜像与下面历史 JSON 输出里的 tgraf/netperf:latest 不同。需要核对当前演示容器是否有 curl、/bin/bash 和 su,以及相应权限;本文未运行镜像来确认这些工具。现存同名演示资源不可直接当作可删除的临时资源。
一、用 kprobe 观察文件访问
文件访问策略包含两个方面:选用什么钩子观察特定访问类型,以及怎样在内核中只保留需要的事件。一般概念见 TracingPolicy 钩子说明。
选择钩子
最常见的访问是读写文件。应用不只会调用 read 和 write,还会使用 copy_file_range、sendfile,或 aio、io_uring 的异步 I/O 接口。与其逐个监控系统调用,示例选择这些路径共有的 security_file_permission。
应用也能把文件直接映射进虚拟地址空间。这时逐次捕捉真正的内存访问很困难,因此策略监控文件被映射的时刻,使用 security_mmap_file。它表示映射操作,并不记录此后每一次内存读写。
另一类调用通过改变文件长度间接修改内容,例如 truncate。旧示例使用 security_path_truncate。从 Linux 6.2 开始,该路径经过重构,需要检查 security_file_truncate;兼容处理见下文。
在内核过滤
这些钩子能产生大量系统事件,很多时候只需要其中一部分。生成事件后再过滤会增加不必要的开销;Tetragon 使用 BPF,可直接在内核里筛选。下面是原文用于监控 /etc/passwd 写入的策略片段:
- call: "security_file_permission"
syscall: false
args:
- index: 0
type: "file" # struct file *,用于获取路径
- index: 1
type: "int" # MAY_READ 为 0x04,MAY_WRITE 为 0x02
selectors:
- matchArgs:
- index: 0
operator: "Equal"
values:
- "/etc/passwd"
- index: 1
operator: "Equal"
values:
- "2"
需要给出被挂钩函数的参数索引及类型。这里用 Equal 精确比较路径及访问参数;也可用 Prefix 按路径前缀过滤。参数是权限掩码,精确等于 2 不能被解释成“所有含写位的任意组合值都匹配”。
先处理内核兼容性
Linux 6.2 及更新内核中,security_path_truncate 不再是可靠的可挂 kprobe 符号:它可能被内联,或可见性已变化。策略若引用不存在的钩子,整条策略会加载失败,其他读写钩子也不会产生事件。因此“没有事件”可能是策略根本没加载,而不是容器没有访问文件。
原文建议在 Tetragon Pod 内或宿主机检查:
cat /sys/kernel/tracing/available_filter_functions | grep security_path_truncate
cat /sys/kernel/tracing/available_filter_functions | grep security_file_truncate
先下载固定版本策略:
curl -fsSLo filename_monitoring.yaml https://raw.githubusercontent.com/cilium/tetragon/v1.7.0/examples/tracingpolicy/filename_monitoring.yaml
修订说明:下面展示适用于已确认存在新钩子环境的完整修订版。相对 v1.7.0,唯一功能性修改是把最后一个钩子的 security_path_truncate 改为 security_file_truncate,并把参数类型 path 改成 file;其余过滤和返回值设置保留。将它保存到刚才的本地文件,核对后再应用。旧内核需要使用已经验证存在的旧钩子和 path 参数。
完整文件访问策略:使用新 truncate 钩子
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: "file-monitoring"
spec:
kprobes:
- call: "security_file_permission"
syscall: false
return: true
args:
- index: 0
type: "file" # (struct file *) used for getting the path
- index: 1
type: "int" # 0x04 is MAY_READ, 0x02 is MAY_WRITE
returnArg:
index: 0
type: "int"
selectors:
- matchArgs:
- index: 0
operator: "Prefix"
values:
- "/etc/" # filenames to filter for
- call: "security_mmap_file"
syscall: false
return: true
args:
- index: 0
type: "file" # (struct file *) used for getting the path
- index: 1
type: "uint32" # the prot flags PROT_READ(0x01), PROT_WRITE(0x02), PROT_EXEC(0x04)
- index: 2
type: "nop" # the mmap flags (i.e. MAP_SHARED, ...)
returnArg:
index: 0
type: "int"
selectors:
- matchArgs:
- index: 0
operator: "Prefix"
values:
- "/etc/" # filenames to filter for
- call: "security_file_truncate"
syscall: false
return: true
args:
- index: 0
type: "file" # (struct file *) used for getting the path
returnArg:
index: 0
type: "int"
selectors:
- matchArgs:
- index: 0
operator: "Prefix"
values:
- "/etc/" # filenames to filter for
原文还提供同时声明新旧钩子、在各项加上 ignore.callNotFound: true 的兼容思路:
# 旧内核钩子的完整配置项中:
- call: "security_path_truncate"
# ……其余 path 参数、返回值和过滤配置……
ignore:
callNotFound: true
# 新内核钩子的完整配置项中:
- call: "security_file_truncate"
syscall: false
return: true
args:
- index: 0
type: "file"
# ……其余返回值和过滤配置……
ignore:
callNotFound: true
上面是结构片段,不是可直接应用的完整清单。callNotFound: true 会跳过不存在的钩子,让其他项仍可加载;这也可能静默减少观测覆盖。使用前应确认安装版本支持该字段,并核查真正加载的钩子。本文给出的单钩子完整修订没有依赖这一选项。
观察 /etc/ 下的文件
示例监控 Kubernetes 负载对 /etc/ 下文件的读取与写入,可按需扩展到其他目录或文件。对本地策略完成上述检查后应用:
kubectl apply -f filename_monitoring.yaml
在一个终端创建临时交互 Pod:
kubectl run --rm -it file-access -n default --image=busybox --restart=Never
译注:原文把交互环境称作 bash,但 BusyBox 示例输出显示 /bin/sh,不能假定镜像有 Bash。原命令的 busybox 没有固定标签或摘要,会随时间变化;需要复现实验时应事先选定并记录经过验证的镜像摘要。
在另一个终端启动事件观察:
kubectl exec -it -n kube-system ds/tetragon -c tetragon -- tetra getevents -o compact --namespace default --pod file-access
回到临时 Pod 内,按原示例编辑 /etc/passwd:
vi /etc/passwd
这一步修改的是隔离实验 Pod 的文件;不要在宿主机终端或共享生产容器照做。原文观察窗口给出如下事件序列:
🚀 process default/file-access /bin/sh
🚀 process default/file-access /bin/vi /etc/passwd
📚 read default/file-access /bin/vi /etc/passwd
📚 read default/file-access /bin/vi /etc/passwd
📚 read default/file-access /bin/vi /etc/passwd
📝 write default/file-access /bin/vi /etc/passwd
📝 truncate default/file-access /bin/vi /etc/passwd
💥 exit default/file-access /bin/vi /etc/passwd 0
BPF 的路径前缀过滤使这份策略只为匹配 /etc/ 的访问生成对应文件事件。原教程还说默认 CRD 会过滤 Pod 初始化进程的噪声;但本文固定的 v1.7.0 文件策略只包含路径过滤,未见该进程过滤选择器,不能把这句描述当作该 YAML 已提供的保证。
查看 JSON 可获得更完整的 Kubernetes 身份与进程上下文。以下保留原文的完整写入事件示例:
原文 JSON:文件写入事件
{
"process_kprobe": {
"process": {
"exec_id": "dGV0cmFnb24tZGV2LWNvbnRyb2wtcGxhbmU6MTY4MTc3MDUwMTI1NDI6NjQ3NDY=",
"pid": 64746,
"uid": 0,
"cwd": "/",
"binary": "/bin/vi",
"arguments": "/etc/passwd",
"flags": "execve rootcwd clone",
"start_time": "2024-04-14T02:18:02.240856427Z",
"auid": 4294967295,
"pod": {
"namespace": "default",
"name": "file-access",
"container": {
"id": "containerd://6b742e38ee3a212239e6d48b2954435a407af44b9a354bdf540db22f460ab40e",
"name": "file-access",
"image": {
"id": "docker.io/library/busybox@sha256:c3839dd800b9eb7603340509769c43e146a74c63dca3045a8e7dc8ee07e53966",
"name": "docker.io/library/busybox:latest"
},
"start_time": "2024-04-14T02:17:46Z",
"pid": 12
},
"pod_labels": {
"run": "file-access"
},
"workload": "file-access",
"workload_kind": "Pod"
},
"docker": "6b742e38ee3a212239e6d48b2954435",
"parent_exec_id": "dGV0cmFnb24tZGV2LWNvbnRyb2wtcGxhbmU6MTY4MDE3MDQ3OTQyOTg6NjQ2MTU=",
"refcnt": 1,
"tid": 64746
},
"parent": {
"exec_id": "dGV0cmFnb24tZGV2LWNvbnRyb2wtcGxhbmU6MTY4MDE3MDQ3OTQyOTg6NjQ2MTU=",
"pid": 64615,
"uid": 0,
"cwd": "/",
"binary": "/bin/sh",
"flags": "execve rootcwd clone",
"start_time": "2024-04-14T02:17:46.240638141Z",
"auid": 4294967295,
"pod": {
"namespace": "default",
"name": "file-access",
"container": {
"id": "containerd://6b742e38ee3a212239e6d48b2954435a407af44b9a354bdf540db22f460ab40e",
"name": "file-access",
"image": {
"id": "docker.io/library/busybox@sha256:c3839dd800b9eb7603340509769c43e146a74c63dca3045a8e7dc8ee07e53966",
"name": "docker.io/library/busybox:latest"
},
"start_time": "2024-04-14T02:17:46Z",
"pid": 1
},
"pod_labels": {
"run": "file-access"
},
"workload": "file-access",
"workload_kind": "Pod"
},
"docker": "6b742e38ee3a212239e6d48b2954435",
"parent_exec_id": "dGV0cmFnb24tZGV2LWNvbnRyb2wtcGxhbmU6MTY3OTgyOTA2MDc3NTc6NjQ1NjQ=",
"tid": 64615
},
"function_name": "security_file_permission",
"args": [
{
"file_arg": {
"path": "/etc/passwd",
"permission": "-rw-r--r--"
}
},
{
"int_arg": 2
}
],
"return": {
"int_arg": 0
},
"action": "KPROBE_ACTION_POST",
"policy_name": "file-monitoring",
"return_action": "KPROBE_ACTION_POST"
},
"node_name": "tetragon-dev-control-plane",
"time": "2024-04-14T02:18:14.376304204Z"
}
除进程执行事件中已有的 Kubernetes 身份与进程元数据外,process_kprobe 还包含挂钩函数的参数:
file_arg.path:被观察的文件路径。int_arg:操作参数;本例 2 表示写,4 表示读。return.int_arg:本例为 0,表示权限检查允许。它不等于整次业务写入已经持久化成功。
结束此项实验时删除本次使用的策略,在临时 Pod 会话中输入 exit;原 --rm 会清理该交互 Pod:
kubectl delete -f filename_monitoring.yaml
exit
原文另链接了 进一步过滤文件访问的相似策略。这些路径策略按应用实际使用的文件名匹配;同一个文件如果经由硬链接或不同 bind mount 路径访问,可能没有匹配事件,因此它不构成完整的文件对象访问审计。
二、观察 TCP 连接
网络用例用 kprobe 捕捉 TCP 连接。下载、审阅并应用固定版本的策略:
curl -fsSLo tcp-connect.yaml https://raw.githubusercontent.com/cilium/tetragon/v1.7.0/examples/tracingpolicy/tcp-connect.yaml
kubectl apply -f tcp-connect.yaml
该策略的三个钩子为 tcp_connect、tcp_close 和 tcp_sendmsg,参数包含 socket,发送事件另取第 2 号参数。
v1.7.0 完整 TCP 策略
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: "connect"
spec:
kprobes:
- call: "tcp_connect"
syscall: false
args:
- index: 0
type: "sock"
- call: "tcp_close"
syscall: false
args:
- index: 0
type: "sock"
- call: "tcp_sendmsg"
syscall: false
args:
- index: 0
type: "sock"
- index: 2
type: int
在一个终端观察默认命名空间中 xwing Pod 的事件,使用原文的日志导出流与 CLI 组合:
kubectl logs -n kube-system -l app.kubernetes.io/name=tetragon -c export-stdout -f | tetra getevents -o compact --namespace default --pod xwing
在另一个终端生成 TCP 连接;原文使用 curl:
kubectl exec -it xwing -- curl http://cilium.io
第一个终端的示例输出展示进程启动、连接、发送、关闭与退出:
🚀 process default/xwing /usr/bin/curl http://cilium.io
🔌 connect default/xwing /usr/bin/curl tcp 10.244.0.6:34965 -> 104.198.14.52:80
📤 sendmsg default/xwing /usr/bin/curl tcp 10.244.0.6:34965 -> 104.198.14.52:80 bytes 73
🧹 close default/xwing /usr/bin/curl tcp 10.244.0.6:34965 -> 104.198.14.52:80
💥 exit default/xwing /usr/bin/curl http://cilium.io 0
地址、端口、字节数与退出值均属于原文那次示例,不应期待每次相同。这里沿用明文 HTTP 只是为了演示端口 80 的网络活动,不要在该请求里附带秘密。该用例观察 TCP,不应宣称覆盖所有网络协议或应用层请求。
关闭此策略:
kubectl delete -f tcp-connect.yaml
三、观察 UID/GID 变更请求
Tetragon 可以挂到直接操作进程凭据的系统调用,指出哪个进程正在尝试改变凭据,以及内核可能应用哪些新值。原文提出两个问题:集群中哪个进程或容器试图改变 UID/GID?哪个进程或容器试图改变 capability?下面给出的具体策略处理的是第一个问题。
process.credentials.changes.at.syscalls 监控 setuid 系列:setuid、setgid、setfsuid、setfsgid、setreuid、setregid、setresuid 和 setresgid。已核对 v1.7.0,策略不包含 capset,setgroups 也只是 TODO;不能拿它证明所有 capability 或附加组变更都已被监控。
curl -fsSLo process.credentials.changes.at.syscalls.yaml https://raw.githubusercontent.com/cilium/tetragon/v1.7.0/examples/tracingpolicy/process-credentials/process.credentials.changes.at.syscalls.yaml
kubectl apply -f process.credentials.changes.at.syscalls.yaml
该策略使用 syscall: true,每个钩子按函数参数数量采集整数参数,并通过 matchNamespaces 排除 host_ns 的 PID 命名空间。它的默认范围不是“所有宿主机进程”。
v1.7.0 完整凭据系统调用策略
# This 'process.credentials.changes.at.syscalls' Tracing Policy
# monitors processes trying to change their credentials inside
# a pid namespace. If you want to monitor all processes including
# host ones, remove the matchNamespaces selector.
#
# Monitors the following system calls:
# - setuid(), setgid(), setfsuid(), setfsgid()
# setreuid(), setregid(), setresuid(), setresgid()
#
# - setgroups() TODO
#
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: "process.credentials.changes.at.syscalls"
spec:
kprobes:
- call: "sys_setuid"
syscall: true
args:
- index: 0
type: "int"
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values:
- "host_ns"
- call: "sys_setgid"
syscall: true
args:
- index: 0
type: "int"
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values:
- "host_ns"
- call: "sys_setreuid"
syscall: true
args:
- index: 0
type: "int"
- index: 1
type: "int"
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values:
- "host_ns"
- call: "sys_setregid"
syscall: true
args:
- index: 0
type: "int"
- index: 1
type: "int"
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values:
- "host_ns"
- call: "sys_setresuid"
syscall: true
args:
- index: 0
type: "int"
- index: 1
type: "int"
- index: 2
type: "int"
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values:
- "host_ns"
- call: "sys_setresgid"
syscall: true
args:
- index: 0
type: "int"
- index: 1
type: "int"
- index: 2
type: "int"
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values:
- "host_ns"
- call: "sys_setfsuid"
syscall: true
args:
- index: 0
type: "int"
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values:
- "host_ns"
- call: "sys_setfsgid"
syscall: true
args:
- index: 0
type: "int"
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values:
- "host_ns"
启动 CLI 观察,然后从另一个终端进入 xwing:
kubectl exec -it -n kube-system ds/tetragon -c tetragon -- tetra getevents
kubectl exec -it xwing -- /bin/bash
在实验容器里执行原文的 su 示例,它会走相关 setuid 系统调用路径:
su root
是否能执行或切换身份取决于镜像内的工具、用户、权限与配置,不应为复现输出而随意放宽生产容器权限。原文给出两条 ProcessKprobe 事件,完整保留如下:
原文 JSON:setgid 与 setuid 事件
{
"process_kprobe": {
"process": {
"exec_id": "a2luZC1jb250cm9sLXBsYW5lOjQwNzk4ODc2MDI2NTk4OjEyNTc5OA==",
"pid": 125798,
"uid": 0,
"cwd": "/",
"binary": "/bin/su",
"arguments": "root",
"flags": "execve rootcwd clone",
"start_time": "2023-07-05T19:14:30.918693157Z",
"auid": 4294967295,
"pod": {
"namespace": "default",
"name": "xwing",
"container": {
"id": "containerd://55936e548de63f77ceb595d64966dd8e267b391ff0ef63b26c17eb8c2f6510be",
"name": "spaceship",
"image": {
"id": "docker.io/tgraf/netperf@sha256:8e86f744bfea165fd4ce68caa05abc96500f40130b857773186401926af7e9e6",
"name": "docker.io/tgraf/netperf:latest"
},
"start_time": "2023-07-05T18:45:16Z",
"pid": 19
},
"pod_labels": {
"app.kubernetes.io/name": "xwing",
"class": "xwing",
"org": "alliance"
}
},
"docker": "55936e548de63f77ceb595d64966dd8",
"parent_exec_id": "a2luZC1jb250cm9sLXBsYW5lOjQwNzk1NjYyMDM3MzMyOjEyNTc5Mg==",
"refcnt": 1,
"tid": 125798
},
"parent": {
"exec_id": "a2luZC1jb250cm9sLXBsYW5lOjQwNzk1NjYyMDM3MzMyOjEyNTc5Mg==",
"pid": 125792,
"uid": 0,
"cwd": "/",
"binary": "/bin/bash",
"flags": "execve rootcwd clone",
"start_time": "2023-07-05T19:14:27.704703805Z",
"auid": 4294967295,
"pod": {
"namespace": "default",
"name": "xwing",
"container": {
"id": "containerd://55936e548de63f77ceb595d64966dd8e267b391ff0ef63b26c17eb8c2f6510be",
"name": "spaceship",
"image": {
"id": "docker.io/tgraf/netperf@sha256:8e86f744bfea165fd4ce68caa05abc96500f40130b857773186401926af7e9e6",
"name": "docker.io/tgraf/netperf:latest"
},
"start_time": "2023-07-05T18:45:16Z",
"pid": 13
},
"pod_labels": {
"app.kubernetes.io/name": "xwing",
"class": "xwing",
"org": "alliance"
}
},
"docker": "55936e548de63f77ceb595d64966dd8",
"parent_exec_id": "a2luZC1jb250cm9sLXBsYW5lOjQwNzk1NjE2MTU0NzA2OjEyNTc4Mw==",
"refcnt": 2,
"tid": 125792
},
"function_name": "__x64_sys_setgid",
"args": [
{
"int_arg": 0
}
],
"action": "KPROBE_ACTION_POST"
},
"node_name": "kind-control-plane",
"time": "2023-07-05T19:14:30.918977160Z"
}
{
"process_kprobe": {
"process": {
"exec_id": "a2luZC1jb250cm9sLXBsYW5lOjQwNzk4ODc2MDI2NTk4OjEyNTc5OA==",
"pid": 125798,
"uid": 0,
"cwd": "/",
"binary": "/bin/su",
"arguments": "root",
"flags": "execve rootcwd clone",
"start_time": "2023-07-05T19:14:30.918693157Z",
"auid": 4294967295,
"pod": {
"namespace": "default",
"name": "xwing",
"container": {
"id": "containerd://55936e548de63f77ceb595d64966dd8e267b391ff0ef63b26c17eb8c2f6510be",
"name": "spaceship",
"image": {
"id": "docker.io/tgraf/netperf@sha256:8e86f744bfea165fd4ce68caa05abc96500f40130b857773186401926af7e9e6",
"name": "docker.io/tgraf/netperf:latest"
},
"start_time": "2023-07-05T18:45:16Z",
"pid": 19
},
"pod_labels": {
"app.kubernetes.io/name": "xwing",
"class": "xwing",
"org": "alliance"
}
},
"docker": "55936e548de63f77ceb595d64966dd8",
"parent_exec_id": "a2luZC1jb250cm9sLXBsYW5lOjQwNzk1NjYyMDM3MzMyOjEyNTc5Mg==",
"refcnt": 1,
"tid": 125798
},
"parent": {
"exec_id": "a2luZC1jb250cm9sLXBsYW5lOjQwNzk1NjYyMDM3MzMyOjEyNTc5Mg==",
"pid": 125792,
"uid": 0,
"cwd": "/",
"binary": "/bin/bash",
"flags": "execve rootcwd clone",
"start_time": "2023-07-05T19:14:27.704703805Z",
"auid": 4294967295,
"pod": {
"namespace": "default",
"name": "xwing",
"container": {
"id": "containerd://55936e548de63f77ceb595d64966dd8e267b391ff0ef63b26c17eb8c2f6510be",
"name": "spaceship",
"image": {
"id": "docker.io/tgraf/netperf@sha256:8e86f744bfea165fd4ce68caa05abc96500f40130b857773186401926af7e9e6",
"name": "docker.io/tgraf/netperf:latest"
},
"start_time": "2023-07-05T18:45:16Z",
"pid": 13
},
"pod_labels": {
"app.kubernetes.io/name": "xwing",
"class": "xwing",
"org": "alliance"
}
},
"docker": "55936e548de63f77ceb595d64966dd8",
"parent_exec_id": "a2luZC1jb250cm9sLXBsYW5lOjQwNzk1NjE2MTU0NzA2OjEyNTc4Mw==",
"refcnt": 2,
"tid": 125792
},
"function_name": "__x64_sys_setuid",
"args": [
{
"int_arg": 0
}
],
"action": "KPROBE_ACTION_POST"
},
"node_name": "kind-control-plane",
"time": "2023-07-05T19:14:30.918990583Z"
}
除 Kubernetes 身份与进程信息之外,重要字段是 function_name(示例为 __x64_sys_setgid 或 __x64_sys_setuid)以及 int_arg(请求使用的 GID 或 UID)。这里参数 0 对应 root 身份。
结果边界:这份策略没有开启返回值采集;看到调用参数为 0,只表示尝试设置该值,不能证明设置成功或发生了提权。示例中的进程元数据本来就显示 uid: 0,更不能把该输出描述为“从普通用户成功变成 root”。
移除此策略:
kubectl delete -f process.credentials.changes.at.syscalls.yaml
把三类事件关联起来
译注:三个原文用例使用不同演示进程,不能将它们拼接成同一个进程已经执行全部行为的事实。实际审计时,可以从 JSON 中的 exec_id、parent_exec_id、节点名、时间、Pod 与容器 ID 建立关联,并保留进程树。不要只按 PID 合并,因为 PID 会复用;同一 Pod 中也可能有多个互不相同的进程。
这里采用单节点实验边界,是为了避免 kubectl exec ds/tetragon 选择某个节点代理后遗漏其他节点事件。多节点环境应按实际拓扑收集每个相关节点的数据,核对策略加载状态及观测范围。文件路径漏检、网络协议边界与凭据调用不含成功结果,都必须进入审计结论。
清理时只删除本次创建的策略和实验资源。若本次专门新建了官方演示负载,确认没有共享依赖后,可按相同版本清单移除它:
kubectl delete -f https://raw.githubusercontent.com/cilium/cilium/v1.15.3/examples/minikube/http-sw-app.yaml
这条最后的演示应用清理命令是译注补充,会删除清单中的 Service、Deployment 和 Pod,不应对别人的现存演示环境使用。
来源、许可与验证记录
三篇上游网页分别为 文件访问、网络可观测性及 系统调用层凭据变化。网页页脚为 © 2024 The Tetragon Authors. All rights reserved. 本文保留该权利声明;项目代码许可不被用于推定网页转载权。
本文复制的 YAML 来自 Tetragon v1.7.0,项目根目录 LICENSE 为 Apache License 2.0,完整许可文本见文末。该代码许可与上面的网页版权声明分别记录。
2026-10-05 译编修改:合并三篇、固定策略到 v1.7.0、改为下载检查后应用同一文件、补全新版 truncate 策略、保留原始输出并解释实际 YAML 与历史页面差异。未运行 Kubernetes、容器、eBPF、文件修改或身份切换命令;没有声称本次实验成功。
示例代码许可证
随示例代码保留项目版权与许可通知。来源:官方 LICENSE。代码许可与本文其他素材的权利分别适用。
许可全文
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} Authors of Cilium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.












暂无评论内容