Computer Virus

A computer virus is malware that attaches itself to a legitimate file or program and spreads when that file is opened or shared, copying itself to other files and computers and often corrupting or deleting data along the way.

BeginnerCategory: Malware

Also called: virus, computer viruses, file infector

What is a computer virus?

NIST describes a virus as a computer program that can copy itself and infect a computer without the user's permission or knowledge, and that may corrupt or delete data or spread to other computers. People often say "virus" for any malware, but strictly a virus is the kind that hides inside another file and needs someone to open or run that file to spread.

How does a computer virus work?

A virus inserts its code into a host, such as a program, a document with macros or a startup area of a disk. When someone runs the host, the virus runs too, copies itself into other files and carries out its payload, which might be anything from a harmless message to deleting data. Macro viruses hidden in Office documents were common for years, which is why Microsoft now blocks macros in files from the internet by default.

Virus, worm or trojan?

  • A virus needs a host file and a person to open it.
  • A [worm](/glossary/computer-worm/) spreads on its own across networks.
  • A [trojan horse](/glossary/trojan-horse/) pretends to be useful software and doesn't copy itself.

How to protect your business

  • Use endpoint protection on every device and keep it updated.
  • Leave Office macro blocking switched on and don't let staff enable macros in emailed files.
  • Keep operating systems and software patched.
  • Scan removable drives and limit who can install software.

Related terms

Sources

  1. Glossary: virus (NIST)
  2. SP 800-83 Rev. 1: Guide to Malware Incident Prevention and Handling (NIST)

Drafted with AI assistance, then edited and fact-checked by a person. How we use AI.