Skip to content

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.

Janis ZesigerUpdated 5 min readShare
Drive-by download illustrated: a download box drops out of a browser window, the way malware can reach a device from a web page

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.

Drive-by download explained: a web page's code is locked inside the browser's sandbox box on a laptop, and only a hand reaching in from outside, the user, can carry a file or command out of it
Page code is locked in the sandbox, so most attacks ask you to carry something out.

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:

  1. You open a page

    A hacked site, or an ad on a normal one

  2. Hidden code checks you

    Browser, version, system, country

  3. Attack code runs

    Only if a matching hole is still open

  4. Breaks out of the sandbox

    Usually needs a second hole

  5. 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.

How web pages get malware onto devices in 2025 and 2026
The trickWhat it asks of youReal case
Fake downloadInstall a copied appFake ChatGPT site
Fake browser updateRun an 'update' file14,971 hacked sites
ClickFix (a fake check)Paste a command, press EnterFake 'verify you are human' boxes
Bad extensionAdd it to your browser4.3 million installs
Fake virus alertCall 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.

Frequently asked questions

Rarely, and almost only when out of date: Coruna, an attack toolkit Google found in 2026, infected iPhones through websites, but only on iOS 13 to 17.2.1. On Android, a site's app file cannot install itself unless you turn on 'Allow from this source' for your browser.

Janis Zesiger

Founder of Browser.lol and Guard.ch

Janis Zesiger founded Browser.lol and Guard.ch and runs Zesiger.net in Switzerland. Janis builds the isolated session platform behind both products and writes about browser security, privacy and AI agents that use the web.

All articles