How to remove malware from a Mac, step by step
To remove malware from a Mac, first stop signing in to accounts with sensitive information, like banking or shopping. Then update macOS, or restart it if it is already up to date, remove login items and apps you did not install, and change your passwords from a different device. If you use GitHub, look for the file ~/Library/LaunchAgents/com.user.gh-token-monitor.plist before you revoke any token, even from another device. If signs of a persistent backdoor remain, back up the files you want to keep, then erase the Mac and reinstall macOS.
To remove malware from a Mac, you do a fixed order of jobs. Accounts come first, because anything you type while the malware is active may be copied. Then you clean the Mac. Passwords and keys are changed after the cleanup, from a device you trust. Malware is harmful software installed on your device without your knowledge, and criminals use it to steal usernames, passwords and bank details. If you are not sure that anything is wrong yet, run the check for a virus first. This page is for the moment you found something or cannot shake the doubt.
01Before you clean: protect the accounts
Stop signing in to online accounts with sensitive information until you know more. Then think back over what you ran recently. Three recent stealer campaigns tricked people into mounting an unsigned DMG, a disk image the developer has not signed, or into pasting a command into Terminal, the app where you type commands. A stealer is a program that goes after browser data, cookies and session tokens. A password prompt that appears before the program goes on can be part of the same pattern: in one AMOS infection, the Mac asked for the user's password before the infection proceeded. If that fits, read the infostealer check alongside this page, because it covers what a stealer could have reached.
02The steps at a glance
| Step | Where | What you do |
|---|---|---|
| 0 | Your accounts | Stop signing in to sensitive accounts |
| 1 | Software Update | Update macOS, or restart if it is current |
| 2 | Activity Monitor | Quit a process you do not recognize, after checking what depends on it |
| 3 | System Settings > General > Login Items & Extensions | Delete items you did not add |
| 4 | Applications folder, Safari Extensions, Device Management | Remove unexpected apps, extensions and profiles |
| 5 | A device you trust | Change passwords and turn on two-factor authentication; replace keys in the safe order below |
| 6 | macOS Recovery | Erase and reinstall if a backdoor may remain |
03Step 1: Update macOS and restart
Go to System Settings, click General, then click Software Update. Install the latest macOS. If your Mac is already on the latest version, restart it, because macOS has a built-in tool that removes known malware when restarting. XProtect, the antivirus built into macOS, removes malware when Apple sends updated information and keeps checking periodically, but it does not restart the Mac for you, so do the restart yourself. What XProtect covers is on the XProtect page.
04Step 2: Quit what you do not recognize
To open Activity Monitor, open Spotlight, type Activity Monitor and click the app. It lists processes, the programs running on your Mac, with the memory and CPU time each one uses. A name you do not know is a reason to look closer, not proof of malware. The suspicious processes page shows how to judge one.
If a process is stuck in a loop or not responding, Activity Monitor can quit it. Before quitting, choose View > All Processes, Hierarchically to see whether another process uses it. To quit it, select the process and click the Stop button in the upper-left corner of the window. Choose Quit first: the process quits only when it is safe to do so. Force Quit ends the process immediately, and if it has files open you may lose data. For a process you do not own you may need to sign in as an administrator. Quitting stops the program for now; it does not remove it. Malware often installs itself persistently so that it runs again after a restart or login, so go on to step 3.
05Step 3: Remove what starts on its own
Choose Apple menu > System Settings, click General in the sidebar, then click Login Items & Extensions. The list shows apps, documents and server connections that open automatically when you log in. Select an item you did not add and delete it.
Some malware hides outside that list, in launch folders. A launch agent is a small background job macOS starts when you log in. Third-party agents for your user live in ~/Library/LaunchAgents, and those for all users in /Library/LaunchAgents. To open one, in the Finder choose Go > Go to Folder and type the path, for example ~/Library/LaunchAgents; the tilde (~) means your home folder. Third-party daemons, the same kind of job for the whole system, live in /Library/LaunchDaemons. For the AMOS stealer, the cleanup is to remove suspicious login items, LaunchAgents and LaunchDaemons from the Library folders, so the malware does not run again after a restart. Read the names slowly: one AMOS infection created a file named .service in a hidden folder named like an Apple service, .com.apple.accountsd, inside Application Support.
Be careful with every file you delete. Trashing system files by mistake can crash the Mac. If a name looks like a normal Apple or app service and you are unsure, leave it and check the item first.
06Step 4: Remove apps, extensions and profiles
Open your Applications folder and look for apps you do not expect. Programs you did not choose often arrive bundled with something you did: certain third-party download sites include extra software alongside the one you asked for. Remove the apps you do not know. Dragging an item to the Trash does not delete it until you empty the Trash.
In Safari, open the Extensions tab in Safari settings and look for extensions you did not install. A browser extension is a small add-on program for the browser. This page covers Safari only; for another browser, use that browser's own extension settings.
Also look at profiles. A configuration profile is a set of settings that can control things like Mail, Wi-Fi and VPN. To see them, choose Apple menu > System Settings, click General, then click Device Management. It is not common to have a profile unless you created a personalized configuration for your Mac. When you remove a profile, all of its settings are deleted. Pop-ups, hijacked search and unwanted extensions have their own page, remove adware.
07Step 5: Change passwords, then replace keys
Do this from a device you trust, not from the Mac you just cleaned. What the malware already copied is still out there, so change the passwords that were stored on the affected system and turn on two-factor authentication for your important accounts. A stolen session can also be used without anything staying on your Mac. The infostealer check has the full order for passwords, keys and sessions.
One trap for developers; if you do not use GitHub, skip it. A GitHub token is a secret that lets a program use your GitHub account. Before you revoke any GitHub token, look for the file ~/Library/LaunchAgents/com.user.gh-token-monitor.plist. It belongs to a malware family called Mini Shai-Hulud: a monitor that polls GitHub and tries to run rm -rf ~/, a command that deletes your home folder, when it sees that a token was revoked.
If the file is there, do not revoke GitHub tokens from any device yet, because the monitor triggers when the token it checks is revoked. Stop it first with launchctl, the tool that loads and unloads launch agents. Type it in the Terminal app, which you open the same way as any app: open Spotlight, type Terminal and click it:
launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.user.gh-token-monitor.plistThe gui/ part points the command at the logged-in user. Then delete the plist file. Or wait: the monitor exits by itself after 24 hours without triggering. Once it is stopped, change your credentials from another device. If the file is not there, change them from another device right away. The Shai-Hulud page has the story.
If you saw ads, websites or emails that seemed to spread malware, or ransomware demanded payment, report it to the FTC at ReportFraud.ftc.gov.
08Step 6: When to erase and reinstall
If signs of a persistent backdoor or unusual activity remain after the steps above, strongly consider erasing the Mac and doing a clean reinstall of macOS. A backdoor is a hidden way for an attacker to send commands to your Mac. Unusual activity can be a persistent connection to an unfamiliar server or new LaunchAgent entries that appear outside a known install event.
A plain reinstall keeps your apps and personal data, so for a clean start erase the startup disk first, which Disk Utility in macOS Recovery can do. Erasing permanently deletes the Mac's files, so back up the files you want to keep before you start. The Recovery window offers Restore from Time Machine, Reinstall macOS and Disk Utility. How you open it depends on the chip. On a Mac with Apple silicon, make sure the Mac is turned off, then press and hold the power button until "Loading startup options" appears, then click Options and Continue. On an Intel Mac, press the power button and immediately hold Command and R until you see an Apple logo or a spinning globe. If you are not sure which you have, you can safely try the Apple silicon steps as well.
Restore files only from backups you know are clean, and do not reuse backups or Time Machine images that may be tainted by an infostealer. After reinstalling, Migration Assistant offers to transfer data from a Time Machine backup, so choose that backup with care. The Time Machine restore page covers the restore side.
09How to know it worked
After you remove malware from a Mac, you cannot prove it is clean by looking at it. Malware can go undetected for a while, even with security software, and one AMOS variant has no persistence at all. A better test is whether the first signs are gone: slowdowns, redirects, new toolbars and pop-ups. Check the signs of a virus table again once the Mac has run for a while. Then keep the habits that stop a second infection. Never run copy-pasted commands from random pages or forums. Download apps from the App Store, or directly from the developer rather than through an ad or link.
10The short version
To remove malware from a Mac, protect your accounts first, then update and restart, remove what you did not install, and change passwords from another device. If you use GitHub, check for the monitor file before revoking any token. Reinstall macOS when a backdoor may be left. Trojans and backdoors have their own page, remove a trojan.
FAQ
How to clean your Mac of malware?
To remove malware from a Mac, first stop signing in to accounts with sensitive information. Then update macOS and restart, remove login items and apps you did not install, and change your passwords from a device you trust. If signs of a persistent backdoor remain, consider a full clean reinstall of macOS.
What are the signs of malware on a Mac?
A slowdown, freezes or crashes, a changed home page or redirects, new browser toolbars, many pop-up ads, a disabled Activity Monitor or messages you did not write. Some malware shows none of them, so the signs of a virus page also covers infections with no signs.
Is there a free malware cleaner available for Macs?
One is already built in. XProtect is the antivirus technology in macOS and it removes known malware. For anything it misses, the steps on this page are manual and need no download. The XProtect page has the details.
Does Apple have a free virus cleaner?
XProtect is built into macOS, so there is nothing extra to download. It removes malware after the fact when Apple sends updated information.
Does Mac have built-in antivirus?
Yes, it is called XProtect. It checks apps that changed and apps at first launch.
Is it possible for a MacBook to get a virus?
Yes. Three recent Mac stealer campaigns relied on tricking people into mounting an unsigned disk image or pasting a command into Terminal. Can Macs get viruses covers the routes.
Does Mac protect against malware?
By default macOS checks all software for known malicious content the first time it is opened. The XProtect page explains what that check covers.
How to clean up a Mac to make it run faster?
Open Activity Monitor and look at how much memory and CPU time each process uses. A slowdown can be a sign of malware, but it has many other causes, so treat it as a reason to look, not a verdict.
Related guides
Sources
- Apple Support, protect your Mac from malware
- Apple Platform Security, protecting against malware
- Apple Support, Login Items & Extensions
- Apple Support, quit a process in Activity Monitor
- Apple Support, launchd script management
- Apple Support, reinstall macOS
- Apple Support, macOS Recovery
- Apple Support, recover all your files
- FTC Consumer Advice, how to recognize, remove and avoid malware
- Malwarebytes, poisoned AI chats and AMOS
- Microsoft Defender Experts, hunting infostealers on macOS
- Wiz, Mini Shai-Hulud
- Artificial Immunity