Skip to content

Rules

Every rule Tephra ships, generated from rules/. Each one is tested on recorded events it must and must not fire on. Click a rule for its description and known false positives.

R001 Shell with a network socket as stdin and stdout high

An interactive shell wired to a socket is the shape of a reverse or bind shell. The image is the binary that actually runs, so a shell started through a script still matches. A shell is recognised by its name or by its content, so a copy under another name (E01), or busybox running its sh applet under any name (E09), is still a shell.

Event
exec
ATT&CK
Execution · T1059.004
False positives
  • Remote-exec tooling that attaches shells over raw sockets
Source
rules/R001-shell-with-socket-stdio.yaml
R002 Shell spawned under a network-facing server process medium

A shell anywhere below a server process in the process tree usually means the server was made to run a command. The shell is recognised by its name or by its content.

Event
exec
ATT&CK
Execution · T1059.004
False positives
  • Applications that shell out on purpose (build tools, npm scripts, subprocess calls with shell=True)
  • Container entrypoint scripts that start the server and are then re-entered
Source
rules/R002-shell-under-server.yaml
R003 Execution of a memfd or already-unlinked binary high blocks

The binary has no name on disk: it was run from an anonymous memory file or deleted before it was executed. Both leave nothing for a file scanner to find.

Event
exec
ATT&CK
Defense evasion · T1620
False positives
  • Container runtimes that re-execute themselves through a file descriptor. runc does so for every container start and every exec into a container. It is recognised by the identity of the node's runc binary (runtime_binaries in the agent configuration), not by a name or a command line, so a process in a container cannot pass for it
  • Self-updating programs that replace and delete their own binary
Source
rules/R003-fileless-exec.yaml
R004 Download or package tool run in a container low

Containers are built once and run unchanged. Fetching files or installing packages in a running one is how tools are brought in after a compromise. curl, wget and the like are also recognised by content, under any name.

Event
exec
ATT&CK
Command and control · T1105
False positives
  • Health checks and init scripts that call curl or wget
  • Images that install or query packages at start-up; the official nginx image's entrypoint runs "apk manifest nginx"
Source
rules/R004-download-tool-in-container.yaml
R005 /etc/shadow opened by a process outside the allowlist high

The password hash file was opened by something that is not part of login or account management. The file is watched by identity as well as by path, so a hard link to it under another name is still reported. The programs allowed by path are allowed only as the image shipped them.

Event
file_open
ATT&CK
Credential access · T1003.008
False positives
  • Backup and configuration-management agents that read all of /etc
  • Image builders other than kaniko, which is allowed by path, unpacking a base image. The false-positive run in docs/coverage.md found this one
Source
rules/R005-shadow-read.yaml
R006 Service account token read by a process other than the pod's main binary medium

The workload itself reads its token to talk to the API. Any other process reading it, such as a shell, cat or dd, is collecting a credential. The token is known from the pod spec, not by its path: a token projected at a custom path or under another name (E17, E22), reached through /proc/<pid>/root, or read from the node's side of the volume under /var/lib/kubelet (E27) is the same file. A pod's main binary reading another pod's token is not left out. The kubelet, which writes and checks the tokens, is.

Event
file_open
ATT&CK
Credential access · T1528
False positives
  • Sidecar-style helper processes started by the main binary that use the API themselves
  • Node agents that read other pods' volumes from the kubelet's directory
Source
rules/R006-service-account-token-read.yaml
R007 Write to /etc/ld.so.preload high blocks

A library named in this file is loaded into every dynamically linked program that starts afterwards.

Event
file_open
ATT&CK
Persistence · T1574.006
False positives
  • Rare. Some profiling and sandboxing tools install themselves this way
Source
rules/R007-ld-so-preload-write.yaml
R008 Write under a cron directory medium

A new or changed cron entry runs a command on a schedule, surviving restarts of the process that planted it.

Event
file_open
ATT&CK
Persistence · T1053.003
False positives
  • Package installation and configuration management
  • Users editing their own crontab
Source
rules/R008-cron-write.yaml
R009 Write to an authorized_keys file high

A key added here gives its owner SSH access as that user. The file is matched by name, wherever the home directory is.

Event
file_open
ATT&CK
Persistence · T1098.004
False positives
  • Provisioning tools (cloud-init, configuration management) writing keys
Source
rules/R009-authorized-keys-write.yaml
R010 Connection to the container runtime's Unix socket from inside a container critical

Whoever can talk to the runtime socket can start a privileged container with the node's filesystem mounted, which is full control of the node.

Event
connect
ATT&CK
Privilege escalation · T1611
False positives
  • Monitoring and CI agents that are deliberately given the runtime socket
Source
rules/R010-container-runtime-socket.yaml
R011 Write to a cgroup release_agent or to core_pattern critical blocks

