Comprehensive VPS Security Using eBPF and Tetragon to Detect Early Privilege Escalation in Docker Containers
A technical guide on comprehensive VPS security using eBPF and Tetragon to detect early privilege escalation behavior in Docker containers, with real configuration and validation steps.
Image credit: analogicus · Pixabay Content License
Introduction
In virtual private server (VPS) environments, Docker containers are a common solution for deploying applications. However, when a container is compromised, attackers can perform privilege escalation to gain full system control. To detect such behavior early, eBPF technology and Tetragon monitoring software provide a deep security layer, executing directly in the kernel without affecting performance.
This guide explains how to implement comprehensive VPS security by integrating eBPF and Tetragon to detect early privilege escalation in Docker containers. The guide includes configuration, testing, and validation steps.
Prerequisites
- VPS server running Linux (Ubuntu 22.04 or CentOS 8+)
- Kernel supporting eBPF (minimum 5.10)
- Docker and Docker Compose installed
- Root or sudo privileges
- Git to clone the repository
Deploying Tetragon with eBPF
Tetragon is an eBPF-based system monitoring tool that detects abnormal behaviors such as process creation, file access, network connections, and especially privilege escalation. Below are the steps to deploy it:
1. Install Tetragon
Run the following commands to install Tetragon from the official repository:
git clone https://github.com/cilium/tetragon.git
cd tetragon
make build
sudo make install
2. Configure and Start
Tetragon requires configuration to monitor Docker-related events. Create a configuration file at /etc/tetragon/tetragon.yaml:
apiVersion: v1
kind: Config
spec:
policy:
- name: "Privilege Escalation Detection"
description: "Detect privilege escalation in Docker containers"
rules:
- action: "log"
event:
- "exec"
condition:
- "container"
- "uid == 0"
- "pid != 1"
Start Tetragon:
sudo tetragon --config /etc/tetragon/tetragon.yaml
Detecting Privilege Escalation Behavior
To test the setup, create a Docker container with root privileges and attempt to escalate privileges using sudo or su:
1. Create a Container
docker run -it --name test-container ubuntu:22.04 /bin/bash
2. Perform Privilege Escalation
Inside the container, run:
sudo su
If configured correctly, Tetragon will log the event:
2024-05-20T10:00:00Z [INFO] Privilege escalation detected: container_id=abc123, pid=456, user=root, command=sudo su
Verification and Troubleshooting
1. Check Tetragon Logs
Run the following command to view detection logs:
sudo journalctl -u tetragon.service -f
2. Verify eBPF Programs
Ensure eBPF programs are loaded correctly:
sudo bpftool prog list
3. Troubleshooting
- If Tetragon fails to start: verify kernel supports eBPF, update kernel if needed.
- If no logs appear: check policy configuration, ensure rule conditions are correct.
- If performance drops: optimize policies, monitor only critical containers.
References
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
