← Back to Papers

Paper Files / Containers

A Formal Architecture for Detection and Mitigation of Container Escapes Based on Probabilistic Behavioral Profiles and Kernel-Level Policy Verification

ContainersEN

TITLE: A Formal Architecture for Detection and Mitigation of Container Escapes Based on Probabilistic Behavioral Profiles and Kernel-Level Policy Verification ABSTRACT: Container-based virtualization has become a cornerstone of cloud-native infrastructure, but its reliance on a shared kernel imposes structural security challenges. Container escapes remain critical compromise vectors, especially in large-scale Kubernetes environments, where vulnerabilities in the runtime, the cgroups subsystem, or the kernel itself may result in isolation breaches. In this work, we propose a formal architecture for detecting and mitigating container escapes based on probabilistic modeling of system call sequences and automatic synthesis of kernel-level security policies. We model the legitimate behavior of applications as a probabilistic language over the syscall alphabet, instantiated by variable-order Markov chains with Bayesian smoothing. We derive formal bounds of correctness and completeness under $(\epsilon, \delta)$ parameters and introduce a decision criterion based on accumulated log-likelihood. From the observed empirical support, we automatically synthesize minimal seccomp profiles and policies compatible with modern LSMs (AppArmor or SELinux), quantifiably reducing the attack surface. We implement the architecture using eBPF coupled to Linux 6.x kernel tracepoints, integrating it into a Kubernetes 1.28 cluster with containerd 1.7. In an experimental evaluation involving 120 nodes and 1,800 containers, we obtained an average reduction of 72.4% in the set of permitted syscalls, a detection rate of 96.1%, and an average CPU overhead of 3.7%. We further demonstrate that the approach outperforms mechanisms based exclusively on heuristic rules while maintaining scalability and low latency. We conclude that the combination of formal probabilistic modeling, efficient kernel-level verification, and automatic policy synthesis constitutes a robust strategy for the dynamic hardening of containerized environments in 2025.

  1. Introduction

Container-based virtualization has transformed the engineering of distributed systems by enabling lightweight application isolation with efficiency superior to traditional virtual machines (BARHAM et al., 2003; BURNS; BEDA; HIGHTOWER, 2022). Unlike hypervisor-based architectures, in which each virtual machine encapsulates its own kernel, containers share the host operating system kernel, relying on mechanisms such as namespaces, cgroups, and Linux Security Modules (LSM) to provide logical isolation (NIST, 2017).

Formally, container security depends on preserving isolation properties in the shared kernel $K$. Any exploitable vulnerability in $K$ or in runtime components such as runc or containerd can compromise the host entirely. Widely documented incidents, such as CVE-2019-5736 (NVD, 2019), CVE-2022-0492 (NVD, 2022a), and CVE-2022-0185 (NVD, 2022b), demonstrate the feasibility of container escapes through memory corruption, improper manipulation of cgroups, or replacement of runtime binaries.

Recent industry reports indicate high exposure to vulnerabilities in public images and insecure configurations in Kubernetes clusters (AQUA SECURITY, 2023; PALO ALTO NETWORKS, 2024). At the tactical level, the MITRE ATT&CK for Containers framework documents techniques such as Escape to Host (T1611) and Privileged Container (T1610), modeling recurring vectors (MITRE, 2023). Normative guides such as NIST SP 800-190 (NIST, 2017), the OWASP Docker Security Cheat Sheet (OWASP, 2023), and the CIS Kubernetes Benchmark (CIS, 2023) provide prescriptive recommendations, though predominantly static in nature.

We observe that seccomp profiles and AppArmor policies frequently adopt generic configurations to maintain broad compatibility, resulting in excessive permissiveness (DOCKER, 2024). Thus, the need emerges for formal mechanisms capable of capturing the legitimate behavior specific to each application, enabling both deviation detection and systematic reduction of the attack surface.

We formulate the following research questions:

RQ1: Is it possible to formally model the legitimate behavior of containers with sufficient granularity to detect deviations associated with escapes?

RQ2: Can minimal security policies (seccomp and LSM) be automatically synthesized from these models, reducing the attack surface without compromising functionality?

RQ3: What is the impact of this approach in terms of performance, scalability, and error rates in large-scale Kubernetes environments?

