S15-02 - The Secret Store
Purpose: Where credentials are held: the secret store, its backends, and the guarantees a backend must give.
Design
Section titled “Design”The store holds credentials
Section titled “The store holds credentials”Every credential is nominally held by the configured secret store. The store keeps them in a container that holds only Wraith Box’s items.
- No Wraith Box process is the holder for another.
- No process gets a secret from the store through another.
- One secret passes between two of them before it is written to the
store.
wbhands the value the user enters forwb cred settowb-credseton its standard input (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., rule 5).
Keys that must never leave hardware, which means the CA signing key, are in the platform’s hardware key store, whatever the backend. That holds on every host that has one (S12-platformsS12-platforms: PlatformsWhich host and guest operating systems Wraith Box targets, how platform-specific code is isolated, what each platform uses, and how wb works inside WSL.). On macOS the store holds only the key’s wrapped form, which no other Mac can use (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”).
Keychain
Section titled “Keychain”The Keychain backend is the data protection keychain, in every build that a team signs. It has one access group per role. So each item is reachable only by the binaries of its role, and there is nothing to unlock.
Release builds are signed with Wraith Box’s Developer ID. Development builds are signed with the developer’s own Apple Development certificate. They use the provisioning profile that Xcode makes for the developer’s team (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., S12-03-host-prerequisitesS12-03-host-prerequisites: Host PrerequisitesWhat wb setup checks on each host, and how a development build on macOS gets signed., “Development builds on macOS”).
The groups are named <TEAMID>.nl.wraithbox.<role>, where <TEAMID>
is the team that signed the build. So a development build’s groups
differ from a release build’s and from another developer’s.
That a program signed by another team can’t name them is assumed. 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… had one team, and a profile grants only groups under its own team’s prefix.
Each program that holds a group is a bundle of its own, with the profile embedded (S10-tech-stackS10-tech-stack: Technology ChoicesFix languages, libraries, packaging, and repository layout, with the reason for each choice.).
| Role | Items | Programs that hold the group |
|---|---|---|
binding |
binding/<name> |
wb-credset, wb-proxyd |
ca |
ca/<vm>/<ca> |
wb-proxyd |
wbadmin |
wbadmin/build/<build>, wbadmin/image/<image>, wbadmin/vm/<vm>/<disk> |
wb-guestadmin |
A group lets the programs that hold it read, write and delete its
items. So an access narrower than that, such as wb-credset’s write
of bindings, is enforced by our code (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., rule 1).
wb doesn’t hold a group (“wb doesn’t hold a group” below).
Each item is a generic password whose service attribute is the item
name and whose account attribute is the fixed wraithbox. Every call
names the data protection keychain (kSecUseDataProtectionKeychain),
the item’s group, the account, and kSecAttrSynchronizable false. A
query without an account matches every account. With the fixed one,
each item name is one item, and no call matches an item another
program of the team wrote in the group under another account.
A write sets the protection class
kSecAttrAccessibleWhenUnlockedThisDeviceOnly. An item with it stays
on this Mac and can be read only while the Mac is unlocked. A write of an
item that exists updates its value in place, so there is no moment
without the item. A list asks for the items’ attributes, never their
values. The cgo shim returns the call’s status and nothing else: a
message from Security.framework can name an item’s attributes, so Go
writes the log line (“Failed store calls”).
The binding secrets are written, listed and deleted by wb-credset,
which wb cred runs (S15-06-binding-commandsS15-06-binding-commands: The Binding CommandsHow wb cred sets, lists and removes the binding secrets in the secret store through the wb-credset helper, while wb itself holds no store access.).
The group of each call
Section titled “The group of each call”Each Keychain call names its group. The cgo shim (S12-platformsS12-platforms: PlatformsWhich host and guest operating systems Wraith Box targets, how platform-specific code is isolated, what each platform uses, and how wb works inside WSL.) sets
kSecAttrAccessGroup to <TEAMID>.nl.wraithbox.<role>:
<role>is the first part of the item name;<TEAMID>is the team identifier of the process’s own code signature. The shim reads it once at start, and never takes it from configuration or a request.
The signature is read from the files on disk, which can change while
the process runs. So the shim first checks that the code directory on
disk still matches the running code, with what it hashes, the
Info.plist among them (SecCodeCheckValidity). The check doesn’t
cover the bundle’s resource files, and the shim reads nothing from
them: the team, the identifier and the executable come from the code
directory and the Info.plist. A signature that fails the check counts
as unreadable, which every check refuses: the team is then none, with
keychain-needs-team. The groups come from the kernel’s copy of the
process’s entitlements (SecTaskCopyValueForEntitlement), the one
the Keychain checks, never from the files.
Without the attribute, a write by a process with two groups, such as
wb-proxyd, would go to the first group of its entitlements. A ca/
item could then end up in binding.
Each call states the group its caller expects. Before any Keychain
call, the shim refuses in each of these cases with the rule
store-group-mismatch, and logs the item and both groups:
- the group isn’t the one the item name gives;
- the process’s entitlements don’t hold the group.
An entitlement set the shim can’t read counts as not holding it.
The program a caller opens the store as decides which accesses the
checks allow (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., “Declared access”). So the shim
also reads the CFBundleExecutable of the Info.plist that the
process’s own signature seals, once at start. When it isn’t the
program’s executable (wb-credset, wb-proxyd or wb-guestadmin),
or there is none, every call is refused with the rule
store-program-mismatch. The signing identifier can’t tell the
programs apart: each helper bundle has the app’s bundle identifier,
which its profile matches (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…). The shim logs the
identifier and the executable when it opens. An ad-hoc build is
refused with keychain-needs-team first.
Ad-hoc signed builds
Section titled “Ad-hoc signed builds”An ad-hoc signed build has no Keychain backend. A CI build is one, and so is the build of a developer without an Apple ID in Xcode.
Each process with store access reads the team identifier of its own
code signature at start. With none, it refuses every Keychain access
with the rule keychain-needs-team, and logs it. So in such a build
these are refused with that rule:
- a session that needs a binding;
- each VM start, because it needs a CA item (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., “Valid CA”);
wb cred set, throughwb-credset;wb image buildand thewbadminrotation at first contact, because they needwbadmin/*items.
wb setup refuses to set up the Keychain backend in such a build,
with the same rule, and says what to do:
- Sign in to Xcode with an Apple ID.
- Build once in the Xcode app.
- Build Wraith Box with the team set (S12-03-host-prerequisitesS12-03-host-prerequisites: Host PrerequisitesWhat wb setup checks on each host, and how a development build on macOS gets signed., “Development builds on macOS”).
wb setup still does the rest of its work, the per-user services
included. Then it exits with a nonzero status.
1Password
Section titled “1Password”The 1Password backend comes after V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there. (I151I151 (open): S15-least-privilege: 1Password as a secret store backendS15-least-privilege (PR #149, B145-least-privilege) makes the configured secret store the nominal holder of every credential, with the macOS Keychain first and 1Password next.), so the Keychain is V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there.’s only backend. It is the desktop app integration, with one vault per role. It doesn’t need a service account token in the store. It runs only after the user turns it on by name.
Backend guarantees
Section titled “Backend guarantees”A backend must give these guarantees:
| Guarantee | Keychain | 1Password |
|---|---|---|
| G1. A container of Wraith Box items only | yes | yes, a vault |
| G2. Each item reachable only by its declared processes | yes, by code signature, per access group | enforced by our code only |
| G3. Locked or unreachable fails, with no fallback | yes | yes |
| G4. Values never written outside the store | yes | yes |
G2 on the Keychain has these limits:
- A group’s holders reach every item in it (“Keychain”, above).
- In release builds, only Wraith Box signs with its team.
- In development builds, the groups are team-wide. The free profile
grants every group under the developer’s team (
<TEAMID>.*). So another program that the developer’s team signs can claim Wraith Box’s groups (“Team-wide groups in development builds” below).
On 1Password, a compromised declared reader reaches every item in the vaults the session has open. A vault per role narrows that.
A backend without G1, G3 or G4 is refused.
For a backend where our code alone enforces G2, these say so:
wb setup, wb cred list, and the audit record of each session start.
The build compiles in the ID of Wraith Box’s release team. A
development build is one signed by any other team. In a development
build, wb setup, wb cred list and that audit record also name the
signing team. They say that every program that team signs can reach
Wraith Box’s groups.
A fallback is never silent.
Failed store calls
Section titled “Failed store calls”Each failed store call is logged with the call, the item, the status and the rule. That holds in every build and on every backend.
- A binding that isn’t in the store refuses a session start that
needs it. On the Keychain that is -25300 (
errSecItemNotFound).wbnames the binding and says to set it withwb cred set. - A locked store is rule 7 of 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.. On the Keychain that is -25308.
- A CA item follows 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., “Valid CA”.
- Any other failure of a binding or
wbadmin/*read isstore-read-failed, -34018 (errSecMissingEntitlement) among them. The work that needed the item is refused with it. - A failed write or delete of any item is
store-write-failed, outside the cases above and the CA issue of 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., “Valid CA”. The command or work that made it is refused with it. - The store logs a missing item with
store-item-not-found, and a locked store withstore-locked. The caller then refuses or waits under its own rule. - A macOS build without cgo has no Keychain shim (S10-01-librariesS10-01-libraries: LibrariesThe libraries and programs Wraith Box uses, and their licenses.). It
refuses every store call with
store-shim-missing.
Decisions
Section titled “Decisions”One access group per role, in every team-signed build
Section titled “One access group per role, in every team-signed build”The Keychain backend is the data protection keychain, with one access group per role.
- Why: each item is then reachable only by the binaries of its role, and there is nothing to unlock.
- Decided: 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…, B248-dev-signingB248-dev-signing: Can development builds signed by the developer's own team share Keychain items across an update?Yes, with conditions..
wb doesn’t hold a group
Section titled “wb doesn’t hold a group”- Why:
wbparses guest terminal output (S16-terminal-streamS16-terminal-stream: Terminal StreamHow wb guards boundary 6 of T00-index, the guest output that wb writes to the user's terminal.) without a sandbox. So a bug there doesn’t reach the store (SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential.). And AMFI never refuses to startwbfor a profile. - Decided: I252I252 (closed): S15-least-privilege, S09-policy-credentials-audit, S10-tech-stack: team-signed development builds and no ad-hoc Keychain, from B248-dev-signingThe maintainer decided B248-dev-signing on 2026-10-15, in the #248 comment that starts Decision (2026-10-15):: option A..
Team-wide groups in development builds
Section titled “Team-wide groups in development builds”Another program that the developer’s team signs can claim Wraith Box’s groups in a development build.
- Decided: accepted on 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…, B248-dev-signingB248-dev-signing: Can development builds signed by the developer's own team share Keychain items across an update?Yes, with conditions..
Status: Draft