Can a zip file contain a virus?
Yes. A zip file is just a compressed container, so anything that fits in a file fits in a zip — including malware. An executable, a script, or a macro-laden document can be compressed inside an archive exactly as easily as a holiday photo. The zip itself is not malicious; it is the delivery wrapper that helps the payload slip past a quick glance, and sometimes past an automated scanner.
The reassuring nuance is that opening a zip is not the same as running what is inside. Browsing the file tree and previewing an entry do not execute anything. The damage happens later, when a file is extracted to disk and then launched. This page explains how archives are used to deliver malware, where the real risk lies, and how to handle a suspicious zip safely. For the broader threat model, see security and privacy; for hands-on checks, see how to check if a zip file is safe.
Why archives are a popular delivery channel
Attackers like archives for a few practical reasons. Compression and encoding let them bundle a payload with supporting files and hide it from a casual inspection. Email and messaging systems often scan attachments by extension or signature, and wrapping a file in a zip can sometimes evade a naive filter — especially when combined with a password the recipient is coaxed into entering. And the wrapper itself is socially useful: people expect an "invoice," a "contract," or a "photo album" to arrive as an archive, which lowers their guard.
None of this makes the zip format bad. The same properties — bundling, compression, familiarity — are why archives are everywhere in legitimate use. The risk is purely about what is inside and who sent it.
- Archives bundle a payload with other files and hide it from a quick glance.
- A zip wrapper can sometimes evade naive email or scanner filters.
- The format is familiar, so a "document" arriving as an archive seems normal.
- The risk is the contents and the sender, not the format.
The payloads that actually carry malware
A handful of file types do almost all of the work as payloads. Executables (.exe, .scr, .com) and scripts (.bat, .cmd, .vbs, .js, .ps1) run code directly when launched. Shared libraries (.dll, .so, .dylib) can be loaded by other programs. Macro-enabled Office documents (.docm, .xlsm, sometimes .doc/.xls with legacy macros) run embedded macros when opened with macros enabled. Malicious shortcuts (.lnk) can execute commands while looking like ordinary files.
Each of these is only dangerous when executed or opened in an application that runs its code. Sitting compressed inside a zip, inert, they do nothing. The danger is the moment they leave the archive and are launched.
- Executables: .exe, .scr, .com.
- Scripts: .bat, .cmd, .vbs, .js, .ps1.
- Shared libraries: .dll, .so, .dylib.
- Macro-enabled Office docs (.docm, .xlsm) and malicious shortcuts (.lnk).
Opening a zip is not running it
This distinction is the single most important one. Listing a zip's file tree reads only the archive's index — the central directory — and previewing an entry in a viewer displays it without launching it. Neither operation executes the payload. You can inspect a malicious archive safely as long as you do not extract and run its contents.
The risk appears at the extract-and-run step. Once a file is written to disk and double-clicked, or opened in an application that executes its code (macros enabled, scripts run), the payload runs with whatever privileges the user has. Where and how you browsed the archive becomes irrelevant at that point. Browsing is safe; launching is the danger zone.
- Listing the tree and previewing entries do not execute anything.
- You can inspect a malicious archive safely without extracting or running it.
- The risk appears at extract-and-run: double-clicking or opening in a runner app.
- Once a payload runs, where you browsed the zip no longer matters.
Tricks malware archives use
Delivery attacks lean on a few recurring tricks. Double extensions exploit operating systems that hide known extensions: a file named invoice.pdf.exe appears as invoice.pdf to the victim, who thinks they are opening a document. Lookalike names use Unicode characters that resemble others to impersonate a trusted file type. Nested archives bury a payload several layers deep, counting on a tool that auto-extracts recursively to unwrap it for the victim. And Office documents with macros rely on the user clicking "Enable content," at which point the macro runs.
Knowing these tricks makes them easy to spot from the file tree. A real document archive does not need an executable or a .lnk inside it; a real photo album does not contain .bat files. The presence of a high-risk extension where a document should be is the tell.
- Double extensions: invoice.pdf.exe looks like a PDF when extensions are hidden.
- Lookalike names using Unicode to imitate a trusted file type.
- Nested archives that count on recursive auto-extraction.
- Macro documents that run code when the user enables content.
How to handle a suspicious archive
A few habits cover the vast majority of real cases. Preview the tree first in a no-upload viewer before extracting anything; seeing a .exe next to an invoice is a cheap, instant signal. Do not extract-and-double-click unknown files — that reflexive double-click is how most payload-driven malware actually runs. For executables you do intend to run, scan with up-to-date local antivirus first. And treat archives from email or unknown senders as untrusted by default, because that is where delivery attacks concentrate.
Do not let any extractor auto-recurse into nested archives — a deliberate click per layer is a defense, not an inconvenience. Keep your browser and operating system updated so the sandbox and any parser stay patched. For a fuller checklist, see how to check if a zip file is safe; archives are also used to shield other attacks, covered in what is a zip bomb.
- Preview the tree in a no-upload viewer before extracting to disk.
- Do not extract and then reflexively double-click unknown files.
- Scan executables with up-to-date antivirus before running them.
- Treat email and unknown-sender archives as untrusted by default.
- Do not let an extractor auto-recurse into nested archives.
What an in-browser viewer does and does not protect against
A client-side viewer improves one thing clearly: confidentiality. Because it parses the archive in your browser, no third party sees your copy of a file you are already suspicious of. That matters when the archive itself is sensitive. It does not change the malware math at all — a malicious file is still malicious, and the moment you extract and run it, the risk is identical regardless of where you previewed the zip.
The honest summary: use a no-upload viewer to inspect safely and privately, but understand that inspection is not disinfection. The defense against a malicious payload is to not run it, and that decision is yours regardless of the tool. See why client-side is safer than uploading for the privacy angle and security and privacy for the full picture.
- A client-side viewer protects confidentiality, not against the file being malware.
- Parsing locally means no third party sees your copy of the suspicious archive.
- Inspection is not disinfection — the defense is to not extract and run the payload.
Frequently asked questions
Can a zip file contain a virus?
Yes. A zip is just a compressed container, so any file that can be malware can live inside one. Executables, scripts, macro-laden Office documents, and malicious shortcuts can all be compressed into an archive. The zip itself is not malicious; it is a delivery wrapper. Opening the zip to browse its tree usually runs nothing — the risk appears when you extract a file and then open or double-click it.
Is it dangerous to open a zip file?
Browsing a zip — listing its file tree and previewing entries — is generally safe, because it does not execute anything. The danger is at the extract-and-run step: once you write a file to disk and launch it, the payload runs. Treat archives from unknown senders as untrusted, preview before extracting, and do not reflexively double-click unknown files.
Can I get a virus just by previewing a zip?
No, not from listing the tree or previewing a file in a viewer, because neither operation runs the payload. Malware inside an archive is inert until it is extracted and executed (or opened in an application that runs its code, like macros in a document). Previewing is a low-risk way to inspect a suspicious archive before deciding whether to extract it.
What file types inside a zip are dangerous?
The high-risk categories are executables (.exe, .scr, .com), scripts (.bat, .cmd, .vbs, .js, .ps1), shared libraries (.dll, .so, .dylib), macro-enabled Office documents (.docm, .xlsm), and malicious shortcuts (.lnk). A document archive that contains an executable or a .bat file is suspicious by definition. Watch for double extensions like invoice.pdf.exe that hide the real type.
Why do attackers use zip files to deliver malware?
Because archives bundle a payload, can sometimes evade naive email or scanner filters, and are familiar enough that a "document" arriving as a zip seems normal. Combined with social engineering — an email pretending to be an invoice or contract — the wrapper lowers the recipient's guard. The format is not the problem; the contents and the sender are.
How do I safely open a zip from an unknown sender?
Preview the tree in a no-upload viewer before extracting anything, and look for high-risk extensions (executables, scripts, macro documents) that should not be in a document archive. Do not extract-and-double-click unknown files, and scan any executable with up-to-date antivirus before running it. If you were not expecting the file, the safest action is often to delete it. See how to check if a zip file is safe for the full checklist.