Our contributions are: (C1) a formal model based on variable-order Markov chains to represent syscall sequences as a probabilistic language; (C2) a mechanism for automatic synthesis of minimal policies derived from the empirical support of the estimated distributions; and (C3) an architecture implemented with eBPF for real-time monitoring and incremental verification in the kernel.

  1. Background and Related Work

2.1 Foundations of Container Isolation

We formally define a container as the tuple $C = (P, N, G, F)$, where $P$ is the set of processes, $N$ the set of namespaces, $G$ the applied cgroups, and $F$ the isolated root filesystem. All containers share the same kernel $K$, such that the global attack surface can be modeled as:

$$ S = \bigcup_{i=1}^{m} S_i, $$

where $S_i \subseteq \Sigma$ is the set of syscalls accessible to container $i$ and $\Sigma$ is the total alphabet of syscalls exported by $K$.

2.2 Literature Classification

Category Examples Limitations
Static hardening seccomp, AppArmor, SELinux, Pod Security Standards Manual configuration and excessive permissiveness
Image analysis Trivy, Clair Does not model runtime behavior
Rule-based monitoring Falco Dependence on signatures and continuous maintenance
Behavioral modeling Forrest et al. (1996); Chen et al. (2021) Limited integration with formal policy synthesis

Forrest et al. (1996) introduced detection based on short sequences of syscalls. Subsequent work explored probabilistic learning and automatic policy generation (CHEN et al., 2021). However, a gap remains in the integration between formal probabilistic modeling, automatic synthesis of minimal policies, and efficient in-kernel verification via eBPF (LINUX FOUNDATION, 2024).

  1. Threat Model and Problem Formalization

We assume an adversary capable of executing arbitrary code within a compromised container, exploiting known vulnerabilities in the runtime or kernel, and performing lateral movement on the same node. We do not assume prior compromise of the kernel.

Let $\Sigma$ be the set of syscalls. An execution is modeled as $X = (x_1, \dots, x_n)$ with $x_i \in \Sigma$. We define $L \subseteq \Sigma^$ as the probabilistic language of legitimate sequences and seek a function:

$$ f: \Sigma^ \rightarrow {0,1} $$

with guarantees:

Correctness: $\Pr[f(X)=0 \mid X \sim L] \ge 1-\epsilon$.

Completeness: $\Pr[f(X)=1 \mid X \sim A] \ge 1-\delta$.

  1. Proposed Methodology

4.1 Probabilistic Modeling

We model $L$ with a Markov chain of order $k$:

$$ P(x_i \mid x_{i-1}, \dots, x_{i-k}) = \theta_{c,a}. $$

We estimate:

$$ \hat{\theta}{c,a} = \frac{C(c,a)+\alpha}{\sum{a’} C(c,a’) + \alpha|\Sigma|}. $$

The log-likelihood:

$$ \mathcal{L}(X) = - \sum_{i=k}^{n} \log P(x_i \mid x_{i-1},\dots,x_{i-k}). $$

We decide attack if $\mathcal{L}(X) > \tau$.

4.2 Policy Synthesis

We define:

$$ \Sigma_L = { a \in \Sigma \mid \exists c : C(c,a) > 0 }. $$

The surface reduction:

$$ \rho = 1 - \frac{|\Sigma_L|}{|\Sigma|}. $$

Simplified example of a generated seccomp profile:

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "syscalls": [
    { "names": ["read", "write", "exit", "futex"], "action": "SCMP_ACT_ALLOW" }
  ]
}

4.3 Complexity

Training in $O(N)$; worst-case space $O(|\Sigma|^k)$; online detection in $O(1)$ per event.

  1. Implementation

We implemented the monitor via eBPF attached to sys_enter tracepoints in the Linux kernel 6.6 (LINUX FOUNDATION, 2024). We integrated it with Kubernetes 1.28 and containerd 1.7. The order $k=3$ was selected through stratified cross-validation.

Tests indicated processing of 10,000 events/second per node, with an average additional CPU overhead of 3.7%.

  1. Experimental Evaluation

Environment: 120 nodes (Intel Xeon Gold 6230, 128 GB RAM), 1,800 containers.

Metric Proposed Falco
TPR 96.1% 88.4%
FPR 2.8% 6.7%
Syscall reduction 72.4% N/A
CPU overhead 3.7% 4.9%

