The Policy Library provides structured examples of Tetragon policies paired with relevant use cases. You can explore all documented policies, along with additional examples, in the policy library directory on Github.
For further community-maintained policy examples, refer to the policy examples directory on GitHub. These examples are valid policies provided by the community but they are not curated in terms of suitability for specific use cases or best practices.
1 - Tetragon Observability Policies
Library of policies that implement Tetragon observability mechanisms.
Monitor execution of a binary in the /tmp directory.
Use Case
Preventing execution of executables in /tmp is a common best-practice as several canned exploits rely on writing and then executing malicious binaries in the /tmp directory. A common best-practice to enforce this is to mount the /tmp filesystem with the noexec flag. This observability policy is used to monitor for violations of this best practice.
Policy
No policy needs to be loaded, standard process execution observability is sufficient.
The “Set User Identity” and “Set Group Identity” are permission flags. When set on a binary file, the binary will execute with the permissions
of the owner or group associated with the executable file, rather than the user executing it. Usually it is used to run programs with elevated privileges to perform specific tasks.
Detecting the execution of setuid and setgid binaries is a common
best-practice as attackers may abuse such binaries, or even create them
during an exploit for subsequent execution.
Requirement
Tetragon must run with the Process Credentials visibility enabled, please
refer to Enable Process Credentials documentation.
Policy
No policy needs to be loaded, standard process execution observability is sufficient.
Privileges Escalation via File Capabilities Execution
Description
Monitor execution of binaries with file capabilities.
Use Case
File capabilities allow the binary execution to acquire more privileges
to perform specific tasks. They are stored in the extended attribute part
of the binary on the file system. They can be set using the
setcap tool.
For further reference, please check capabilities
man page; section File capabilities.
Detecting the execution of file capabilities binaries is a common
best-practice, since they cross privilege boundaries which make them a suitable
target for attackers. Such binaries are also used by attackers to hide their
privileges after a successful exploit.
Requirement
Tetragon must run with the Process Credentials visibility enabled, please
refer to Enable Process Credentials
documentation.
Policy
No policy needs to be loaded, standard process execution observability is sufficient.
User namespaces isolate security-related identifiers like user IDs, group IDs
credentials and
capabilities.
A process can have a normal unprivileged user ID outside a user namespace
while at the same time having a privileged user ID 0 (root) inside its own
user namespace.
When an unprivileged process creates a new user namespace beside having a
privileged user ID, it will also receive the full set of capabilities. User
namespaces are feature to replace setuid and setgid binaries, and to allow
applications to create sandboxes. However, they expose lot of kernel
interfaces that are normally restricted to privileged (root). Such interfaces
may increase the attack surface and get abused by attackers in order to
perform privileges escalation exploits.
Unfortunatly, a report from Google
shows up that 44% of the exploits required unprivileged user namespaces to
perform chain privileges escalation. Therfore, detecting the creation of user
namespaces by unprivileged is a common best-practice to identify such cases.
Detecting capset()
calls that set the effective, inheritable and permitted capabilities to non
zero is a common best-practice to identify processes that could raise their
privileges.
Monitor the execution of binaries that exist exclusively as a computer
memory-based artifact.
Use Case
Often attackers execute fileless binaries that reside only in memory
rather than on the file system to cover their traces. On Linux this
is possible with the help of memfd_create()
and shared memory
anonymous files. Therefore, detecting execution of such binaries that
live only in RAM or backed by volatile storage is a common best-practice.
Requirement
Tetragon must run with the Process Credentials visibility enabled, please
refer to Enable Process Credentials
documentation.
Policy
No policy needs to be loaded, standard process execution observability is
sufficient.
Demo to reproduce
You can use the exec-memfd.py
python script as an example which will copy the binary /bin/true into
an anonymous memory then execute it. The binary will not be linked on the
file system.
The output shows that the executed binary refers to a file descriptor
/proc/self/fd/3 that it is not linked on the file system.
The binary_properties
includes an inode
with zero links on the file system.
Execution of Deleted Binaries
Description
Monitor the execution of deleted binaries.
Use Case
Malicious actors may open a binary, delete it from the file system to hide
their traces then execute it. Detecting such executions is a good pratice.
Requirement
Tetragon must run with the Process Credentials visibility enabled, please
refer to Enable Process Credentials
documentation.
Policy
No policy needs to be loaded, standard process execution observability is
sufficient.
The output shows that the executed binary refers to a file descriptor
/proc/self/fd/14 that it is not linked on the file system.
The binary_properties
includes an inode
with zero links on the file system.
eBPF Subsystem Interactions
Description
Audit BPF program loads and BPFFS interactions
Use Case
Understanding BPF programs loaded in a cluster and interactions between applications
and programs can identify bugs and malicious or unexpected BPF activity.
"2023-11-01T02:56:54.926403604Z /usr/bin/bpftool prog list programType:BPF_PROG_TYPE_SOCKET_FILTER programInsn:2"
Kernel Module Audit Trail
Description
Audit loading of kernel modules
Use Case
Understanding exactly what kernel modules are running in the cluster is crucial to understand attack surface and any malicious actors loading unexpected modules.
Understanding the exact versions of shared libraries that binaries load and use is crucial to understand use of vulnerable or deprecated library versions or attacks such as shared library hijacking.