Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macOS Security Overview #270

Open
wants to merge 149 commits into
base: main
Choose a base branch
from
Open

Add macOS Security Overview #270

wants to merge 149 commits into from

Conversation

friadev
Copy link

@friadev friadev commented Aug 8, 2024

Want to cover FileVault, App Sandbox, Hardened Runtime, XProtect, Gatekeeper, Notarization, threat models for each

Disclosure: I copied/used parts of https://github.com/drduh/macOS-Security-and-Privacy-Guide?tab=readme-ov-file#app-sandbox but I wrote those parts so I'm only plagiarizing myself. I also copied parts of official Apple documentation, didn't want to change them for the sake of accurate information. Wherever I do I link back to the source.

Copy link

netlify bot commented Aug 8, 2024

Deploy Preview for privsec-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 986f23d
🔍 Latest deploy log https://app.netlify.com/sites/privsec-dev/deploys/6747bcc587c6420008f81443
😎 Deploy Preview https://deploy-preview-270--privsec-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@friadev friadev marked this pull request as ready for review August 10, 2024 04:17
@friadev friadev marked this pull request as draft August 10, 2024 04:29
@friadev friadev marked this pull request as ready for review August 10, 2024 04:37
@ghost
Copy link

ghost commented Nov 26, 2024

The reasoning needs work. This is not the reason for the attack surface

I can remove that part I guess. I'm not really aware of any other way it increases attack surface.

From https://support.apple.com/en-gb/guide/security/secebb113be1/web:

Just-in-time translation
In the just-in-time (JIT) translation pipeline, an x86_64 Mach object is identified early in the image execution path. When these images are encountered, the kernel transfers control to a special Rosetta translation stub rather than to the dynamic link editor, dyld(1). The translation stub then translates x86_64 pages during the image’s execution. This translation takes place entirely within the process. The kernel still verifies the code hashes of each x86_64 page against the code signature attached to the binary as the page is faulted in. In the event of a hash mismatch, the kernel enforces the remediation policy appropriate for that process.

Unsigned x86_64 code
A Mac with Apple silicon doesn’t permit native arm64 code to execute unless a valid signature is attached. This signature can be as simple as an ad hoc code signature (cf. codesign(1)) that doesn’t bear any actual identity from the secret half of an asymmetric key pair (it’s simply an unauthenticated measurement of the binary).
For binary compatibility, translated x86_64 code is permitted to execute through Rosetta with no signature information at all. No specific identity is conveyed to this code through the device-specific Secure Enclave signing procedure, and it executes with precisely the same limitations as native unsigned code executing on an Intel-based Mac.

@ghost
Copy link

ghost commented Nov 26, 2024

Will it be recommended to use Safari or will the recommendation be to use a Chromium-based browser?

@friadev
Copy link
Author

friadev commented Nov 27, 2024

The reasoning needs work. This is not the reason for the attack surface

I can remove that part I guess. I'm not really aware of any other way it increases attack surface.

From https://support.apple.com/en-gb/guide/security/secebb113be1/web:

Just-in-time translation
In the just-in-time (JIT) translation pipeline, an x86_64 Mach object is identified early in the image execution path. When these images are encountered, the kernel transfers control to a special Rosetta translation stub rather than to the dynamic link editor, dyld(1). The translation stub then translates x86_64 pages during the image’s execution. This translation takes place entirely within the process. The kernel still verifies the code hashes of each x86_64 page against the code signature attached to the binary as the page is faulted in. In the event of a hash mismatch, the kernel enforces the remediation policy appropriate for that process.

Unsigned x86_64 code
A Mac with Apple silicon doesn’t permit native arm64 code to execute unless a valid signature is attached. This signature can be as simple as an ad hoc code signature (cf. codesign(1)) that doesn’t bear any actual identity from the secret half of an asymmetric key pair (it’s simply an unauthenticated measurement of the binary).
For binary compatibility, translated x86_64 code is permitted to execute through Rosetta with no signature information at all. No specific identity is conveyed to this code through the device-specific Secure Enclave signing procedure, and it executes with precisely the same limitations as native unsigned code executing on an Intel-based Mac.

I'm not sure how significant those are.

@friadev
Copy link
Author

friadev commented Nov 27, 2024

Will it be recommended to use Safari or will the recommendation be to use a Chromium-based browser?

I think just leave it up to the reader.

@nihil-admirari
Copy link

NIST offers configuration profiles and scripts for automatic configuration: https://github.com/usnistgov/macos_security/tree/sequoia. Can some of them be recommended?


macOS comes with a built-in [firewall](https://support.apple.com/guide/mac-help/change-firewall-settings-on-mac-mh11783/mac). Make sure it's enabled at the very least, but you can block all incoming connections for the best security/privacy.

Avoid third-party firewalls like LittleSnitch or LuLu that require you to install a system extension. They don't cover DNS so data exfiltration is still possible.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. LittleSnitch and LuLu block outgoing connections; built-in firewall – only incoming. There's no built-in replacement for these tools.
  2. Latest version of LittleSnitch does cover DNS. With LuLu, it's possible to use dnscrypt-proxy locally.


All encryption keys are handled by the Secure Enclave. Swap space is also [encrypted](https://support.apple.com/en-euro/guide/mac-help/mh11852/mac).

Your Mac is at its most secure when it's fully off and the data is at rest. Depending on your threat model, it might behoove you to turn your Mac off completely whenever you're not using it, especially since Macs do not have memory encryption.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS can be forced to clear FileVault keys from memory when hibernating by executing:

sudo pmset -a hibernatemode 25

and installing DestroyFVKeyOnStandby profile.

@nihil-admirari
Copy link

nihil-admirari commented Jan 16, 2025

May be worth adding:

Compared to Linuxes, macOS doesn't sanitise $HOME when executing sudo: https://scriptingosx.com/2024/03/zsh-scripts-and-root-escalations/. It means that the entire content of shell init scripts is executed as root when elevating.

HOME can be removed from the following line in /etc/sudoers to mitigate it:

Defaults  env_keep += "HOME MAIL"

It may also be worthwhile to mark shell init scripts as immutable as the link suggests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[c] new content Pull requests that add an entirely new article
Development

Successfully merging this pull request may close these issues.

5 participants