Block unauthorized outgoing connections for enhanced security.
Project details
Tetragon Outgoing Guard provides kernel-level security policies for Cilium Tetragon, ensuring that only authorized processes can establish outbound connections in Kubernetes or Docker Swarm environments. This tool effectively mitigates risks from stealthy persistent threats and unauthorized access by enforcing strict execution policies.
The Tetragon Outgoing Guard is a security solution tailored for kernel-level runtime protection within the Cilium Tetragon framework. This project effectively prevents stealthy post-exploitation techniques by blocking unauthorized outbound connections from Linux containers in environments like Docker and Kubernetes. With the recent insights into threats like GSocket, which exploit persistent Command and Control (C2) access even after vulnerabilities are patched, Tetragon Outgoing Guard stands out as an essential tool for container security.
The Tetragon Outgoing Guard implements two primary security measures using eBPF TracingPolicy manifests:
Container Executable Allowlisting (security_bprm_check): This feature allows only explicitly defined binary paths to execute within non-host PID namespaces. If an unauthorized binary, including common shells or those in memory-backed directories (/dev/shm), is detected, it is immediately terminated with a synchronous kernel SIGKILL.
Host Outbound TCP Zero-Trust (tcp_connect): This policy ensures that any process in the root host_ns that attempts to initiate a TCP connection to a public IP address (non-RFC1918) is instantly killed, thereby preventing unauthorized external communications from containerized applications.
The repository is organized for ease of navigation and implementation:
tetragon-outgoing-guard/
├── README.md
├── LICENSE
├── policies/
│ ├── standalone-docker.yaml # TracingPolicy for Docker / Swarm / standalone Linux hosts
│ └── kubernetes-workload.yaml # TracingPolicyNamespaced with podSelector for K8s clusters
├── scripts/
│ └── discover-binaries.sh # Helper to extract ground-truth binary paths from running containers
└── examples/
└── docker-compose.tetragon.yml # Deploy Tetragon via Docker Compose or Docker Swarm (global mode)
A recommended approach to implement Tetragon Outgoing Guard includes:
Discovering Allowed Binaries: Utilize the provided discovery script to identify legitimate binaries in running containers.
chmod +x scripts/discover-binaries.sh
sudo ./scripts/discover-binaries.sh
Make sure to document the paths into policies/standalone-docker.yaml.
Testing in Audit Mode: This step helps ensure that no vital workloads trigger the policy before full enforcement.
docker compose -f examples/docker-compose.tetragon.yml up -d
docker exec -it tetragon tetra getevents -o compact
Enforcing Policies: After validating the initial tests, uncomment the enforcement actions in the policies and restart Tetragon to enforce security checks.
Tetragon seamlessly integrates with various Container Network Interfaces (CNI) such as Calico, Flannel, or Cilium. Installation via Helm is straightforward:
helm repo add cilium https://cilium.io
helm repo update
helm install tetragon cilium/tetragon -n kube-system
kubectl apply -f policies/kubernetes-workload.yaml
While the policy actively blocks outbound public TCP connections from the host namespace, it may interrupt package management operations. A shell alias can streamline host updates without disabling the policy:
alias sysupgrade='docker compose -f /path/to/examples/docker-compose.tetragon.yml stop tetragon && sudo apt update && sudo apt upgrade -y; docker compose -f /path/to/examples/docker-compose.tetragon.yml start tetragon'
curl or similar binaries will be terminated unless included in the allowlist.This project is maintained by Daniele Cruciani and is released under the Apache License 2.0, aiming to enhance security measures for containerized applications against advanced threats.
Comments
0Start the conversation
Share the first comment.