Paper Files / Containers
CONTAINERSHIELD: A Formal and Empirical Framework for Threat Detection and Mitigation in Container Environments Based on Multilayer Telemetry
TITLE: CONTAINERSHIELD: A Formal and Empirical Framework for Threat Detection and Mitigation in Container Environments Based on Multilayer Telemetry ABSTRACT: The massive adoption of containers, driven by platforms such as Docker and Kubernetes, has transformed distributed system architecture, but it has introduced a complex and highly dynamic attack surface. Vulnerabilities in images, inadequate namespace and kernel capability configurations, as well as escape and lateral movement attacks, have been systematically exploited, as evidenced by recent CVEs (e.g., CVE-2019-5736, CVE-2022-0492). In this work, we propose CONTAINERSHIELD, a formal and empirical framework for threat detection and mitigation in container environments, based on the correlation of multilayer telemetry (kernel, runtime, and orchestrator). We formally model the environment as a labeled transition system and define security properties expressed in terms of isolation, integrity, and capability confinement. We developed two core algorithms: (i) a detection mechanism based on probabilistic behavior modeling via variable-order Markov chains and (ii) a policy verification module that applies dynamic Linux capability restrictions and seccomp profiles. We implemented the system on Kubernetes 1.28 with eBPF and evaluated it in a 48-node cluster (768 vCPUs). Using real workloads and 27 attack scenarios mapped to MITRE ATT&CK for Containers, we achieved a detection rate of 96.4% (±1.8%), with a false positive rate of 2.1% and an average CPU overhead of 3.7%. Compared to tools such as Falco and Aqua Security in their default configuration, our method reduced false positives by 38% and improved mean detection time by 24%. We demonstrate that the formal integration of threat modeling and real-time telemetry provides more robust guarantees of operational security. CONTAINERSHIELD contributes to the rigorous systematization of container security, offering a scalable and verifiable path for protection in cloud-native environments.
- Introduction
Lightweight virtualization through containers has consolidated itself as the dominant paradigm in cloud computing, enabling application isolation through Linux kernel namespaces and cgroups. Unlike traditional virtual machines, containers share the same kernel, which reduces overhead but expands the shared attack surface. This structural characteristic makes the security model inherently dependent on operating system isolation mechanisms, whose misconfiguration or exploitation can compromise multiple workloads simultaneously.
Recent incidents underscore the criticality of the problem. The CVE-2019-5736 vulnerability enabled container escape through manipulation of the runc runtime, allowing overwriting of the host binary. Similarly, CVE-2022-0492 exploited deficiencies in cgroups configuration to obtain privileged execution. Campaigns such as TeamTNT exploited misconfigured Kubernetes environments for cryptocurrency mining, employing techniques mapped to MITRE ATT&CK, such as T1611 (Escape to Host) and T1610 (Deploy Container). Reports from Red Hat and Sysdig (2023) indicate that more than 60% of images in public registries contain known critical vulnerabilities.
Despite the proliferation of security tools — including image scanners, runtime security systems, and admission controllers — conceptual fragmentation and the absence of unified formalization of the problem can be observed. Most solutions adopt signature-based or heuristic rule-based approaches, without formal modeling of the desired security properties.
We therefore formulate the following research questions:
RQ1: How can security properties in container environments be formalized in a verifiable and measurable way?
RQ2: Is it possible to combine multi-layer telemetry to significantly improve attack detection rates compared to one-dimensional approaches?
RQ3: What is the impact of dynamic mitigation mechanisms based on formal policies on the operational performance of large-scale clusters?
Our main contributions are:
C1: A formal model of the container environment as a labeled transition system with mathematically expressed isolation and integrity properties.
C2: A probabilistic detection mechanism based on variable-order Markov chains fed by eBPF telemetry.
C3: A scalable implementation integrated with Kubernetes, with large-scale empirical evaluation demonstrating significant quantitative gains.
The rest of the paper is organized as follows: Section 2 discusses background and related work; Section 3 presents the threat model; Section 4 describes the proposed methodology; Section 5 details the implementation; Section 6 presents the experimental evaluation; Section 7 discusses implications and limitations; and Section 8 concludes the work.
- Background and Related Work
Containers are based on fundamental Linux kernel mechanisms: namespaces $N = {pid, net, ipc, mnt, uts, user}$ and cgroups $C$ that impose resource constraints. Formally, a container can be defined as a tuple:
$$ \mathcal{K} = (P, N, C, I, \Pi) $$
where $P$ represents the set of processes, $I$ the base image, and $\Pi$ the set of applied policies (seccomp, AppArmor, SELinux).
Previous work can be classified into three main categories:
(i) Static image analysis: tools such as Clair and Trivy analyze dependencies and known CVEs.
(ii) Runtime monitoring: Falco uses syscall-based rules; Sysdig Secure applies behavioral detection.
(iii) Admission policies and hardened isolation: PodSecurityPolicies, OPA/Gatekeeper, and gVisor.
From a mathematical perspective, behavioral detection can be modeled as a classification problem over sequences $S = (s_1, s_2, …, s_n)$ of system events. Prior approaches employ first-order Markov models, assuming:
$$ P(s_{i} | s_{i-1}) $$
However, such models ignore higher-order dependencies and orchestrator semantic context.
Recurring limitations include:
- High false-positive rates due to the ephemeral nature of containers.
- Lack of integration across layers (kernel and control plane).
- Absence of explicit formalization of security properties.
Our approach overcomes these limitations by integrating formal modeling and contextualized telemetry.
- Threat Model and Problem Formalization
We assume an adversary capable of:
(a) Deploying malicious containers via exploitation of compromised credentials.
(b) Exploiting vulnerabilities in the runtime or kernel.
© Performing lateral movement between pods.
We denote the global system as a directed graph $G = (V, E)$, where $V$ represents containers and $E$ communication links.
We define strong isolation property as:
$$ \forall v_i, v_j \in V, ; i \neq j \Rightarrow \neg \text{write}(v_i \rightarrow host \rightarrow v_j) $$
The problem consists of detecting sequences of events $S$ such that:
$$ P(S | \theta_{normal}) < \epsilon $$
where $\theta_{normal}$ represents the legitimate behavior model and $\epsilon$ is an adaptive threshold.
- Proposed Methodology
Our architecture consists of three modules: (1) eBPF Collector, (2) Probabilistic Modeling Engine, (3) Mitigation Engine.
Algorithm 1: Behavioral Model Training
Input: Syscall sequences S
Output: Model M
1: Initialize counters C_k for k-grams
2: For each sequence S:
3: For i = 1 to |S|-k:
4: C_k[S_i...S_{i+k}]++
5: Estimate probabilities P using Laplace smoothing
6: Return M
Algorithm 2: Online Detection
Input: Event e_t, Model M
Output: Alert or Normal
1: Update window W
2: Compute P(W | M)
3: If P < ε then
4: Emit alert
5: Apply restrictive policy
Complexity: Training $O(nk)$; online detection $O(k)$ per event.
- Implementation
We implemented the collector with eBPF coupled to kernel 5.15, exporting events via perf buffers. The backend uses Apache Kafka for streaming and Redis for temporary storage. The mitigation module integrates with the Kubernetes Admission Controller and CRI-O.
We chose eBPF due to its low overhead (<2%) compared to ptrace (>15%). The experimental cluster contains 48 nodes, each with 16 vCPUs and 64GB RAM.
- Experimental Evaluation
Scenarios include escape, privilege escalation, and exfiltration attacks. Metrics: detection rate (TPR), false positive rate (FPR), mean time to detection (MTTD).
Aggregated results:
- TPR: 96.4% (±1.8%)
- FPR: 2.1% (±0.6%)
- MTTD: 1.3 s (vs. 1.7 s in Falco)
- CPU overhead: 3.7%
- Memory overhead: 4.2%
In T1611 attacks, detection reached 98.2%. Comparatively, Falco presented an FPR of 3.4%.
- Discussion
The results demonstrate that variable-order modeling captures contextual dependencies ignored by simplistic approaches. The reduction in false positives is particularly relevant in high-turnover CI/CD environments.
Limitations include dependence on an initial training phase and potential evasion through low-and-slow attacks.
- Conclusion and Future Work
We presented CONTAINERSHIELD, a formal and empirical framework for container security. We demonstrated substantial quantitative gains in detection and false-positive reduction with minimal overhead.
Future work includes integration with federated learning across clusters and formal verification via model checking.
- References
[1] P. Barham et al., “Xen and the Art of Virtualization,” SOSP, 2003.
[2] J. Merkel, “Docker: Lightweight Linux Containers,” Linux J., 2014.
[3] NIST SP 800-190, “Application Container Security Guide,” 2017.
[4] MITRE ATT&CK for Containers, 2023.
[5] A. Kivity et al., “kvm: the Linux Virtual Machine Monitor,” OLS, 2007.
[6] L. Torvalds, “Linux Kernel Documentation,” 2022.
[7] Sysdig, “2023 Cloud-Native Security Report.”
[8] Red Hat, “State of Kubernetes Security,” 2023.
[9] A. Madhavapeddy et al., “Unikernels,” ASPLOS, 2013.
[10] B. Burns et al., “Borg, Omega, and Kubernetes,” ACM Queue, 2016.
[11] CNCF, “Kubernetes Documentation,” 2024.
[12] Aqua Security, “Container Security Report,” 2023.
[13] D. Walsh, “SELinux and Containers,” Red Hat Summit, 2017.
[14] J. Corbet, “Namespaces in Operation,” LWN.net, 2013.
[15] S. Quinlan, “AppArmor,” USENIX, 2006.
[16] Falco Project Documentation, 2024.
[17] C. Kocher et al., “Spectre Attacks,” IEEE S&P, 2019.
[18] D. Borkmann, “eBPF and XDP,” Linux Plumbers, 2018.
[19] Google, “gVisor Documentation,” 2024.
[20] Open Policy Agent Documentation, 2024.