Skip to content

X09 - Keychain access without a signing identity

Purpose: The result of the spike for I23I23 (closed): X09-keychain-unsigned: Keychain access without a signing identityDoes the fallback Keychain access model from S09-policy-credentials-audit work for an ad-hoc signed binary, and can such a binary create a Secure Enclave key?. Does the Keychain model for ad-hoc signed builds in S15-least-privilegeS15-least-privilege: Least Privilege on the HostThe security design for SEC12-least-privilege: which rights Wraith Box takes on the host, where credentials are held, and how each host process gets only the credentials it needs, for only as long as it needs them. work, and can an ad-hoc signed binary without entitlements keep a Secure Enclave key for the CA of S09-policy-credentials-auditS09-policy-credentials-audit: Policy, Credentials, Certificates and AuditWhere policy comes from, how secrets are held, how TLS inspection is trusted, and what is recorded.?

Requirements: SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential., SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts., SEC14-no-fake-approvalsSEC14-no-fake-approvals: Approvals cannot be spoofed by the guestApproval prompts are never rendered in the agent's terminal stream.

Brief: B23-keychain-unsignedB23-keychain-unsigned: How do development builds without a signing identity keep their Keychain items and their CA key?Between updates the access-control list works, but after each update every item asks for a password nobody knows.

From I23I23 (closed): X09-keychain-unsigned: Keychain access without a signing identityDoes the fallback Keychain access model from S09-policy-credentials-audit work for an ad-hoc signed binary, and can such a binary create a Secure Enclave key?, for an ad-hoc signed binary with the hardened runtime and no entitlements:

  1. A generic password item whose access-control list names only this binary. Can this binary, another ad-hoc binary and security find-generic-password read it, and what does a rebuild (new cdhash) do?
  2. Can it create a P-256 Secure Enclave key, permanent and not, and sign a certificate with it through Go’s crypto.Signer?
  3. How long does signing a leaf certificate take?
  1. Yes, between updates. No across an update. The list pins each ad-hoc binary by its cdhash. A binary on the list reads without a dialog. Another binary, Apple’s security tool, and the same binary after a rebuild get a dialog that asks for the password of the keychain file. In S15-least-privilegeS15-least-privilege: Least Privilege on the HostThe security design for SEC12-least-privilege: which rights Wraith Box takes on the host, where credentials are held, and how each host process gets only the credentials it needs, for only as long as it needs them. that password is random and the user never sees it, so the user can’t answer it. No call repaired the list without the dialog.
  2. A permanent key: no. A key kept across restarts: yes. A permanent key fails with -34018 (errSecMissingEntitlement). An ephemeral key works, and its token object ID, saved, and passed back to Security.framework, restores the same key in another process, another binary, and a rebuilt binary.
  3. 4.7 ms per leaf with the Secure Enclave key, against 0.1 ms with a software key.

All runs were on the host, macOS 27.0.1 (26A434), Apple M2, Go 1.27.1, with the binaries signed codesign -s - -o runtime. The keychain was a throwaway file made with SecKeychainCreate and a random password, outside the search list, deleted afterwards. The maintainer watched the screen and answered each dialog.

Step Result
x9-a adds an item with its own access-control list no dialog. The list holds requirement: cdhash H"842344…"
x9-a adds an item whose list names x9-a and x9-b no dialog, the list holds both binaries
x9-a reads its item no dialog, 5 ms
x9-b reads x9-a’s item dialog: “x9-b wants to use your confidential information stored in “svc-self” in your keychain”, a field for the “x09” keychain password, Always Allow, Deny, Allow. Deny returned -128
security find-generic-password reads it the same dialog for security, the same password field. Deny returned exit 128
rebuilt x9-a (new cdhash) reads its item the same dialog. With the password and Always Allow, the list gained the new cdhash and kept the old one, and the next read had no dialog
rebuilt x9-a replaces a list with SecKeychainItemSetAccessWithPassword and the right password -25293, for a new access object and for the item’s own one edited in place
security set-generic-password-partition-list -k exit 0, list unchanged. These items have no partition entry, both for the default list and for a custom one

So a list grows with each build after “Always Allow”, and nothing a Wraith Box process can do without the user stops the dialogs after an update.

Turning the dialog into an error:

Read with Result
kSecUseAuthenticationUIFail ignored for a keychain file: the dialog appeared and the call waited for it
SecKeychainSetUserInteractionAllowed(false) -25293 in 9 ms, no dialog

The second call is deprecated and applies to the whole process.

Step Result
ephemeral key (kSecAttrIsPermanent false), kSecAccessControlPrivateKeyUsage, kSecAttrAccessibleWhenUnlockedThisDeviceOnly works. Signs a self-signed CA through crypto.Signer, and the signature verifies
permanent key, with kSecUseDataProtectionKeychain -34018, “failed to add key to keychain”
token object ID of the ephemeral key, from SecKeyCopyAttributes 324 bytes, saved to a file
SecKeyCreateRandomKey or SecKeyCreateWithData with the ID in kSecAttrTokenOID the same public key, in another process, in x9-b, and after a rebuild
SecKeyCreateWithData with the ID as data but without kSecAttrTokenOID a new key each time, without an error, also for random bytes
CryptoKit SecureEnclave.P256.Signing.PrivateKey(dataRepresentation:) on the saved ID the same public key. The reverse works too

The ID is wrapped by this Mac’s Secure Enclave and useless elsewhere. On this Mac any process of the user that has it can sign with the key. Neither the binary nor its signature binds it.

200 leaf certificates for a P-256 leaf key, signed by a CA key:

CA key p50 p90 p99 max
Secure Enclave 4.741 ms 4.816 ms 4.865 ms 4.878 ms
software 96 µs 100 µs 117 µs 327 µs

wb-proxyd signs a leaf once per new host name and caches it (S09-policy-credentials-auditS09-policy-credentials-audit: Policy, Credentials, Certificates and AuditWhere policy comes from, how secrets are held, how TLS inspection is trusted, and what is recorded.), so 5 ms is added to the first connection to a host.

Open source projects that use the Secure Enclave, read for this result:

  • Secretive keeps each key as its CryptoKit dataRepresentation in a generic password item in the data protection keychain, behind a keychain-access-groups entitlement and a provisioning profile. Its migration code reads the toid attribute of keys made by the Keychain and loads it with CryptoKit, the same token object ID this spike used. It has no ad-hoc path: debug builds are signed with the developer’s team.
  • age-plugin-se keeps the dataRepresentation in a mode 0600 file and is ad-hoc signed. Its design notes give the entitlement a permanent key needs as the reason it uses CryptoKit. User presence on each use is its default.

Neither uses a keychain file or access-control lists for ad-hoc binaries, and neither restores a key through Security.framework.

Throwaway code on branch spike/x09-keychain-unsigned, commit cba8309: a cgo shim over Security.framework (shim.c), the x9 commands (main.go), a CryptoKit reference (ckref.swift), and build.sh.

Status: Answered 2026-10-13: yes between updates, no across an update, and no permanent Secure Enclave key. Decided 2026-10-15 (I23I23 (closed): X09-keychain-unsigned: Keychain access without a signing identityDoes the fallback Keychain access model from S09-policy-credentials-audit work for an ad-hoc signed binary, and can such a binary create a Secure Enclave key?): 1D, with 1A until X29-dev-signingX29-dev-signing: Keychain access group for development buildsCan a developer's free personal team, an Apple ID signed in to Xcode without a paid membership, sign the helpers in Wraith Box.app (wb-proxyd, wb-hostd, wb-vmd) with a keychain-access-groups entitlement and a provisio…, and 2A