How Antivirus Works: Signatures, Behavior and Cloud Checks
Antivirus is a single name for several different techniques running side by side. Each one catches threats the others miss, and none of them catches everything. Knowing roughly how they work helps you understand what a warning means, why a harmless file is sometimes flagged, and which risks are still yours to handle. This guide describes the techniques in general terms; it does not compare or recommend products.
What it watches
Modern security software, including the protection built into Windows and macOS, looks at several moments in a file's life:
- When a file arrives: a download, an email attachment, a file copied from a USB drive.
- When a file is opened or a program starts: often called real-time or on-access protection.
- While a program runs: what it does to other files, settings and the network.
- On a schedule or on request: a quick scan of the places malware usually hides, or a full scan of every file.
- On the web: many products also check the sites you visit and the files you download against lists of known dangerous ones.
Signatures: recognizing known threats
The oldest technique is matching files against a library of known malware. The simplest signature is a file hash: a fixed-length fingerprint calculated from every byte of a file. If a file's hash matches the hash of a known malicious file, it is that file.
You can see why hashes make good fingerprints with our File Hash Generator. The SHA-256 hash of the text hello is 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824. Change one letter to a capital, Hello, and the hash becomes 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969: completely different, not slightly different.
That sensitivity is also the weakness. Whoever makes a piece of malware can change a few bytes and produce a file with a new hash that no exact-match list contains. So signature libraries also describe patterns: characteristic sequences of code or structure that stay the same across many variants. Signatures are fast and rarely wrong, but they only recognize what someone has already seen and described, which is why the detection data has to be updated constantly. Leave automatic updates on (see software updates and patching).
Heuristics: judging the unfamiliar
Heuristic analysis examines a file that matches no signature and asks whether it looks like malware: whether it is built the way malicious programs usually are, hides what it contains, or includes instructions typical of harmful software. It produces a judgment, not a certainty, which is why heuristic detections are sometimes labeled "suspicious" or given a generic name rather than a specific one.
Behavior monitoring: watching what programs do
Some threats only reveal themselves when they run. Behavior monitoring watches running programs for actions that ordinary software rarely takes together: changing large numbers of your files in quick succession (as ransomware does when it encrypts them), quietly adding itself to the list of programs that start with the computer, reading the files where browsers keep saved passwords, or turning off security settings. When the pattern is clear enough, the security software stops the program and, in some cases, undoes its changes.
Reputation and cloud lookups
Many products send details of a new file (often just its fingerprint, and sometimes, depending on the settings, a copy of the file) to the maker's online service to ask whether it has been seen before, by how many people, and whether it has been judged safe or harmful. A file that millions of people run is less likely to be a threat than one that appeared an hour ago. Microsoft describes its SmartScreen feature this way: if a file, app or website has an established reputation, no warning appears; if it has none, it is treated as higher risk and you see a caution. Unknown is not the same as malicious, but it is a reason to stop and check where the file came from.
Web and download protection
Browsers and security products keep lists of sites reported for phishing or for spreading malware, and show a warning page when you try to visit one. Treat these warnings as real; do not click through. A missing warning, though, means only that the site is not yet on a list. New phishing pages appear all the time, so the absence of a warning is not a sign that a page is genuine.
Quarantine
When security software finds something, it usually does not delete it straight away. It moves the file to quarantine, a locked area where it cannot run, and records the detection in a history or log. That way a mistaken detection can be undone. Restore a quarantined file only if you are sure it is genuine, for example a program you downloaded yourself from the publisher's official site, and even then consider downloading a fresh copy instead.
False positives, and why you should not switch protection off
Any method that judges unfamiliar files will occasionally flag a harmless one. Small or new programs, tools that change system settings, and files that few people use are the usual victims. When that happens:
- Do not turn protection off to make the file run. This is exactly what someone sending a malicious file will ask you to do ("your antivirus blocks it, just pause it for a minute"). A real colleague, supplier or support service does not ask that.
- Ask where the file came from. If someone sent it, check with them through a channel you already use, not by replying to the message.
- Get it from the source. Download the program again from the publisher's own site, typed or bookmarked, or from the official app store.
- Check its checksum if the publisher lists one; check a file hash shows how, and what a match does and does not prove.
- Report it to the security product's maker if you are confident it is a mistake; most have a way to submit a file for another look.
What antivirus cannot do
Security software is good at recognizing harmful files and programs. Most scams today do not need either.
- It cannot stop you from typing your password into a convincing fake sign-in page. That is phishing, and the defense is to sign in only from a bookmark, a typed address or the official app (see how to spot a phishing email).
- It cannot stop a phone caller from talking you into moving money, reading out a code or installing remote-access software. Never let someone who contacted you take control of your device.
- It cannot protect an account whose password you have reused elsewhere and that leaked in a breach.
- It cannot fix flaws in software that has not been updated, although it may catch some of what tries to use them.
- It cannot catch everything. New threats can go unrecognized for a while, and no product, free or paid, detects every one.
That is why antivirus is one layer among several: updates, a password manager with a different password for every account, two-factor sign-in, careful downloads and backups.
One product at a time
Two security products scanning the same files at once can slow a computer down and interfere with each other. Windows handles this itself: Microsoft's documentation says that on Windows 10 and 11, when another antivirus product is installed and acting as the main one, Microsoft Defender Antivirus switches off automatically, and it can switch itself back on if the other product expires or is removed. If you install a security product, let it be the only real-time scanner, and keep it updated. The security built into Windows, Mac and phones explains how to check what is protecting your device now.
Reading a detection
- "Threat blocked" or "quarantined": the software stopped it. Note where the file came from and avoid that source.
- "Action needed" or "threat found but not removed": follow the steps in the security app itself, which you open from the system's own menus, not from a pop-up in a web page.
- A warning that appears inside a web page, with a phone number or a countdown: that is not your security software. Close the tab; see real and fake security alerts.
- Repeated detections, or signs that something is still wrong: follow signs of malware and what to do.
For the kinds of threats these techniques are looking for, see types of malware explained.