Security Model
Threat model
The daemon is designed against two different adversaries, and its guarantees are not the same size against each:
- A remote attacker — phishing, a stolen backup, a compromised CI secret, malware on a different machine. They have no code execution on your Mac and no way to reach the Secure Enclave at all.
- Local malware running as you — something with code execution under your own user account, able to talk to
gpg-agent(and thereforescdaemon-se) and to read/write your Keychain, exactly like any other process you run.
Non-extractability (the private key never leaves the Secure Enclave) and user-presence gating (Touch ID/passcode required for every private-key operation) are both real, hardware-enforced properties. What they prove differs sharply between those two adversaries.
What Touch ID proves — and what it doesn’t
Every signing, decryption, and authentication operation requires a Touch ID or passcode approval, enforced by the Secure Enclave’s .userPresence access control flag — this cannot be bypassed in software, and each prompt names the card and key slot involved (e.g. “Sign with your scdaemon-se Secure Enclave key — card X (OPENPGP.1)”).
Against a remote attacker, this is close to airtight: there’s no way to trigger the prompt from outside the machine at all, and the key material itself can never be exfiltrated.
Against local malware, it’s weaker than it might sound. The prompt proves a human approved some operation on that card/slot — it does not show what is being signed or decrypted, and it looks identical whether it was raised by your own git commit -S or by malware that issued its own SETDATA/PKSIGN request in the moment you happened to approve something. This is a structural limit of presence-only gating (as opposed to a smartcard with a PIN pad or a token that displays the transaction being approved) — not a bug, since a raw 32-byte digest isn’t something a human could meaningfully review even if it were shown. Treat approving a prompt as proof that you, at your Mac, just authorized an operation — not as proof that you reviewed and approved the specific content being signed. Keeping the machine free of malware matters; this daemon alone isn’t a defense against an attacker who already has code execution as you.
There is no separate PIN or passphrase — CHECKPIN and PASSWD are unconditional no-ops (see Assuan Reference) because authentication happens at the Secure Enclave hardware level, not in software.
Key substitution detection
Because the Keychain only stores an opaque handle to each Secure Enclave key, and any process running as you can read and rewrite that handle, the daemon can’t simply trust “whatever key is currently stored under this tag.” To catch a handle being silently swapped for a different key, every key is pinned the first time it’s generated (or first loaded, for a key that predates this mechanism): its keygrip is recorded, and every subsequent load recomputes the keygrip and compares it. A mismatch is refused outright, rather than the daemon silently using — or silently regenerating over — whatever key it finds.
This is trust-on-first-use, not cryptographic attestation: an attacker with the same Keychain write access used to substitute a key could, in principle, also rewrite its pin at the same time. It raises the bar against accidental or opportunistic tampering and closes a specific gap (a substituted key being silently “cured” by quiet regeneration) — it does not prove the key genuinely originated in this specific Secure Enclave to a remote verifier. That kind of proof would need hardware attestation entitlements that aren’t available to an unsigned command-line tool.
The two danger-gated operations
Two operations are disabled unless explicitly enabled via an environment variable, because they risk permanent, unrecoverable data loss rather than a merely-inconvenient one:
| Operation | Risk if used casually | Env var |
|---|---|---|
Creating the encryption key (OPENPGP.2) | Anything encrypted to it is lost forever if the device is lost — there’s no backup or export path for a Secure Enclave key. | SCDAEMON_SE_ALLOW_ENCRYPTION |
--export-public-key | Roots your entire OpenPGP identity in a single non-backupable device; losing it orphans your whole web of trust. | SCDAEMON_SE_ALLOW_MASTER |
Signing and authentication don’t carry this risk in the same way — a lost signing or auth key is rotatable (revoke it, issue a new one), which is why those two operations work with no opt-in required. See Use Cases for the reasoning behind which use cases fit this trade-off and which don’t.