A zip bomb is a tiny compressed file that grows huge when unpacked and overwhelms the computer.
This guide is for people new to security, website owners who accept uploads, and anyone curious about how a tiny file can cause trouble. You do not need to know how compression works. It explains the idea and the simple limits that defend against it.
In short
- Compression shrinks repeated data. A zip bomb abuses this so a few kilobytes can expand into far more data than any disk can hold.
- The harm is to availability: the system runs out of memory, disk space or time, slows down or crashes.
- Any software that unpacks archives automatically is at risk, including upload pages, mail filters and file scanners.
- The fix is limits: cap how much is unpacked, how deep, and for how long.
What you will learn
- Explain what a zip bomb is and why it is possible.
- Describe what happens to a system that unpacks one.
- Spot which of your systems unpack files automatically.
- Name the limits that stop a zip bomb doing harm.
- Squashed file (archive)
- one file, such as a .zip, that holds other files in a smaller, compressed form.
- Squash factor (compression ratio)
- how much bigger the data gets when it is unpacked.
- Service knocked over (denial of service)
- an attack that stops a system working for the people who need it.
What is a zip bomb?
Think of a vacuum-packed duvet. It arrives in a small bag. Open the bag and it puffs up to fill the bed. Now imagine a bag the size of a book that puffs up to fill a whole warehouse. That is a zip bomb.
Compression works by spotting repetition. If a file contains the same pattern millions of times, it can be stored as "this pattern, repeated millions of times". That is why compressed files are small.
A zip bomb is built to push this to an extreme. Researcher David Fifield describes it as a small file that expands into a huge amount of data, exhausting disk, memory or processing time [1]. The best-known example, 42.zip, is about 42 kilobytes. Fully unpacked, layer within layer, it would reach about 4.5 petabytes [1].
Where the comparison stops working: a duvet stops growing once it is open. A badly built program keeps unpacking until something breaks.
The zip bomb glossary entry gives the short definition. This page explains how it works and how to defend against it.
Why does it matter?
A zip bomb does not steal data. It stops things working. A public list of software weaknesses says highly compressed input can quickly use up memory and processing power, causing poor performance or a crash [2].
If your website accepts uploads
What could happen: someone uploads a tiny archive that fills your server's disk and takes the site offline.
Check this: ask whether uploads are unpacked, and what size limits apply after unpacking.
If you run email or file scanning
What could happen: a scanner that looks inside attachments gets stuck unpacking one, and mail backs up.
Check this: confirm your scanning tools have limits on unpacking depth, size and time.
Next: Antivirus for Beginners
If you write software
What could happen: your code trusts the sizes an archive claims, and they are false.
Check this: count bytes as you unpack and stop at a fixed limit.
What does it look like?
Here is a made-up log from an upload service that stopped a suspicious archive.
Example only. All values are made up.
upload: EXAMPLE-invoice.zip size 0.04 MB (1) claimed: unpacked size 0.5 MB (2) unpacking: 900 MB written ... limit 500 MB reached (3) ratio: over 10,000 to 1 (4) action: stopped, file quarantined, alert raised (5)
- A tiny upload that looks harmless.
- What the archive says it contains. In a real file, this line would contain the sizes listed inside the archive, which can be false.
- The service counts real bytes as it unpacks and stops at its limit.
- A huge gap between packed and unpacked size is a warning sign.
- The safe outcome: the file is set aside and someone is told.
Why this is risky: without the limit in line 3, the service would keep writing until the disk was full.
The safer way: always measure what is actually unpacked, and stop early.
How does it work?
- Squash repeated data. Data that repeats a lot compresses very well, so a huge amount fits in a small space.
- Stack or reuse it. Some bombs put archives inside archives, like 42.zip with its nested layers [1]. Others make many entries point at the same squashed data, so one small piece is unpacked over and over [1].
- A program unpacks it. This might be an upload page, a mail filter, a file scanner or a person double-clicking.
- Resources run out. Memory, disk space or processing time is used up, and the system slows, crashes or restarts [2].
- Limits stop it. A program that caps size, depth and time stops long before harm is done.

