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.
For review
Section titled “For review”- Decides: how ad-hoc signed builds keep their store items across an update, and where the CA signing key is kept.
- You are approving: the answers below, and the 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. and 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. text
in this pull request that states what the measured fallback does
today:
- a keychain file item is reachable without a dialog only by the binaries its access-control list names, each pinned by its cdhash;
- every other reader, and every rebuilt binary, gets a dialog that asks for the password of the keychain file, which no user knows;
- code can’t repair an access-control list without that dialog, and
only
SecKeychainSetUserInteractionAllowed(false)turns the dialog into an error.
- Controls touched: SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts. (credentials are held by the store and reached only by their declared processes): unchanged by this pull request. The ad-hoc fallback gives G2 by cdhash between updates, and the update path is the first open decision. SEC14-no-fake-approvalsSEC14-no-fake-approvals: Approvals cannot be spoofed by the guestApproval prompts are never rendered in the agent's terminal stream. (a prompt is never an approval): a dialog the user can’t answer is a problem for this control. The first open decision removes it.
- Assumed:
- that an item in the login keychain gets the same dialog, asking for the login password, which the user knows. The spike didn’t touch the login keychain (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?);
- that
kSecAttrTokenOIDkeeps its valuetoidand its use for restoring a key. Security.framework exports it, but it isn’t in the SDK headers. Secretive reads the same attribute; - that a CryptoKit
dataRepresentationand the token object ID stay the same format. They were on macOS 27.0.1.
- Decisions: decided 2026-10-15, as recommended, in the 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?
comment that starts
Decision (2026-10-15):. The specs have them (I249I249 (closed): S09-policy-credentials-audit, S15-least-privilege: developer-signed builds and a wrapped Secure Enclave CA key, from B23-keychain-unsignedThe maintainer decided the two points of B23-keychain-unsigned on 2026-10-15, in the #23 comment that starts Decision (2026-10-15):.): S15-02-secret-storeS15-02-secret-store: The Secret StoreWhere credentials are held: the secret store, its backends, and the guarantees a backend must give. (“Keychain”), S15-03-access-rulesS15-03-access-rules: Access RulesHow each host process gets only the credentials it needs, for only as long as it needs them, and which process may access which item. (access rule 4, “Declared access”), a section of 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. on updates that was removed later, S09-05-credentialsS09-05-credentials: CredentialsHow credentials are stored and bound to requests, and how the model credential reaches the model API without entering the guest. (“Storage”), S09-06-ca-keysS09-06-ca-keys: CA KeysHow the key of each TLS inspection certificate authority is made, stored and restored, and when a CA is valid. (“Key”), S10-02-packaging-and-signingS10-02-packaging-and-signing: Packaging and SigningHow Wraith Box is packaged and signed on each host, and the one version every build stamps. and S12-01-platform-interfacesS12-01-platform-interfaces: Platform InterfacesHow platform-specific code is isolated behind interfaces, and what each host OS uses for each. (“Hardware key”).-
How ad-hoc signed builds keep their items across an update.
- A. Fail closed: after an update,
wbsays the store must be set up again, and the user enters each binding again. Generated items, such aswbadmin/vm/<vm>/<disk>, are lost. - B. Before the binaries are replaced, the old ones copy every item into a new keychain file whose access-control lists name the new binaries, already on disk. Adding an item with a list of other binaries didn’t raise a dialog. The whole path wasn’t run.
- C. The keychain file gets a password the user knows, so the dialog after an update can be answered once per item.
- D. No ad-hoc Keychain support: development builds are signed
with the developer’s own Apple Development certificate and a
profile with a Keychain access group, as Secretive does. Whether
a free personal team can grant
keychain-access-groupsto the helpers inWraith Box.appneeds a spike.
Recommended: D, with a spike first, and A until that spike answers. A gives the fail-closed behavior 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. already asks for, with no dialog. B and C keep a model that only exists for development builds. Decided: D, after 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… (I248I248 (closed): X29-dev-signing: Keychain access group for development builds signed by a personal teamCan a developer's free personal team (an Apple ID signed in to Xcode, no paid membership) sign the helper binaries inside Wraith Box.app (wb-proxyd, wb-hostd, wb-vmd) with a keychain-access-groups entitlement and a…), and A until that spike answers yes.
- A. Fail closed: after an update,
-
Where the CA signing key is kept. A permanent Secure Enclave key needs an entitlement, so the spec’s “key handle” isn’t available to an ad-hoc build.
- A. An ephemeral Secure Enclave key, kept as its token object ID
in the store item
ca/<vm>/<ca>, for every build. The value is usable only by this Mac’s Secure Enclave. In a signed build the access group protects the item. - B. The software fallback key 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. for ad-hoc builds, and a permanent Secure Enclave key for signed builds.
Recommended: A. Signed and ad-hoc builds share the code path, and a copied item is useless on another Mac. Secretive keeps its keys the same way. A needs one SPI symbol in the cgo shim. Decided: A. A Linux host without a TPM keeps the software key, which no macOS build uses.
- A. An ephemeral Secure Enclave key, kept as its token object ID
in the store item
-
- 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.
Question
Section titled “Question”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:
- A generic password item whose access-control list names only this
binary. Can this binary, another ad-hoc binary and
security find-generic-passwordread it, and what does a rebuild (new cdhash) do? - Can it create a P-256 Secure Enclave key, permanent and not, and
sign a certificate with it through Go’s
crypto.Signer? - How long does signing a leaf certificate take?
Answer
Section titled “Answer”- 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
securitytool, 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. - 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. - 4.7 ms per leaf with the Secure Enclave key, against 0.1 ms with a software key.
Measurements
Section titled “Measurements”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.
Keychain file
Section titled “Keychain file”| 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.
Secure Enclave
Section titled “Secure Enclave”| 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.
Leaf signing
Section titled “Leaf signing”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.
Other projects
Section titled “Other projects”Open source projects that use the Secure Enclave, read for this result:
- Secretive keeps each key
as its CryptoKit
dataRepresentationin a generic password item in the data protection keychain, behind akeychain-access-groupsentitlement and a provisioning profile. Its migration code reads thetoidattribute 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
dataRepresentationin 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.
Limits
Section titled “Limits”- The login keychain wasn’t used, so the dialog for the
unlockitem there is assumed, not seen. - Option B of the first decision wasn’t run end to end.
- A permanent key without
kSecUseDataProtectionKeychainwasn’t tried, because it would have used the login keychain. - The runs used one Mac and one macOS version.
- The spike didn’t confine the binaries. The sandbox rules for
securitydand the Secure Enclave are I61I61 (closed): X23-sandboxed-daemons: wb-proxyd profile with Keychain and Secure EnclaveSplit from #34 (X23-sandboxed-daemons) during triage on 2026-10-04., which builds on this.
What it means for the specs
Section titled “What it means for the specs”- 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.: development builds signed by the developer’s team, the ad-hoc keychain file 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…, what an update does to it (“After an update”), no Keychain dialog in any build, and the wrapped CA key in “Declared access” (I249I249 (closed): S09-policy-credentials-audit, S15-least-privilege: developer-signed builds and a wrapped Secure Enclave CA key, from B23-keychain-unsignedThe maintainer decided the two points of B23-keychain-unsigned on 2026-10-15, in the #23 comment that starts Decision (2026-10-15):.).
- 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.: “Storage” for both kinds of build, and
“Key” for the wrapped Secure Enclave key, the check that catches a
break of
kSecAttrTokenOID, and the key on each host (I249I249 (closed): S09-policy-credentials-audit, S15-least-privilege: developer-signed builds and a wrapped Secure Enclave CA key, from B23-keychain-unsignedThe maintainer decided the two points of B23-keychain-unsigned on 2026-10-15, in the #23 comment that starts Decision (2026-10-15):.). - S10-tech-stackS10-tech-stack: Technology ChoicesFix languages, libraries, packaging, and repository layout, with the reason for each choice.: the signing of development builds (I249I249 (closed): S09-policy-credentials-audit, S15-least-privilege: developer-signed builds and a wrapped Secure Enclave CA key, from B23-keychain-unsignedThe maintainer decided the two points of B23-keychain-unsigned on 2026-10-15, in the #23 comment that starts Decision (2026-10-15):.). The cgo
shim declares
kSecAttrTokenOID, which 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. states.
Spike code
Section titled “Spike code”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