Malware & ransomware

How Does a Computer Virus Spread? 9 Ways Malware Moves

A virus needs a host file and a way to run. It spreads when you open, share or plug in something infected — or, in the worm's case, all by itself.

Cysoro Security TeamPublished · 7 min read
1 file → 1 network → 200,000 PCs MALWARE & RANSOMWARE How does avirus spread? Nine routes — and how to block them.
Quick answer

A computer virus spreads by attaching itself to a normal file or program and copying itself when that file runs or is shared. The main routes are email attachments, malicious downloads, USB drives, shared folders, messaging apps, compromised websites and unpatched software flaws. Worms differ: they copy themselves across networks on their own, with no file for you to open.

Key takeaways

  • A virus needs a host file and a user action to run; a worm spreads across networks by itself.
  • Email attachments, downloads, USB drives and shared folders are the most common routes.
  • Patching, backups, antivirus and refusing to open unexpected attachments stop most spread.

A computer virus is not alive, but it behaves like one: it copies itself, hides inside something useful, and travels wherever that thing goes. Understanding how it moves is the first step to stopping it — because every route has a different defense.

What is a computer virus, exactly?

A computer virus is malicious code that attaches itself to a legitimate file or program and copies itself when that file runs. When you share the file, the virus travels with it.

That host-file requirement is the defining feature. As Fortinet's virus guide explains, a virus needs a host: a document, an application or an executable. When you run that file, the virus runs with it, and when you share it, the virus goes along.

Once it runs, a virus typically goes through phases: it infects files on the machine, waits for a trigger such as opening an app or a date, and then carries out its payload — stealing data, damaging files or opening a door for other malware.

Virus vs worm vs Trojan: what is the difference?

People use virus, worm and Trojan interchangeably, but they spread differently. Knowing which one you are dealing with tells you how fast it can move and what will stop it.

TypeNeeds a host file?Needs a user action?How it spreads
VirusYesYes, usuallyInside files that are opened or shared
WormNo, self-containedNoAcross networks by exploiting flaws
TrojanNo, pretends to be useful softwareYes, install itBy tricking you into installing it

A worm replicates itself and moves from device to device on its own, using network connections, shared drives or software vulnerabilities. A Trojan pretends to be useful software so you install it, and once running it can steal passwords or give an attacker remote access.

The lines can blur. The ILOVEYOU worm of 2000 arrived as an email attachment someone had to open, then spread itself through victims' address books and infected millions of computers. Modern ransomware often combines all three: a Trojan to get in, a virus to persist, and worm-like spread once inside.

How does a computer virus spread? The 9 main routes

A virus spreads when an infected file is opened or shared, or when malware exploits a flaw to reach a new machine. These nine routes cover almost every real-world infection.

Nine ways a virus reaches your computer1. Email attachmentsinvoices, documents, zips2. Malicious downloadscracked apps, fake installers3. USB drivesborrowed or found drives4. Network sharesshared folders and drives5. Messaging appsWhatsApp, social media links6. Compromised sitesdrive-by downloads7. Software flawsunpatched systems, zero-days8. Torrents and P2Ppirated files hide malware9. Malvertisingmalicious ads on real sites
Most infections use one of these nine routes — often two at once. Illustration by Cysoro.

1. Email attachments

Email attachments are one of the most common ways viruses spread. A virus may be disguised as a normal file, like an invoice, a report or a photo, and sent to many people at once.

When the attachment is opened, the virus activates. Macro-enabled documents are a classic example: the file asks you to "enable content", and that click runs the malicious code. For more on the messages that carry them, see our phishing email examples.

2. Malicious downloads

Viruses hide inside software installers, media files and browser add-ons downloaded from untrusted sites. Cracked software and free movie downloads are favorite hiding places.

Even trusted platforms have, in the past, bundled unwanted programs with downloads. Only download software from the vendor's own site or your operating system's official store.

3. USB drives and removable media

Removable devices such as USB sticks can carry infected files. Plugging one into a system risks transferring the virus, especially if the drive auto-runs files or contains a disguised executable.

The Stuxnet worm is a key example of malware that spread through external drives, reaching systems that were not even connected to the internet. Never plug in a drive you found, and scan every borrowed drive before opening its files.

4. Shared folders and networks

Once one computer on a network is infected, the virus can copy itself to shared folders and mapped drives, where other computers pick it up when they open those files.

If a high-privilege account is tricked, the virus can move laterally across network shares, spreading to other systems. Limiting who can write to shared folders slows this route sharply.

5. Messaging apps and social media

Malware links and infected attachments are now shared through WhatsApp, Facebook, Instagram and other messaging platforms, making mobile devices vulnerable too.

A message from a hacked friend's account is especially convincing, because you trust the sender. Treat unexpected links and files with the same suspicion in a chat as you would in an email.

6. Compromised websites and drive-by downloads

Legitimate websites can be compromised and injected with malicious code. Visiting the site can trigger an automatic download if your browser or its plugins are unpatched.

That is the speed of a drive-by download: just visiting the wrong site can start an infection. Keeping your browser updated closes most of these holes before attackers can use them.

7. Software vulnerabilities and exploits

Unpatched systems are the easiest targets for attackers. A virus or worm can exploit a flaw in Windows, a browser or another application to run code without any click at all.

WannaCry used a known vulnerability in Windows file sharing to race through networks worldwide in hours. Zero-day exploits are worse still: no fix exists yet, so the virus has a free run until one is released.

8. File sharing and torrent sites

Peer-to-peer sharing platforms are hotbeds for infection. Free movie torrents or cracked apps often carry hidden malware, and people download them without checking what they really are.

9. Malvertising

