Skip to content

CL-0026: No resource limits — exit code 137, OOMKilled and CPU throttling

Severity: MEDIUM (how it is derived)

Docker sets no memory or CPU limit by default, so one container can starve the host and everything else on it. Set both, sized from what the service uses.

Fix

Set both limits, sized from what the workload actually uses at steady state:

services:
  api:
    image: ghcr.io/acme/api:2.4.0
    deploy:
      resources:
        limits:
          memory: 512M
          cpus: '0.50'

Docker Compose (v2 and later) honours deploy.resources.limits outside Swarm, so this form works for a plain docker compose up. The service-level spellings are equivalent (both measured on Compose 5.5.0):

    mem_limit: 512m
    cpus: 0.50

Recreate the service and check the kernel holds the limits:

docker compose up -d api
docker compose exec api cat /sys/fs/cgroup/memory.max /sys/fs/cgroup/cpu.max
# 536870912          (512M in bytes; "max" means no limit)
# 50000 100000       (0.5 CPU: 50 ms of every 100 ms; "max 100000" means none)

compose-lint -q compose.yaml | grep CL-0026    # prints nothing once fixed

These paths are cgroup v2. On a cgroup v1 host the limits still apply, and the OOM kill and throttling behave the same, but the files are /sys/fs/cgroup/memory/memory.limit_in_bytes (and memory.max_usage_in_bytes for the peak) and /sys/fs/cgroup/cpu/cpu.cfs_quota_us with cpu.cfs_period_us; cpu.stat reports throttled_time in nanoseconds (measured on Ubuntu 24.04 booted with cgroup v1, Docker 29.1.3, which warns that v1 support is deprecated).

Sizing the limits

  1. Run the service without limits and exercise its real workload, including the expensive paths — a backup, a re-index, a bulk import.
  2. Read the peak. The kernel keeps the memory high-water mark (cgroup v2):
docker compose exec api cat /sys/fs/cgroup/memory.peak

docker stats --no-stream shows only the usage at that instant, not the peak; to size CPU, watch docker stats while the expensive path runs.

  1. Set the memory limit above the observed peak with headroom (a common starting point is peak + 50%), and the CPU limit at the concurrency the service actually needs.
  2. Watch for the failure modes below, and raise rather than remove.

Reading the failure

A container that hits its memory limit is killed by the kernel, not asked to stop — so the symptom is an abrupt disappearance rather than a log line from the application:

Symptom What happened Action
Container exits with code 137, State.OOMKilled: true in docker inspect the cgroup's memory limit was reached raise memory, or find the leak — the process got no chance to log
Container stays running but a worker or child process vanished; logs show Killed; State.OOMKilled: true with exit code 0 the kernel killed a child, not the main process as above; confirm with docker compose exec <svc> grep oom_kill /sys/fs/cgroup/memory.events
Application logs end mid-request with no error same — SIGKILL leaves no shutdown path as above
Service slows steadily but never dies, cpu.stat throttled_usec climbing the CPU limit is throttling it raise cpus; CPU limits throttle rather than kill, so this degrades instead of crashing

Confirm which limit is biting before changing anything:

docker inspect --format '{{.State.OOMKilled}} {{.State.ExitCode}}' <container>
docker exec <container> cat /sys/fs/cgroup/memory.max /sys/fs/cgroup/cpu.max

The asymmetry is worth remembering: memory limits kill, CPU limits throttle. An over-tight memory limit takes the service down; an over-tight CPU limit makes it slow. Size memory with more headroom than CPU.

Tested on: Docker 29.7.2 with Compose 5.5.0, on a host without AppArmor (Yama ptrace_scope 1); the Fix steps above were re-run there in October 2026. Also measured in throwaway VMs in October 2026 (Docker 29.9.1 or 29.1.3): on a cgroup v1 host, as described under the Fix block. Not tested: SELinux.

When to suppress

  • A workload whose whole purpose is to use the machine — a batch job, a build runner, a transcoder on a dedicated host. Suppress with a reason: naming the workload and the host it owns.
  • A single-service host where there is nothing else to starve. Note that the host's own daemons are still something to starve.

What it detects

A service that declares no memory limit, no CPU limit, or neither.

Limit Satisfied by
Memory mem_limit, or deploy.resources.limits.memory
CPU cpus, cpu_quota, or deploy.resources.limits.cpus

The message names which of the two is missing, so a service that bounds memory but not CPU gets a finding that says so.

A memory value is read with the grammar Compose uses (go-units): a number, optionally one space, then a scale letter k, m, g, t or p alone or followed by b or ib, in any case, or a bare b. So 512m, 1GiB, 262144KiB and 1t are all limits. A suffix Compose refuses (512Mi, 1bb) is not a limit and is flagged.

Reservations do not satisfy this rule. mem_reservation and cpu_shares express priority under contention — they are soft targets the kernel aims for, not ceilings it enforces. A service with only a reservation still has an unbounded hard limit and is still flagged.

Neither does a non-positive value. Docker reads --memory 0 and --cpus 0 as unlimited, so mem_limit: 0 is an unbounded container wearing the syntax of a bounded one. The key being present is not enough; the value has to bound something. A bare ${VAR} interpolation is treated as a limit — its value is unknowable from the file, and assuming the worst would fire on every parameterised compose file. A defaulted interpolation is not unknowable: mem_limit: "${MEM:-0}m" ships 0m, which Docker reads as unlimited, so it fires. Previously any dollar-bearing value that failed to parse as a quantity was credited as a limit, which let exactly that spelling through.

