Drive-By Downloads: Can a Website Infect You?
Can you get a virus just by visiting a website? Rarely, with an updated browser. How drive-by downloads work, what infects people instead, and what to do.

You can rarely get a virus just by visiting a website: with an updated browser, a drive-by download (malware that installs itself during a visit) needs a security hole that is not fixed yet. Most infections start with something the page talks you into: a fake download, a fake update or a command to paste.
Can you get a virus just by visiting a website?
Your browser runs every page in a sandbox, a sealed box away from your files. Switzerland's national cyber security office says opening a website infects a device only in very rare cases.
Attacks through unknown holes, called zero-days, mostly target chosen people such as diplomats, and a fixed hole is closed for everyone who updates.

What is a drive-by download?
The attacker plants code on a page you visit, often a hacked but genuine site or an ad on it. Every stage has to work:
You open a page
A hacked site, or an ad on a normal one
Hidden code checks you
Browser, version, system, country
Attack code runs
Only if a matching hole is still open
Breaks out of the sandbox
Usually needs a second hole
Malware installs
Without a prompt or a click
Out-of-date devices are the ones at risk: by November 2026, Chrome had fixed eight holes attackers were already using. Our Chrome zero-day tracker shows how to check you have the fix.
How do you actually get malware from a website?
Instead of breaking out of the sandbox, attackers ask you to step out of it. In Microsoft's Digital Defense Report 2025, 47% of break-ins at the organisations it protects began with a pasted command, and 1% with a security hole.
| The trick | What it asks of you | Real case |
|---|---|---|
| Fake download | Install a copied app | Fake ChatGPT site |
| Fake browser update | Run an 'update' file | 14,971 hacked sites |
| ClickFix (a fake check) | Paste a command, press Enter | Fake 'verify you are human' boxes |
| Bad extension | Add it to your browser | 4.3 million installs |
| Fake virus alert | Call a number or install a 'cleaner' | Tech support scam pop-ups |
Is antivirus enough, and why does it fail?
For most people, yes: the free antivirus built into Windows is enough if it stays on and updated. In AV-Comparatives' test of February to May 2026, Microsoft Defender blocked 396 of 400 live malicious addresses; the best product blocked 399.
Antivirus stops
Pros
- Known malicious files
- Programs that behave suspiciously
- Addresses its maker knows are bad
Why antivirus fails
Cons
- Brand-new malware it cannot recognise yet
- A command you paste and run yourself
- A password typed into a fake page
How to prevent drive-by downloads and fake downloads
The padlock in the address bar only means the connection is encrypted: the fake ChatGPT site had one too.
- Let your browser and system update, and relaunch the browser when it asks
- Get software only from the maker's site, typed by hand, or an app store
- Use an ad blocker when you search, as the FBI recommends
- Close any page that wants an 'update', an extension or notifications
- Remove extensions you no longer use
- Work in a standard account, one without administrator rights
What to do if you think a website infected you
Password stealers send saved passwords and login cookies (what keeps you signed in) away within seconds and often leave nothing for a scan to find. On a work device, tell IT before you clean anything.
- You only opened the page and closed itAlmost certainly fine on an updated device.
- A file downloaded, but you never opened itDelete it and empty the bin.
- You allowed notifications from the siteNot a virus. Remove the site's permission in site settings.
- You typed a password or card number on the pagePhishing, not malware. Change that password now; call your bank about the card.
- You opened a file, installed something or pasted a commandGo offline, change passwords from another device, email first, sign out everywhere, then run a full antivirus scan.
- A scan finds something, or you remain unsureBack up your files and reinstall the device, as the Swiss office advises.
If money is gone, call your bank first, then report it to the police.