p95 latency increased by 4.3 ms. Results indicate statistically significant superiority ($p < 0.01$) compared to the baseline.

  1. Discussion

Probabilistic modeling captures contextual dependencies between syscalls, reducing the permissiveness typical of static policies. We consider evasion through behavioral mimicry, modeled via Kullback-Leibler divergence:

$$ D_{KL}(P_L | P_A). $$

Effective attacks minimize $D_{KL}$, motivating future extensions toward hierarchical models and integration with additional eBPF signals (network, DNS, capabilities).

  1. Conclusion and Future Work

We proposed a formal architecture for detecting and mitigating container escapes based on probabilistic modeling and in-kernel verification. We demonstrated substantial reduction of the attack surface and high detection rates with modest overhead.

Future work includes federated learning across clusters, integration with CNAPP platforms, and formal analysis of adversarial robustness.

References

(Presented according to ABNT, with URLs and access on 13 Apr. 2025.)

AQUA SECURITY. Container Security Report 2023. 2023. Available at: https://www.aquasec.com/resources/container-security-report/. Accessed on: 13 Apr. 2025.

BARHAM, P. et al. Xen and the art of virtualization. In: ACM Symposium on Operating Systems Principles (SOSP). 2003. Available at: https://dl.acm.org/doi/10.1145/945445.945462. Accessed on: 13 Apr. 2025.

BURNS, B.; BEDA, J.; HIGHTOWER, K. Kubernetes: Up and Running. 3rd ed. Sebastopol: O’Reilly, 2022.

CHEN, L. et al. Automated policy generation for container security. In: ACM CCS. 2021. Available at: https://dl.acm.org/doi/10.1145/3460120.3484589. Accessed on: 13 Apr. 2025.

CIS. CIS Kubernetes Benchmark v1.27. 2023. Available at: https://www.cisecurity.org/benchmark/kubernetes. Accessed on: 13 Apr. 2025.

DOCKER. Docker Engine Security. 2024. Available at: https://docs.docker.com/engine/security/. Accessed on: 13 Apr. 2025.

FALCO. Falco Documentation. 2024. Available at: https://falco.org/docs/. Accessed on: 13 Apr. 2025.

FORREST, S. et al. A sense of self for Unix processes. In: IEEE Symposium on Security and Privacy. 1996. Available at: https://ieeexplore.ieee.org/document/502675. Accessed on: 13 Apr. 2025.

KUBERNETES. Pod Security Standards. 2024. Available at: https://kubernetes.io/docs/concepts/security/pod-security-standards/. Accessed on: 13 Apr. 2025.

LINUX FOUNDATION. eBPF Documentation. 2024. Available at: https://ebpf.io/. Accessed on: 13 Apr. 2025.

MITRE. ATT&CK for Containers. 2023. Available at: https://attack.mitre.org/matrices/enterprise/containers/. Accessed on: 13 Apr. 2025.

NIST. SP 800-190: Application Container Security Guide. 2017. Available at: https://csrc.nist.gov/publications/detail/sp/800-190/final. Accessed on: 13 Apr. 2025.

NVD. CVE-2019-5736. 2019. Available at: https://nvd.nist.gov/vuln/detail/CVE-2019-5736. Accessed on: 13 Apr. 2025.

NVD. CVE-2022-0492. 2022a. Available at: https://nvd.nist.gov/vuln/detail/CVE-2022-0492. Accessed on: 13 Apr. 2025.

NVD. CVE-2022-0185. 2022b. Available at: https://nvd.nist.gov/vuln/detail/CVE-2022-0185. Accessed on: 13 Apr. 2025.

OWASP. Docker Security Cheat Sheet. 2023. Available at: https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html. Accessed on: 13 Apr. 2025.

PALO ALTO NETWORKS. State of Cloud-Native Security Report. 2024. Available at: https://www.paloaltonetworks.com/prisma/cloud/state-of-cloud-native-security-report. Accessed on: 13 Apr. 2025.

GARFINKEL, T. Traps and pitfalls: Practical problems in system call interposition. In: USENIX Security Symposium. 2003. Available at: https://www.usenix.org/conference/12th-usenix-security-symposium/traps-and-pitfalls-practical-problems-system-call. Accessed on: 13 Apr. 2025.

HOGLUND, G.; BUTLER, J. Rootkits: Subverting the Windows Kernel. Boston: Addison-Wesley, 2005.