Sub topic 10
XProtect: built-in malware detection and removal
This chapter assumes you know how to open Terminal and run a command. It also assumes you have read the earlier chapters on code signing, notarization, quarantine and Gatekeeper. XProtect is the last of the built-in checks. It looks at what a file actually contains, rather than who signed it or where it came from.
What XProtect is
XProtect is Apple's built-in, signature-based malware detection. It works like a small antivirus engine that ships with macOS. It has three parts:
- Detection rules. These are signatures that describe known malware families. Apple writes them and updates them separately from macOS releases.
- A scanner. It checks apps, disk images and other executable content against the rules at specific moments.
- Remediation. This part is called the Malware Removal Tool (MRT) in older versions of macOS and XProtect Remediator (XPR) in current ones. It finds malware that is already installed and removes it.
XProtect does not replace the other checks. Gatekeeper asks whether an app is signed and notarized. XProtect asks whether the app matches something Apple already knows to be malicious. An app can pass the first check and fail the second. A notarized app can be added to the block list after the fact if it turns out to be harmful.
When XProtect scans
macOS runs XProtect checks at these points:
- First launch of a quarantined app. Gatekeeper's check includes an XProtect scan. This is the main moment, and it is why quarantine matters (see the quarantine chapter).
- When an app has changed. If an app is modified, macOS checks it again when it next runs.
- When the signature data updates. macOS rescans in the background after Apple ships new rules.
- On a schedule. XProtect Remediator runs periodic background scans for known threats on the whole system.
Because the first scan depends on quarantine, a file that never receives the quarantine attribute skips that launch check. Some command-line tools, such as curl, do not apply quarantine. This is one reason to treat files fetched from Terminal with the same caution as browser downloads.
What you see when XProtect blocks something
When XProtect detects malware, macOS shows a dialog saying the app "will damage your computer" or "contains malware". The buttons are typically Move to Trash and Cancel. There is no "Open anyway" path for a confirmed detection. This differs from the Gatekeeper "unidentified developer" warning, which you can override in System Settings. Treat the two messages differently:
| Message | Meaning | Can you override it? |
|---|---|---|
| "Cannot be opened because the developer cannot be verified" | Gatekeeper: unsigned or not notarized | Yes, in Privacy & Security, at your own risk |
| "Will damage your computer" or "contains malware" | XProtect: matches a known threat | No. Move it to the Trash |
If you see the second message, do not look for a workaround. Delete the file, empty the Trash, and re-check how it reached you.
How the rules and tools update
Apple delivers XProtect data through background security updates. These are separate from full macOS updates, so protection can improve without a restart in most cases. On current macOS versions, the relevant setting is in System Settings > General > Software Update, under the info button next to Automatic Updates. Keep Install Security Responses and system files turned on (the label may vary slightly by macOS version).
You can see the installed XProtect version in System Settings > General > About, then System Report, then Software > Installations. Look for entries named "XProtect" and "XProtect Remediator" (or "MRT" on older systems) with their install dates. If the newest entry is many weeks old and Automatic Updates is off, your detection rules are stale.
The data lives in system locations that you should not edit. On recent macOS versions, the XProtect rules are in a bundle under /Library/Apple/System/Library/CoreServices/XProtect.bundle, and the remediation tools sit under /Library/Apple/System/Library/CoreServices/XProtect.app. Paths have moved between macOS versions, so use the System Report rather than relying on a fixed path.
You can list the bundle version from Terminal:
defaults read /Library/Apple/System/Library/CoreServices/XProtect.bundle/Contents/Info.plist CFBundleShortVersionStringIf this prints an error, the path differs on your macOS version. In that case use System Report instead.
What XProtect does not do
XProtect is useful, but it has limits that shape how you should install software:
- It only knows what Apple has already seen. New malware, or a lightly modified version of an old family, can get past the signature rules until Apple updates them.
- It does not check behavior in real time. It is not an on-access scanner for every file you open, and it does not watch a running app for suspicious actions.
- It does not judge unwanted software. Adware, aggressive trackers and apps with excessive permissions can pass cleanly because they are not on the malware list.
- It cannot stop what you approve. If you override a Gatekeeper warning, paste a command into Terminal, or type your password into a fake installer, XProtect has nothing to match against.
- It is not a firewall. It does not control network traffic.
This is why the earlier chapters on vetting sources and verifying downloads still matter. XProtect is a safety net, not the primary defense.
Third-party antivirus
Many Mac users do not need a separate antivirus product for basic protection, because Gatekeeper, notarization and XProtect already cover common threats. A third-party tool can still make sense in specific cases:
- A managed work laptop where the employer requires endpoint protection.
- A Mac that regularly handles files for Windows users, where you want to catch Windows malware before passing it on.
- A need for behavior monitoring or network filtering that XProtect does not provide.
If you install one, choose a vendor that uses Apple's supported system extension interfaces, and install it from the vendor's official site, using the same checks you would apply to any other app. A security tool has deep access, so a fake one is a serious risk.
Checking for infections you suspect
If you think an app was malicious but XProtect did not complain, work through these steps:
- Make sure your security updates are current, then restart. Remediation scans run in the background, so give them time.
- Open Activity Monitor and look for unfamiliar processes using heavy CPU or network.
- Review System Settings > General > Login Items & Extensions for items you did not add. Remove anything unknown.
- Review Privacy & Security for permissions (Accessibility, Full Disk Access, Screen Recording) granted to apps you do not recognize. Revoke them.
- Check browser extensions and any configuration profiles under Privacy & Security > Profiles if that section appears.
- Change passwords from a different, trusted device if you entered credentials into the app, and enable two-factor authentication where it is available.
Confirm the file's signature and hash with the commands from the verification chapters. A valid signature from a known developer, plus a matching checksum, is stronger evidence than an absence of warnings.
codesign --verify --deep --strict --verbose=2 /Applications/Example.app
spctl --assess --type execute --verbose=4 /Applications/Example.appCommon errors
- Assuming a notarized app is safe. Notarization is an automated check. Malware has passed it. XProtect and Apple's revocation of developer certificates exist to cover that gap.
- Turning off automatic security updates. This leaves the detection rules out of date, which is the main weakness of a signature-based tool.
- Looking for an override. A true XProtect block is not meant to be bypassed. If a legitimate app is flagged, contact the developer and wait for a corrected build. Do not strip quarantine or disable protections to make it run.
- Confusing "no warning" with "verified". Absence of an alert only means no known signature matched.
Exercise
A coworker sends you a download link and the app you get shows the message "will damage your computer" with only Move to Trash and Cancel buttons. Which built-in check produced it, can you override it from Privacy & Security, and what two things should you do next?
Show answer
The message comes from XProtect, which matched the app to known malware. It cannot be overridden from Privacy & Security (that option applies to Gatekeeper warnings about unsigned or unnotarized apps). Move the app to the Trash and empty it. Then find out how the file reached you, for example by telling your coworker their account or link may be compromised, and check that your security updates are current.
Exercise
Why might a file downloaded with curl in Terminal skip the first-launch XProtect scan, and how does that affect how you treat it?
Show answer
XProtect's launch-time scan is tied to the quarantine attribute, and curl does not add it. Without it, macOS does not run the first-launch checks, so you get less protection. Treat such files like any other untrusted download: verify the source, checksum and signature yourself before opening them.