Hi,
If I have a pod hosting a running process that is making malicious syscall such as "kill"
, is it possible to identify the pod using seccomp?
Here is how I approached the above scenario:
- Create the following seccomp directory on the node that is hosting the pod
/var/lib/kubelet/seccomp/profiles/
- Create the following custom audit seccomp profile (e.g. audit.json) under the above directory
{
"defaultAction": "SCMP_ACT_LOG"
}
- Edit my deployment to include my seccomp profile under the pod definition
spec:
securityContext:
seccompProfile:
type: Localhost
localhostProfile: profiles/audit.json
- View syscall generated by the process on the host via the following command
grep syscall /var/log/syslog | grep <deployment_name>
Jan 3 22:02:28 cluster1-node1 kernel: [20466.105995] audit: type=1326 audit(1704319348.959:75804): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=105848 comm="collector1-proc" exe="/collector1-process" sig=0 arch=c000003e syscall=281 compat=0 ip=0x45da80 code=0x7ffc0000
Jan 3 22:02:28 cluster1-node1 kernel: [20466.105999] audit: type=1326 audit(1704319348.959:75805): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=105848 comm="collector1-proc" exe="/collector1-process" sig=0 arch=c000003e syscall=35 compat=0 ip=0x45d1bd code=0x7ffc0000
Jan 3 22:02:28 cluster1-node1 kernel: [20466.106903] audit: type=1326 audit(1704319348.963:75806): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=105848 comm="collector1-proc" exe="/collector1-process" sig=0 arch=c000003e syscall=202 compat=0 ip=0x45d863 code=0x7ffc0000
Jan 3 22:02:28 cluster1-node1 kernel: [20466.106906] audit: type=1326 audit(1704319348.963:75807): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=106062 comm="collector1-proc" exe="/collector1-process" sig=0 arch=c000003e syscall=202 compat=0 ip=0x45d863 code=0x7ffc0000
As you can see, I do see various syscall represented by number. However, when I cross reference the syscall number against
grep -w <syscall_number> /usr/include/asm-generic/unistd.h
I don’t see anything related to "kill"
syscall.
Does the above approach make sense? Am I doing something wrong here?
Just for the record, when I review the syscalls made by the process using "strace"
, I do see "kill"
syscall made by the process running on the pod:
strace -p <process_id>
epoll_pwait(3, [], 128, 999, NULL, 1) = 0
kill(666, SIGTERM) = -1 ESRCH (No such process)