Fifield's research showed how far this can go without nesting: a 10 megabyte file that unpacks to 281 terabytes [1]. He also warns that the sizes listed inside an archive cannot be trusted, so adding them up does not predict the real result [1].
His strongest advice is to run the unpacking code in a sandbox, an isolated space with limits on time, memory and disk use [1]. OWASP adds that upload size checks should happen after decompression, not just on the packed file [3].
A worked example
This story is made up to show the idea.
Amara Yeboah runs IT for Kestrel Print, a small printing firm. Customers upload artwork as zip files through the firm's website. The site unpacks them so staff can preview the images.
One Monday the website stops responding. The server's disk is full. Amara finds a single upload from the weekend, under 50 kilobytes, that had been unpacking for hours.
She calls in Lars Iyer, a developer who helped build the site. He checks the upload code. It trusted the sizes written inside each archive and had no limit on how much it would write.
Lars makes three changes. The code now counts real bytes as it unpacks and stops at a sensible limit for artwork. It refuses archives nested inside archives. It runs the unpacking in a separate, limited process, so a bad file cannot fill the main disk.
Amara clears the disk, restores the site and adds an alert for when free space drops low. She also tells customers to send artwork as single image files where they can.
A few weeks later another oversized archive arrives. This time the log shows "limit reached, file quarantined", and nobody notices except Amara, reading the alert over coffee.
Amara learned that the file was never the real problem. The problem was software that would unpack anything with no limit.
Myths and mistakes
| What people think | What is true |
|---|---|
| A small file cannot cause big problems. | A file of about 42 kilobytes can claim to hold petabytes of data[1]. |
| Checking the upload size is enough. | The size check must happen after decompression too[3]. |
| The archive tells you how big it will be. | Sizes listed inside an archive can be false[1]. Count what is really written. |
| Zip bombs are a kind of virus. | They contain no harmful code. They harm availability by using up resources[2]. |
| Blocking one trick fixes the problem. | There are several kinds of bomb. Limits on time, memory and disk work against all of them[1]. |
What can I do this week?
- List every system that unpacks files on its own, such as upload pages and mail filters.
- For each one, ask what limits it has on size, layers and time.
- Set an alert for when a server that takes uploads is low on disk space.
- Read File Upload Security for Beginners for the wider risks of accepting files.
Checklist
- I can explain a zip bomb as a tiny file that unpacks to a huge size.
- I know zip bombs attack availability, not secrecy.
- We know which systems unpack archives automatically.
- Those systems cap unpacked size, nesting depth and time.
- Size checks happen after unpacking, not only before.
- Unpacking runs in an isolated, limited process where possible.
- We get an alert when a server's disk is nearly full.
Common questions
Is a zip bomb dangerous to open on my computer?
It can freeze your computer or fill its disk, but it does not normally steal data or install anything. The bigger risk is to servers and services that unpack files automatically with no limits.
What is 42.zip?
It is a famous example zip bomb of about 42 kilobytes. It contains layers of archives inside archives. If every layer were unpacked, it would reach about 4.5 petabytes, far more than any normal computer can store.
Can antivirus software stop a zip bomb?
Scanners that look inside archives face the same risk as any other program that unpacks files. A well-built scanner sets limits on how far and how much it unpacks, then flags files that go past them. Check how your own tools behave.
Are there bombs in other file types?
Yes. The same idea of small input causing huge output appears elsewhere. OWASP mentions XML bombs, also called the billion laughs attack, alongside zip bombs as threats to upload features.
What is the simplest defence?
Limits. Stop unpacking after a set amount of data, refuse deeply nested archives, and cap how long the job can run. Running the work in an isolated process means a bad file cannot take the whole system down.
Where next?
Ready for the detail? Read the practitioner guide: Secure File Upload Handling Guide. It covers validation, storage and safe processing of uploaded files, including archives.
Also useful:
- D3-FCDC File Content Decompression Checking
- File Upload Security for Beginners
- Denial of Service at Application Layer Guide
- DDoS Attacks for Beginners
Related NHI Mgmt Group resources: Antivirus for Beginners, Malware for Beginners and Website Security for Beginners.
Key terms
- Zip bomb
- A compressed file that expands to a vastly larger size when unpacked, using up disk, memory or processing time.
- Decompression bomb
- The general name for any file that is small when packed but expands dramatically when unpacked.
- Compression ratio
- How much larger data is when unpacked compared with its packed size.
- Sandbox
- An isolated space where a program runs with limits, so it cannot harm the rest of the system.
- Denial of service
- An attack that stops a system or service working for its normal users.
Sources and further reading
- David Fifield, "A better zip bomb", USENIX WOOT 2019. https://www.bamsoftware.com/hacks/zipbomb/ (accessed 30 Nov 2026).
- MITRE, "CWE-409: Improper Handling of Highly Compressed Data (Data Amplification)", Common Weakness Enumeration. https://cwe.mitre.org/data/definitions/409.html (accessed 30 Nov 2026).
- OWASP, "File Upload Cheat Sheet", OWASP Cheat Sheet Series. https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html (accessed 30 Nov 2026).