A fork bomb is a type of denial-of-service (DoS) attack that exploits the process creation capabilities of an operating system. It works by creating a large number of processes in a short amount of time, which can overwhelm the system's resources, such as CPU and memory.
The classic example of a fork bomb in Unix-like systems is the command:
:(){ :|:& };:
Here's how it works:
:defines a function named:.- Inside the function, it calls itself twice (
:|:), creating two child processes. - The
&puts the processes in the background, allowing the function to be called repeatedly. - The final
;:executes the function, starting the cycle.
As a result, the system quickly becomes overloaded with processes, leading to a crash or unresponsiveness. To mitigate the effects of a fork bomb, system administrators can set limits on the number of processes a user can create.