Cybercriminals inject malicious code into digital ads, which can appear on genuine websites. Clicking one of these ads can activate the virus, and in some cases simply loading the ad is enough on an unpatched browser.

Case study: how WannaCry spread around the world in a day

WannaCry is the clearest example of how fast network spread can be. On 12 May 2017, the ransomware worm began spreading through computer networks worldwide, encrypting more than 200,000 devices across 150 countries in about a day, as ReliaQuest recounts.

It used EternalBlue, an exploit for a flaw in Microsoft's Server Message Block (SMB) protocol, to move from machine to machine without any user interaction. It scanned the local network, found other devices with an exposed SMB port, and used specially crafted packets to install and execute a copy of itself — then repeated the process.

The patch for the flaw had been released by Microsoft months earlier, but widespread failure to apply it left victims exposed. The outbreak was halted within hours when a researcher registered a domain name hard-coded into the malware as a kill switch, which stopped already-infected computers from encrypting or spreading further.

The lesson is blunt: patching is not admin work, it is the defense that stops worms. A single unpatched machine can infect a whole network, and a whole network can infect its partners.

How do you know a virus is spreading on your device?

A spreading virus leaves signs, though they are easy to mistake for ordinary computer trouble. Look for several of these together, not just one.

  • Files or programs appear, disappear or change without you touching them.
  • Your computer slows down sharply, or the fan runs hard when nothing is open.
  • Friends report strange emails or messages sent from your accounts.
  • Your browser homepage or search engine changes by itself.
  • Antivirus warnings appear, or your antivirus is suddenly disabled.
  • Files are renamed, encrypted or held for ransom.

If you see these signs, disconnect the device from the network first — that single step stops the virus spreading to other machines while you investigate. Our guide on how to know if your phone is hacked covers similar warning signs on mobile.

How do you stop a computer virus from spreading?

Stopping spread is about breaking the chain at every link: the file, the flaw, the network and the user. No single step is enough on its own.

Five defenses that break the chain1. Patch everything, promptlyclose the flaws worms use2. Run antivirus and keep it updatedcatch known viruses early3. Back up offline, and test restoresransomware loses its leverage4. Do not open unexpected attachmentsverify by another channel5. Limit shares and admin rightsone infection cannot reach all
Layered defenses: each one blocks a route the others miss. Illustration by Cysoro.
  1. Patch promptly. Apply operating system and browser updates as soon as they appear. WannaCry spread through a flaw that already had a fix.
  2. Use antivirus and keep it updated. Real-time protection catches known viruses when they try to run, not just when you scan.
  3. Back up offline. Keep at least one backup copy that ransomware cannot reach, and test that you can restore from it.
  4. Be careful with attachments and links. Do not open unexpected files, do not enable macros on documents you did not expect, and verify surprising requests by another channel.
  5. Limit sharing and privileges. Do not share folders more widely than needed, and do not browse as an administrator for everyday work.
  6. Scan USB drives. Scan any removable drive with antivirus before opening its files.
If you are already infected, disconnect firstUnplug the network cable or turn off Wi-Fi before you do anything else. Then change passwords from a clean device, and check whether any password you reused elsewhere needs changing with our pwned password checker.

The bottom line

A computer virus spreads by riding inside files you open or share, and a worm spreads by exploiting flaws to move on its own. Email, downloads, USB drives, shared folders and unpatched software are the routes that matter most.

Patch promptly, back up offline, use antivirus, and pause before opening anything unexpected. Those four habits break almost every route a virus uses — and if one machine is infected, disconnecting it quickly protects all the rest.

Frequently asked questions

How does a computer virus spread to another computer?

It travels inside a file or program that someone opens or shares: an email attachment, a download, a USB drive or a file on a shared folder. When the infected file runs on the new computer, the virus copies itself there too. Worms can also move across a network on their own.

Can a virus spread without the user doing anything?

A true virus usually needs a user action, such as opening a file. A worm does not: it exploits a network or software flaw to copy itself to other machines without anyone clicking anything. That is what made WannaCry spread so fast in 2017.

Can a virus spread through Wi-Fi?

A virus does not spread through Wi-Fi itself, but a worm or an attacker on the same network can reach other devices through shared folders, open ports and unpatched flaws. Keeping devices patched and not sharing folders openly limits that risk.

Can a virus spread through email without opening the attachment?

Modern email clients do not usually run attachments automatically, so opening the attachment is normally the trigger. But a malicious link in the email can lead to a compromised site, and previewing a file in some old or unpatched software has also been exploited.

Can a virus spread from a phone to a computer?

Yes, if an infected file is transferred between them, for example by USB, a shared drive, a messaging app or a cloud folder. A phone virus rarely runs directly on a computer, but the file it carries can infect the computer when it is opened there.

How do I stop a virus from spreading on my network?

Disconnect the infected device, change passwords entered on it, run a full antivirus scan, patch every device, and check shared folders for infected files. Segmenting the network so one infected machine cannot reach everything else also slows spread.

How fast can a virus spread?

Very fast when it is a worm. WannaCry infected more than 200,000 computers in over 150 countries within about a day in May 2017, using a Windows flaw that had already been patched but not yet applied by many victims.

Sources

  1. Fortinet — What are Computer Viruses? Definition and Types of Viruses
  2. Network Threat Detection — How Computer Viruses Spread
  3. Guard.io — Virus vs. Worm vs. Trojan: What's the Difference?
  4. Cyber Experts — Computer Virus Definition: How Viruses Spread
  5. ReliaQuest — Five years after the WannaCry dumpster fire
  6. FBI Internet Crime Complaint Center — 2025 IC3 Annual Report
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against Fortinet, CISA-cited worm guidance and the FBI IC3 2025 report, with WannaCry as the documented worm case.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free