eBPF-Based Runtime Detection of Semantic DDoS Attacks in Linux Containers
Published in IEEE Access, vol. 13, pp. 169178–169219, 2025.
Authors: S. Remya, Manu J. Pillai, B. Niranjan, P. M. Ajith Kumar, K. Merin Shaju, K. Dinoy Raj, Somula Ramasubbareddy, Yongyun Cho
Links: IEEE Xplore · DOI · Code · Docs
Modern DDoS attacks increasingly target the application layer to exhaust CPU resources rather than the network. Containers make these attacks harder to see, because isolation hides application behaviour from traditional network-level tools. We built CODAX (Container-aware DDoS Attack detection using eXtended Berkeley Packet Filter), a lightweight, eBPF-based detector that starts measuring CPU time the moment a connection is accepted, instead of waiting for it to close. That single design choice lets CODAX catch long-running malicious connections that never hang up.
The attack that never hangs up
Traditional volumetric DDoS attacks flood a service with traffic. A semantic DDoS attack does the opposite: it sends very few, legitimate-looking requests that exploit an application-level weakness to burn CPU. Regular expression denial of service (ReDoS) is a common example. A crafted input pushes the regex engine into exponential backtracking, and a handful of connections can keep a server pinned at 100% CPU.
Containers complicate detection in two ways. First, the attack lives inside the application layer, below the view of network firewalls that only see packets. Second, containers are isolated by design, so host-level tools cannot easily tell which container a connection belongs to without breaking that isolation.
The prior state of the art, CODA (Containerized Denial-of-Service Attack detection), measures the CPU burst time between accept() and close() system calls. If the burst exceeds a per-container threshold, CODA flags the connection. The weakness is obvious once you see an attack in the wild: many semantic DDoS connections never call close(). The attacker holds the socket open, keeps the request incomplete, and lets the server burn CPU indefinitely. By the time CODA would have something to measure, the service is already unresponsive.
CODAX starts from a simple question: why wait for the end of a connection at all?
Tracking CPU from the first system call
The core of CODAX is a global eBPF map that records every active connection when it is accepted:
Mglobal = { (conn_id, t_accept, rho_initial) }
When accept() fires, the eBPF program stores a 64-bit Unix timestamp and the initial CPU usage for that connection. While the connection stays open, CODAX continuously estimates the CPU time consumed so far:
X_hat(t) = (t - t_accept) * rho_avg(t)
where rho_avg(t) is the time-averaged CPU utilization since the connection was accepted. If the estimated CPU time crosses the container's threshold, CODAX raises an alert immediately, even though close() has not happened yet. This is the difference between waiting for a post-mortem and watching the attack happen.
The design still respects container boundaries. CODAX identifies containerized processes through multiple kernel-level signals:
| Signal | Confidence |
|---|---|
| PID namespace | 0.95 |
| Docker network proxy | 0.85 |
cgroup path (/docker/*, /lxc/*, /systemd/docker*) |
0.75 |
| Host process | not containerized |
The PID namespace check is the strongest: a process whose PID namespace is not the init namespace is almost certainly containerized. The UTS namespace name often contains the Docker container ID. When that is not enough, CODAX traces the docker-proxy process or parses the cgroup path. This layered approach means the detector works across process architectures, including single-process servers and multi-process or multi-threaded servers that spawn child processes per connection.
The statistics that make it defensible
A detector is only useful if its threshold is principled. CODAX uses two classical concentration inequalities, both of which make no assumptions about the exact distribution of normal CPU usage.
Chebyshev's inequality bounds how far a value can drift from the mean:
P(|X - mu| >= k * sigma) <= 1 / k^2
so the threshold becomes theta = mu + k * sigma.
Markov's inequality provides a complementary bound for non-negative values:
P(X >= a) <= E[X] / a
which gives theta = mu / delta for a tolerable false-positive probability delta.
CODAX combines both into theta = max(theta_chebyshev, theta_markov). In the paper, the sensitivity parameter k = 4.0 gives the best balance, with an F1 score of 0.927. Lower values flag too many benign requests; higher values start missing attacks.
The thresholds are not static. CODAX updates the mean and standard deviation with exponential smoothing, adds a trend term, and adapts the threshold with a gradient-descent-style update. The goal is to stay accurate as a container's workload drifts over time, which is exactly where fixed thresholds fail.
Making it work inside eBPF
eBPF runs sandboxed programs in the kernel, which is what makes this fast and container-aware, but it also imposes constraints. The paper documents the engineering needed to make the statistics fit:
- No square root instruction. CODAX implements the Babylonian method iteratively to compute the standard deviation.
a = __val / 2;
b = (a + __val / a) / 2;
for (int i = 0; i < 10; i++) {
a = b;
b = (a + __val / a) / 2;
}
return b;
- No room to store every sample. Mean and standard deviation are updated incrementally, so memory stays constant as connections accumulate.
- Time-based triggers do not exist in eBPF. Because eBPF programs run in response to events, CODAX piggybacks threshold checks on
close()calls from any container. In practice this approximates periodic checking, because normal traffic keeps producing close events somewhere in the system. - 64-bit timestamps can be awkward. The implementation masks 64-bit Unix time to 32 bits to stay compatible with existing eBPF tooling and to remain functional past 2038.
Detections are surfaced through a CLI alert and a remote logger. The action module chooses between alerting, throttling, blocking, or terminating a connection, weighing effectiveness against system cost.
Security was part of the design, not an afterthought. The eBPF programs need only CAP_BPF rather than CAP_SYS_ADMIN, and after loading, a seccomp filter locks down the bpf() syscall so the program cannot be modified at runtime. Per-container maps are capped at 65,536 entries, insertions are rate-limited to 1,000 per second, and stale entries are cleaned up automatically. If the map reaches 80% capacity, time-based cleanup runs; at 95%, the oldest entries are evicted.
Filtering the noise with a machine-learning post-filter
Threshold-based detection is bound to produce some false positives. Legitimate batch jobs, deployment rollouts, garbage collection, and slow external dependencies can all hold CPU. CODAX adds a Random Forest post-filter as a second opinion for connections that cross the CPU threshold.
The classifier looks at connection duration, temporal CPU patterns, request frequency, payload size variation, and inter-request timing. It achieves 94.3% accuracy with 0.91 precision and 0.93 recall. In the evaluation, the post-filter cut the false-positive rate from 8% to 2%. Classification adds about 12–15 ms per connection.
To avoid model drift, the system retrains on a schedule every six hours and also when Kolmogorov–Smirnov tests detect a feature distribution shift or accuracy drops by more than 15%. If accuracy falls below 85%, emergency retraining takes over. A new model is only deployed if it beats the performance threshold; otherwise the previous model is restored.
Results
The headline numbers from the evaluation are strong, and they are statistically validated rather than anecdotal. Across ten independent trials, CODAX detected attacks significantly faster than CODA, with a mean reduction of 1,772.3 ms (a 94.2% relative reduction, p < 0.0001). A Wilcoxon signed-rank test agreed (W = 0, p = 0.0020).
| Metric | CODAX |
|---|---|
| Attack Detection Rate (ADR) | 0.92 |
| False Positive Rate (FPR) | 0.02 |
| True Positive Rate (TPR) | 0.90 |
| True Negative Rate (TNR) | 0.95 |
| Precision | 0.93 |
| F1 score | 0.91 |
| Average detection latency | ~50 ms |
| CPU utilization under attack | ~30% |
Against established tools, the gap is clear:
| System | ADR | FPR |
|---|---|---|
| CODAX | 0.92 | 0.02 |
| Snort | 0.85 | 0.10 |
| ModSecurity | 0.80 | 0.15 |
| OSSEC | 0.70 (TPR) | 0.12 |
The CPU comparison is equally telling. With no detection, CPU usage climbs to roughly 80% under attack. CODA holds it near 42%. CODAX keeps it around 30%, because it detects and mitigates earlier rather than after a connection closes.
The paper also reports an ablation study, which is often the most honest part of a systems paper:
- Removing periodic threshold checking drops detection accuracy from 92% to 79%, a 14.1% loss. This is the single most important component.
- Removing the ML post-filter raises false positives from 2% to 8%.
- Removing memory garbage collection increases detection latency by 46% and memory use by 84% over 24 hours.
- Using only Chebyshev drops accuracy to 85% with 9% false positives; using only Markov drops accuracy to 78% with 12% false positives. Combining both gives the best coverage.
On a seven-node Kubernetes cluster, latency rose to 78 ms, ADR held at 91.2%, false positives stayed at 0.031%, and the per-node overhead was 198 MB of memory and 5.6% CPU. Power measurements showed 847 detections per watt-hour, compared with 312 for CODA and 298 for Snort.
What it does not solve
The paper is candid about its scope. The implementation targets x86-64 Linux and is Docker-specific, so Kubernetes, Podman, and other runtimes need adaptation. Testing was done on a LAN, so WAN and cloud conditions are still open questions. Performance degrades beyond 10,000 concurrent connections. And every new container needs a learning period before its baseline threshold is trustworthy.
The threat model also focuses on external, unauthenticated attackers. The authors discuss insider threats and compromised sidecars, but full pod-level quarantine and cross-namespace correlation are left as future work.
Where this goes next
The natural next step is broadening the attack taxonomy beyond ReDoS and infinite loops. Slowloris, HTTP keep-alive abuse, and library-specific protocol vulnerabilities all fit the same CPU-time model. The authors also point toward distributed threshold management for multi-cloud deployments, multi-resource anomaly detection that combines CPU with memory and network usage, and more advanced mitigation such as container throttling and automated migration.
The broader lesson is that container security benefits from moving closer to the kernel. eBPF gives you visibility into system calls without piercing container isolation, and that visibility turns an invisible application-layer attack into a measurable resource-consumption problem.
Citation
@ARTICLE{11179973,
author={Remya, S. and Pillai, Manu J. and Niranjan, B. and Ajith Kumar, P. M. and Merin Shaju, K. and Dinoy Raj, K. and Ramasubbareddy, Somula and Cho, Yongyun},
journal={IEEE Access},
title={eBPF-Based Runtime Detection of Semantic DDoS Attacks in Linux Containers},
year={2025},
volume={13},
pages={169178-169219},
doi={10.1109/ACCESS.2025.3614389}
}
The paper is open access under CC BY 4.0. The implementation is available at github.com/Ziton-live/CODAX, and the documentation lives at ziton-live.github.io/CODAX.