12 KiB
title | date | tags | author | ||
---|---|---|---|---|---|
macOS Security Overview | 2024-08-09 |
|
kimg45 |
macOS comes equipped with many security features to keep you safe. Check out the Apple Platform Security page for more detail about the security features in a Mac. This guide assumes you're running on official Apple hardware that's officially supported by the latest stable version of macOS.
FileVault
By default, your macOS install is encrypted, but it will automatically unlock on boot. Turning on FileVault will require a user password to unlock the volume. It also makes it so that you need to enter a user password to enter recovery mode.
App Sandbox
The App Sandbox is a feature that limits the access an app has to the rest of your system. Developers enable it when they sign their app, so it's not possible for you to enable it or modify the entitlements since they are defined in the signature.
The App Sandbox is designed to limit the damage to your system in the event an app is exploited, however it can't protect against malicious developers since they can just disable or weaken the sandbox in a future update if they want. For protection against malicious developers, you'll need to install apps from the App Store where the sandbox is enforced.
There are a few ways to check whether an app is sandboxed:
You can check whether running processes are sandboxed in the Activity Monitor. Right click on the columns and check "Sandbox"
You can check whether an app is sandboxed and what entitlements it has by running the command
% codesign -dvvv --entitlements - <path to your app>
If the app is sandboxed, you will see
[Key] com.apple.security.app-sandbox
[Value]
[Bool] true
You can enable a column in Activity Monitor called "Restricted" which is a flag that prevents programs from injecting code via macOS's dynamic linker. Ideally, this should say "Yes."
Hardened Runtime
The Hardened Runtime is an optional security feature that developers can enable that makes an app more resistant to exploitation. It prevents certain classes of exploits, like code injection, dynamically linked library (DLL) hijacking, and process memory space tampering.
Unlike the App Sandbox, the Hardened Runtime is required in order for an app to be notarized and so you'll be warned by Gatekeeper if an app doesn't use it. While this warning is bypassable, you should be cautious and investigate a bit more before running it.
Check if an app is using the Hardened Runtime before running it with the command
codesign --display --verbose /path/to/bundle.app
You will see flags=0x10000(runtime)
if it's enabled.
Gatekeeper
Gatekeeper stops you from running apps that aren't notarized. Notarization is a process by which app developers submit their app to Apple to scan for malware and ensure it meets certain requirements. Among these are that it is signed with a key provided by Apple to the developer and that the Hardened Runtime is enabled. Gatekeeper also prevents the loading of unwanted plugins with benign apps by opening apps from randomized, read-only locations.
While the Gatekeeper warning can be easily bypassed by control + clicking on the app and clicking open, it's useful since it presents an unavoidable warning when you try to run an app for the first time that's not downloaded from the App Store.
XProtect
XProtect is the built-in antivirus software in macOS. Like all AV, it's a last line of defense after all others have been bypassed.
XProtect uses YARA signatures and is updated frequently, independent of OS updates. This is one of the many reasons you should be cautious about blocking connections to Apple servers; many of them serve a security purpose, so make sure you know what you're blocking. It can also detect unknown malware using heuristics. When it detects unkown malware, it will send information about that software to Apple so that they can update the signatures in XProtect.
Apple also issues revocations for notarization tickets, which are detected with encrypted online OCSP checks. Blocking these checks will make you more vulnerable to malicious apps.
System Integrity Protection
SIP protects system files from being changed, even by the root user. Since it's protecting your base system files, you should never disable it even temporarily if you want the best security.
On Apple Silicon Macs, it's combined with Kernel Integrity Protection to protect kernel memory from being exploited.
Secure Boot
Mac computers ensure that only Apple-signed code runs from the lowest levels of the firmware to macOS itself. It accomplishes this with a chain of trust that starts with the Boot ROM burned into the Secure Enclave at the factory as the first step.
A unique feature of Mac computers is that you can set a different security policy for different installs, so you could have your main macOS with Full Security set and also an Asahi Linux install set to Permissive Security and it won't affect the security of your macOS. Avoid lowering the security policy below Full Security for any operating system you require to be secure, even temporarily.
DMA Protection
Mac computers have an IOMMU so that each DMA agent, including PCIe and Thunderbolt ports, can only access memory explicitly mapped for their use.
Lockdown Mode
Lockdown Mode is an optional security feature that disables lots of attack surface in your Mac. It may break certain things like websites or apps, but you can disable it for individual apps or websites if you need to.
Custom umask
macOS is a Unix-like, so certain security practices carry over from other systems. Consider setting a stricter umask.
Terminal Secure Keyboard Entry
To prevent other apps from detecting what you type in Terminal, enable Secure Keyboard Entry.
Standard User Account
When you first set up your Mac, you will create an Administrator account that has powerful access to the OS. Apple recommends limiting the number of Administrator accounts on your machine and using a Standard user account when Aministrator privileges aren't needed.
You can hide an administrator account so you don't accidentally log into it.
Also make sure to set a strong password for any accounts you make and set a time after which a user will automatically be logged out.
Lock Screen Security
Make sure you require users to login and set your Mac to require a password after waking up.
Use the Control + Command + Q keyboard shortcut to lock your screen any time you leave your computer.
Prevent Windows from Reopening
When you restart your Mac, you'll get a dialog box that asks if you want to reopen windows when you restart. It's best to turn this off to prevent data from previous sessions from being retained.
Automatically Empty Trash
You can set the trash to automatically empty every 30 days to prevent old unwanted files from sticking around.
Show File Extensions
You should set Finder to always show all file extensions to help you see when a file is masquerading as another filetype.
System Extensions
There are two types of system extensions on macOS: legacy system extensions (also known as kernel extensions) and system extensions. Kernel extensions modify the actual kernel, giving the software extremely low-level access to your system. These are very dangerous and in fact you need to lower your security policy to even load them. They're being phased out more and more with every version of macOS.
Newer system extensions don't directly modify the kernel, but they use APIs that give them lower level access to your system than regular apps. You should be very cautious with these as well and only allow them when absolutely necessary.
Apps Requiring Admin
Be careful installing apps that require Administrator privileges to run, you're giving them a lot of power in your system.
Note: When mounting a .dmg file, usually a graphic will come up asking you to move the app to your Applications folder, which will trigger an Administrator popup. The app isn't actually running, you're just moving it to the systemwide Applications folder so that all users on the system can run it. If you're not comfortable with this, you can simply drag the app anywhere else and run it.
.dmg files are just a disk image that you're mounting, similar to a virtual flash drive. These won't run any scripts on your machine, they simply allow you to copy the app to wherever you want on your machine and then run it. .pkg files are a bit different in that they will typically run some kind of install script, which most of the time requires Administrator privileges. You should favor .dmg over .pkg format when downloading apps from the internet.
Firewall
macOS comes with a built-in firewall. Make sure it's enabled at the very least, but you can block all incoming connections for the best security/privacy.
Disable AirDrop and Handoff
You can disable AirDrop and Handoff to better protect yourself against nearby threats. Turn off "Allow Handoff between this Mac and your iCloud devices," change "Airdrop" to "No one," turn off "AirPlay Receiver," and turn on "Require password."
Disable Bluetooth
Bluetooth adds extra attack surface for nearby adversaries, so if that fits your threat model then you should disable it.
Hardware Microphone Disconnect
Macs feature a hardware disconnect for the microphone when you close the lid. There is no such feature for the camera as it's blocked when the lid is closed anyway.