Both files name a program that the kernel runs on the host, as root, outside every container. Writing them from a container is a known escape. They are matched by name because the attacker chooses where to mount the filesystem that holds them.

Event
file_open
ATT&CK
Privilege escalation · T1611
False positives
  • Crash-reporting services setting core_pattern at boot
Source
rules/R011-release-agent-core-pattern-write.yaml
R012 Shell history truncated low

The history file was opened for truncation, which empties it. Deleting the file or replacing it is reported by R022.

Event
file_open
ATT&CK
Defense evasion · T1070.003
False positives
  • A shell rewriting its whole history on exit, which bash does when the session added more lines than the file holds
Source
rules/R012-shell-history-truncated.yaml
R013 Connection to the Kubernetes API from an unexpected binary medium

A pod's own program may use the API. A different binary in the same container doing so, such as curl or kubectl, is someone exploring the cluster with the pod's credentials.

Event
connect
ATT&CK
Discovery · T1613
False positives
  • Helper processes of operators and controllers that call the API themselves
Source
rules/R013-kubernetes-api-unexpected-binary.yaml
R014 Outbound connection to a common mining-pool port low

Stratum mining pools listen on a small set of well-known ports.

Event
connect
ATT&CK
Impact · T1496
False positives
  • Any other service that happens to use one of these ports
Source
rules/R014-mining-pool-port.yaml
R015 Attach-level access to another process high blocks

A process in a container asked the kernel for attach-level access to another process: ptrace attach, or reading and writing its memory. That is how code is injected into a running process and how secrets are read out of one. Access to the Tephra agent also raises R033, critical, from anywhere.

Event
ptrace
ATT&CK
Defense evasion · T1055.008
False positives
  • Debuggers, profilers and crash handlers run on purpose in a container
Source
rules/R015-ptrace-attach.yaml
R016 Kernel module loaded while a container process is current critical blocks

A kernel module runs with the kernel's privileges on the whole node. A container that can load one has left its isolation behind.

Event
module_load
ATT&CK
Persistence · T1547.006
False positives
  • Privileged system containers that manage node drivers (GPU or storage driver installers)
Source
rules/R016-module-load-from-container.yaml
R017 mount called from inside a container high blocks

An ordinary container cannot mount anything. One that does is privileged, and a mount is the usual first step to reaching the node's filesystem.

Event
mount
ATT&CK
Privilege escalation · T1611
False positives
  • The container runtime setting up a container's own filesystem; the runtime is recognised by the identity of its binary on the node
  • Privileged storage and CSI driver pods
Source
rules/R017-mount-in-container.yaml
R018 Process entered one of the node's own namespaces critical

A process that belongs to a pod switched into a namespace of the node itself, as nsenter does. From there it sees the node's processes, network or filesystem as if it were not in a container.

Event
setns
ATT&CK
Privilege escalation · T1611
False positives
  • Privileged node-maintenance pods that use nsenter by design
Source
rules/R018-setns-into-host-namespace.yaml
R019 Process became root without running a setuid binary critical

The legitimate way for an unprivileged process to become root is to execute a setuid binary, which changes credentials as part of the exec. An effective uid that goes from non-zero to zero outside an exec is what a kernel privilege-escalation exploit produces.

Event
cred_change
ATT&CK
Privilege escalation · T1068
False positives
  • None known. A process that kept a saved uid of 0 and switches back to it changes euid this way; such programs are rare and worth knowing about
Source
rules/R019-uid-zero-without-setuid.yaml
R020 BPF program loaded by something other than the sensor high

BPF programs can observe and change what the kernel does, including what this sensor sees. The sensor's own programs are not reported. Loads by the container runtime and by systemd on the host, which use BPF for device and network control of cgroups, are filtered; both are recognised by the identity of their binaries on the node.

Event
bpf_load
ATT&CK
Defense evasion · T1562.001
False positives
  • Other BPF-based tools installed on purpose (CNI plugins, profilers, other security agents)
Source
rules/R020-bpf-program-loaded.yaml
R021 Program started in a container with a dynamic loader override medium

These variables make the dynamic loader run code from a library the caller chooses. Only these three names are ever read from the environment. An environment too long to scan to its end is reported too, so that padding it does not hide the variable.

Event
exec
ATT&CK
Persistence · T1574.006
False positives
  • Images that set LD_LIBRARY_PATH for bundled libraries (JVMs, GPU runtimes)
  • Containers with several hundred environment variables
Source
rules/R021-dynamic-loader-environment.yaml
R022 Shell history removed or replaced low

The history file was deleted, renamed away, replaced by another file or by a link (to /dev/null, usually), or cut short with truncate. None of these opens the file, so R012 does not see them.

Event
file_change
ATT&CK
Defense evasion · T1070.003
False positives
  • Image builds and clean-up scripts that delete history files on purpose