oom_kill_disable: true is not graded. Docker's documentation warns that disabling the OOM killer on a container with no memory limit leaves the kernel to kill host processes instead. On the posture these rules are graded against (ADR-020) the setting does nothing: on a cgroup v2 host, Docker 29.1.3 discards it with WARNING: Your kernel does not support OomKillDisable. OomKillDisable discarded. and records OomKillDisable: false on the container, with or without a memory limit (measured 2026-10-14; captured, not CI-asserted). The memory half of this rule already asks for the limit the warning is about, and no corpus file sets the key (Triage for a newly found gap in ASSURANCE.md; counted in #1047).

A restart policy is not graded. CIS Docker Benchmark 5.15 asks for on-failure with at most five retries, and KICS carries a query for it. Docker already delays each restart by double the previous delay, starting at 100 ms (docker run reference, restart policies), always and unless-stopped are what real files set (5,791 of the 11,111 corpus files, against 221 for on-failure), and a retry cap turns a restart loop into an outage. A finding whose fix is a worse failure mode is not one this rule asks for.

A process limit is not graded. CIS Docker Benchmark 5.29 asks for one, and OWASP's Docker Security Cheat Sheet lists the number of processes among the resources to limit. Once memory is bounded, the memory limit is what protects the host from a fork bomb, and a process limit only changes how the failure ends. A fork bomb in a container held to 128M and half a CPU, with and without pids: 100:

Process limit Processes reached Outcome
none about 1,200 in five seconds OOM-killed, container exited
100 100 forks refused, container stayed up

The host stayed responsive both times. At the process limit the container used about 10M and the shell printed sh: can't fork: Resource temporarily unavailable (Docker 29.9.3, 8 CPUs; captured, not CI-asserted). Neither ending is healthy. A killed container under a restart policy comes back to the same attack, and a service at its process ceiling cannot start new work: postgres there cannot fork a backend for a new connection.

With no limit set, the host supplies a ceiling where Docker uses the systemd cgroup driver (pids.max read 9046 on that host and 18751 on another), which is too high to matter once memory is limited. compose-lint retired its rule for this, CL-0012, because memory is the dominant exhaustion vector and a file that leaves it unbounded already gets this rule's finding (ADR-020). The setting can still be worth having, and the hardening guide shows where the key goes and how to size it.

Why it matters

Docker imposes no default memory or CPU cap. Verified on Docker 29.1.3: a container started with no limits reports

memory.max = max
cpu.max    = max 100000     # "max" quota — the period is set, the ceiling is not

and both become finite the moment --memory or --cpus is passed. So the absence this rule flags is genuinely Docker's default rather than a hardening preference — the bar the premise validator exists to enforce.

That matters in two different directions:

  • Compute theft. Cryptomining is the most common opportunistic payload dropped into a compromised container, and it is CPU-bound. A memory limit does not slow it down at all; only a CPU limit bounds what an attacker can steal from the host and from the workloads sharing it. (MITRE ATT&CK T1496 Resource Hijacking, and its .001 Compute Hijacking sub-technique.)
  • Denial of service. A memory leak or a deliberate allocation loop in one container reaches the host's OOM killer, which then picks a victim by its own heuristics — frequently not the offending container. (T1499 Endpoint Denial of Service.)

Neither is an isolation break, which is why this is MEDIUM rather than HIGH: the attacker gains no privilege and reads no data. What they gain is everyone else's resources.

ATT&CK coverage

Remediating this finding contributes to mitigating the following MITRE ATT&CK techniques (pinned to ATT&CK v18). compose-lint is a static analyser, so this is mitigation coverage — it detects nothing at runtime.

Technique Tactic
T1496 Resource Hijacking Impact
T1499 Endpoint Denial of Service Impact

See also

  • CL-0007 — read-only root filesystem (the other containment control that limits what a compromised container can do rather than what it can reach)
  • Hardening guide, step 7 — where this rule fits when hardening a whole file

Severity derivation

Derivation (see severity model):

  • Baseline: A — the attacker already has code execution in this container, as the workload uid
  • Precondition: Removes a mitigation — the missing limit grants no primitive of its own; it deletes the cgroup ceiling that would have contained a runaway or compromised workload, widening the blast radius of exhaustion rather than supplying it. (The named-primitive test: nothing here is a nameable primitive, so this is Removes a mitigation, not Second flaw.)
  • Impact: Host — an unbounded container exhausts host memory or CPU, and the host-global OOM killer takes down host processes, the daemon and neighbouring containers alike
  • Qualifier/modifier: availability-only — the impact is denial of service and stolen compute, with no confidentiality or integrity loss
  • Derived: Removes a mitigation × Host + availability-only = MEDIUM
  • Shipped: MEDIUM
  • Evidence: _cl0026 in scripts/validate_rule_premises.py — a container's memory.max is max and its cpu.max is max 100000 by default, and both become bounded once a limit is set. Re-proven against a live daemon on every CI run

References: - OWASP Docker Security Rule #7 - CIS Docker Benchmark 5.11 — Ensure that the memory usage for containers is limited - CIS Docker Benchmark 5.12 — Ensure that CPU priority is set appropriately on containers

A reference means the rule relates to that source. It does not mean a file with no finding complies with it. The CIS, OWASP and ATT&CK mapping for every rule, and the tags SARIF output carries for it, are on Standards mapping.