LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

What is a fork bomb such as :(){ :|:& };:, and why is it relevant to container security?

A function that recursively calls itself twice and backgrounds each call, so processes multiply exponentially until the system runs out of PIDs/memory and locks up — a denial-of-service. It is relevant because --pids-limit stops it.

Decoding the classic Bash one-liner :(){ :|:& };::

  • :() defines a function named :.
  • Its body :|:& calls : and pipes it into another :, and & backgrounds the whole thing — so each call spawns two more.
  • The final : invokes it once to start the chain.

The result is exponential process growth: 1 → 2 → 4 → 8 → … within moments the process table and memory are exhausted and the machine becomes unresponsive. It needs no special privileges — any shell can run it.

Why a container lab asks about it: a container that can fork without limit can take the whole host down (a local DoS), affecting every other container. The defence is a cgroup PID limit: docker run --pids-limit 6 … caps the container's process count, so the bomb detonates against the limit and fork() simply fails, leaving the host healthy. It is a concrete demonstration of why resource limits are a security control, not just a performance knob.

Go deeper:

From Quiz: ISLAB / Docker Security | Updated: Nov 26, 2026