Source
rules/R022-shell-history-removed.yaml
R023 Sensitive file put in place without being opened high

A file was moved or linked onto one of the names that R007, R008 and R009 watch for writes. Writing a file elsewhere and renaming it into place gives the same result as writing it there, without ever opening the watched name.

Event
file_change
ATT&CK
Persistence · T1574.006
False positives
  • Package managers and configuration management, which replace files by renaming a temporary file into place
  • crontab(1), which installs a user's table the same way
Source
rules/R023-sensitive-file-replaced.yaml
R024 Refused attempt to open a sensitive file medium

A process in a container tried to open one of these files and the kernel said no: wrong user, a read-only filesystem, or a security module. The attempt failed, but it is what someone looking for a way up tries first. The name is compared as text after "." and ".." are removed; a symbolic link in it is not followed.

Event
file_denied
ATT&CK
Credential access · T1003.008
False positives
  • Programs that probe for files they may not read and carry on, such as some PAM-aware tools run as a non-root user
  • Containers with a read-only root filesystem whose entrypoint tries to edit these files
Source
rules/R024-sensitive-file-denied.yaml
R025 File fetched into a container and then executed high

A file-transfer tool ran in a pod and, within a minute, the pod executed a file that was written or made executable after that. Either step alone is common; a container that fetches a file and runs it is installing something it was not built with. The second step looks at the file that was asked for, so a fetched script is recognised although the kernel runs its interpreter.

Event
sequence
ATT&CK
Command and control, Execution · T1105, T1059
False positives
  • Entrypoints that fetch a binary or script at start-up and run it
  • Build or CI pods whose steps download a tool and run it
Source
rules/R025-download-then-execute.yaml
R026 Service account token read, then the Kubernetes API contacted high

A process other than the pod's main binary read the service account token and, within a minute, a process other than the main binary in the same pod connected to the Kubernetes API. R006 and R013 report each half; together they are the shape of a stolen token being used.

Event
sequence
ATT&CK
Credential access, Discovery · T1528, T1613
False positives
  • Sidecars or helper scripts that talk to the API with the pod's own token
Source
rules/R026-token-then-api.yaml
R027 Program started with a network socket as stdin and stdout medium

A program in a container was started with a socket on both stdin and stdout, whatever the program is. That is how a remote party drives an interactive program: a reverse or bind shell, or an interpreter or a custom binary standing in for one. R001 is the high-level case of a recognised shell; this rule covers what is not recognised, by behaviour rather than by name or content. The container's own main binary is left out, since a socket-activated server is started this way.

Event
exec
ATT&CK
Execution, Command and control · T1059, T1571
False positives
  • inetd-style services that run a program per connection, rare in containers
  • Debug sidecars that attach a program to a socket on purpose
Source
rules/R027-socket-stdio-exec.yaml
R028 Interpreter that is not the container's application connects out medium

A script interpreter (Python, Perl, Ruby, Node and the like) made a network connection, and it is not the program the container runs. An interpreter can hold a whole remote session by itself, reading commands from a socket and running them in its own process, so no shell or other program is ever started (E02, E12). The container's application is left out, as is an interpreter started directly by the container's first process, which is how entrypoint scripts run their workers. An attacker who enters with kubectl exec or through the application hangs below the runtime or the application instead.

Event
connect
ATT&CK
Command and control, Execution · T1059.006, T1071
False positives
  • Maintenance scripts run by hand with kubectl exec that use the network
  • Sidecar-less containers whose entrypoint starts a helper interpreter from a nested script rather than directly
Source
rules/R028-interpreter-connects-out.yaml
R029 Program started on a terminal that an interpreter created medium

A program in a container was started with a pseudo-terminal on stdin and stdout, by a script interpreter that is not the container's application. That is how a relay upgrades a raw connection to a full interactive shell (Python's pty.spawn, Perl's IO::Pty): the shell sees a terminal, not the socket, so the rules on socket stdio do not apply (E13). A terminal given by kubectl exec -t comes from the runtime, and one given by a notebook server comes from the application; neither fires.

Event
exec
ATT&CK
Execution, Command and control · T1059, T1572
False positives
  • Interactive tools run by hand inside a kubectl exec session, such as a Python REPL that starts a shell
Source
rules/R029-interpreter-gives-a-terminal.yaml
R030 Signal sent to the Tephra agent critical

A process sent a signal to the Tephra agent: to kill it (E07), freeze it while something else happens and kill it before it wakes (E14), or stop it. Kubernetes stops the agent through the container runtime, and a node that shuts down through its first process; both are recognised by the identity of the file, so a rollout, upgrade, uninstall or drain does not fire. A signal to the agent always produces this alert. The kernel records it before delivering it, so even a SIGKILL leaves the record, in a tamper buffer of its own that a flood of other events cannot fill (E19, E23). The kernel also keeps the last signals in a pinned table until an agent has handled them, so a record the dying agent read but never handled is raised by the next agent, sender included. Only thousands of signals to the agent can push one out of both; each one then is counted in the kernel and still raises this alert, with signal.lost set and no sender, while the signals that pushed it out name who sent them. The same signal can be raised twice when an agent dies within seconds of handling it. SIGHUP only makes the agent re-read files it is given through ConfigMaps, and is not reported.

