This article is free to read. Creating a lesson uses your daily or stored credits; review the language and settings before starting.
How does a computer virus spread?
Quick answer
A computer virus spreads by attaching to a file or program and running when a user opens it, then copying itself into other files or sending itself to new devices. Common routes include email attachments, downloads, USB drives, and network shares. Some viruses also exploit security holes to spread automatically.
A computer virus spreads when an infected file or program runs on a new device, letting the virus copy itself into other files or systems. It typically travels via email attachments, downloads, shared drives, or infected removable media, then executes and replicates when a user opens or runs the malicious code.
Step by step
- The virus code is written into a legitimate file or program, often by infecting an executable or document.
- A user runs the infected file, which triggers the virus code to execute before or alongside the legitimate program.
- The virus loads into memory and searches for other files, drives, or network connections to infect.
- It copies its code into new host files or sends copies via email, shared folders, or removable media.
- When those newly infected files are opened on other devices, the cycle repeats, spreading the virus further.
Key things to understand
- A virus is a piece of code that attaches itself to a legitimate program or file, lying dormant until that file is executed.
- When the host file runs, the virus code executes first, often loading itself into memory and copying its code into other executable files.
- Common transmission routes include email attachments, pirated software downloads, infected USB drives, and network file shares.
- Related malware called worms spreads automatically by exploiting network vulnerabilities, scanning for open ports and copying themselves to other machines without user action.
- Once active, a virus can deliver a payload—such as data corruption, backdoor access, or further malware downloads—while continuing to replicate.
Labelled diagram
- Infection
Virus code is inserted into a legitimate file or program, often without visible signs.
- Execution
User runs the infected file, causing the virus code to execute and load into memory.
- Replication
Virus copies itself into other files, programs, or system areas on the same device.
- Transmission
Infected files are shared via email, downloads, USB drives, or network connections.
- New host
Another user opens the infected file, and the virus repeats the cycle on a new device.
Real-world examples
- The ILOVEYOU virus in 2000 spread as an email attachment named LOVE-LETTER-FOR-YOU.TXT.vbs, tricking millions into opening it and overwriting files.
- The Melissa virus in 1999 infected Word documents and emailed itself to the first 50 contacts in a user's address book, rapidly spreading through enterprises.
- Stuxnet, discovered in 2010, spread via infected USB drives and network shares to reach industrial control systems, showing how viruses can target physical equipment.
- A user plugs an infected USB drive into a work computer, which then infects shared network folders, allowing the virus to reach other machines on the same office network.
Common mistake
✗ Myth: Every computer virus spreads entirely by itself, without anyone opening a file or running a program.
✓ Fact: Most viruses require a user to run an infected program or open an infected file to execute. However, some malware (like worms or exploit kits) can spread through network flaws or malicious web pages without user action, so the distinction matters.
People also ask
How do computer viruses spread from one computer to another?
Can a virus spread without internet?
What happens after a virus infects a computer?
Can a computer virus spread without opening an email attachment?
What is the difference between a virus and a worm?
How do USB drives spread viruses?
Do antivirus programs stop all viruses from spreading?
Part of the guide: How the Internet Works →