Event
signal
ATT&CK
Defense evasion · T1562.001
False positives
  • An administrator signalling the agent by hand from the node instead of through Kubernetes
Source
rules/R030-signal-to-agent.yaml
R032 Program executed that was not in the container's image medium

A container executed a file that was written, replaced or made executable after the container started, so it is not something its image shipped. Containers are built once and run what they were built with; a new executable is how a dropped tool, a downloaded payload or a renamed copy of a shell gets run, whatever it is called and however it got there. For a script the file judged is the script, not its interpreter.

Event
exec
ATT&CK
Execution, Defense evasion · T1059, T1036
False positives
  • Build and CI pods, which compile programs and run them
  • Entrypoints that generate a script at start-up and run it a while later
  • Scripts in ConfigMap volumes that are updated while the pod runs
Source
rules/R032-exec-not-in-image.yaml
R033 Attach-level access to the Tephra agent critical

A process asked the kernel for attach-level access to the Tephra agent: ptrace attach, or reading or writing its memory through /proc/<pid>/mem or process_vm_writev. The agent's own process is the one thing the sensor does not report, so code injected into it would act unseen. The kernel reports the request before it is granted, into the tamper buffer that a flood of other events cannot fill, and keeps it in a pinned table until an agent has handled it, as for R030; a request lost to both is counted and still raises this alert, with ptrace.lost set and no sender. Nothing is exempt, the node included: no routine task debugs the security sensor.

Event
ptrace
ATT&CK
Defense evasion · T1562.001, T1055.008
False positives
  • An administrator debugging or profiling the agent on purpose
Source
rules/R033-access-to-agent.yaml
R034 A pod moved a process into a cgroup high

Writing a process ID into a cgroup.procs or cgroup.threads file moves that process into the cgroup. The container runtime and the node do that when they start containers; a process in a pod does it to take on another container's identity, such as the Tephra agent's (E15, E20) or a bystander's (E26). The file is matched by name, wherever the cgroup filesystem is mounted, and the alert names the pod that made the move.

Event
file_open
ATT&CK
Defense evasion, Privilege escalation · T1036, T1611
False positives
  • Pods that run their own container runtime (Docker in Docker, build tools that start containers)
  • systemd running as a container's first process
Source
rules/R034-cgroup-move.yaml
R035 Program started inside the Tephra agent's container critical

A program started in the agent's own container, found there by cgroup or by mount namespace, that is not the agent. The agent never starts a program, so anything else in its container came in from outside: moved into its cgroup (E15, E20), entered through its namespaces, or started with kubectl exec. The alert names the pod the program came from, where that is known. The agent's own binary run with kubectl exec, which is how an operator turns detection or enforcement off, is left out: it is the container's main binary. Run from another pod through /proc it is not, since the process is then named under the pod it came from.

Event
exec
ATT&CK
Defense evasion · T1562.001, T1036
False positives
  • None expected; the agent image has no shell or other program
Source
rules/R035-stranger-in-agent.yaml
R036 Process entered another pod's namespaces high

A process in a pod switched into a namespace of another pod, as nsenter does. In another container's mount namespace it sees that container's files as its own; in another pod's network namespace it connects out with that pod's address, past network policies meant for its own pod; in another pod's pid namespace it sees and signals that pod's processes. R018 covers the node's own namespaces; this rule covers the other pods'. With a move into the other container's cgroup it is how a process takes on that container's identity (E26).

Event
setns
ATT&CK
Lateral movement, Defense evasion, Privilege escalation · T1036, T1611
False positives
  • Privileged debugging pods that use nsenter on purpose
Source
rules/R036-enter-other-pod.yaml
R037 Interpreter that is not the container's application accepts a connection medium

A script interpreter that is not the program the container runs accepted a connection: a bind session, the other way round from R028. The interpreter listens, the attacker connects in, and commands run inside the interpreter's own process, so no shell is started (E24). Loopback is included, because kubectl port-forward reaches a pod as a connection from 127.0.0.1 inside it. The same processes are left out as in R028: the application itself, an interpreter started directly by the container's first process, the runtime and the node.

Event
accept
ATT&CK
Command and control, Execution · T1059.006, T1571
False positives
  • Debugging servers started by hand with kubectl exec, such as python -m http.server
  • Sidecar-less containers whose entrypoint starts a helper server from a nested script rather than directly
Source
rules/R037-interpreter-accepts.yaml