C05 - Credentials and the Secret Store
Purpose: The test cases for the secret store and its callers, the
signing setup that gives development builds their Keychain groups, and
the credential checks wb-proxyd makes on guest requests and server
responses.
Verifies: 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-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., 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”, rule 8), 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., 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”), 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., S07-08-requests-and-credentialsS07-08-requests-and-credentials: Requests and CredentialsThe form of each request wb-proxyd sends upstream, and how it removes the guest's credentials and injects bound ones. (“Credential replacement”)
Unit tests
Section titled “Unit tests”Store errors
Section titled “Store errors”- Make the call that turns Keychain dialogs off fail, and see the
process refuse every store access with
store-dialogs-on. - With a fake store:
- return -25300 for a binding, and see the binding’s own refusal;
- return -25308, and see the work wait for the unlock and name the store;
- return -34018 and another status for a binding and for a
wbadmin/*item, and see each refused withstore-read-failed; - fail a
wb cred setwrite, awb cred rmdelete and awbadmin/*write with -34018, and see each refused withstore-write-failed; - for a CA item in the record, see -25300 and every status other than
-25308 give
ca-key-restore.
- A locked store, -25308 on the Keychain, makes the work wait for the unlock, for a CA item as for any other.
- Each log line names the failed call.
The store’s side of these cases is in internal/platform/secretstore,
over the fake of secretstore/storetest: TestC05StoreDialogsOn,
TestC05StoreErrorsNotFoundLocked, TestC05StoreErrorsReadFailed,
TestC05StoreErrorsWriteFailed and TestC05StoreAccessUndeclared.
Each of them also searches the log for the value it wrote and finds
none. The waits, the binding’s refusal and ca-key-restore are the
callers’ tests.
Access groups
Section titled “Access groups”Spec: 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”.
- A table test maps each item name form of “Declared access” to its
group,
<TEAMID>.nl.wraithbox.<role>, with the team from the process’s own signature. - Ask the shim to write a
ca/item with thebindinggroup, and to use a group the process’s entitlements don’t hold, and see each refused withstore-group-mismatchbefore any Keychain call. - A shim whose own entitlements can’t be read refuses every call with
store-group-mismatch. - Open the store as one program in a process whose signed Info.plist
names another program’s executable, or none, or can’t be read, and
see every call refused with
store-program-mismatch(TestC05StoreProgramMismatch, over the fake). - Start a copy of the test binary from a bundle signed ad hoc, sign the
bundle again under another identifier while it runs, and see the
copy read its identifier and executable before, and after it see the
signature refused (OSStatus -67034), no group read, and the open
refused with
keychain-needs-team(TestC05AdhocSwap, on macOS CI). TestC05AccessGroupsininternal/storeitemis the table test.TestC05AccessGroupsMismatchandTestC05AccessGroupsUnreadableininternal/platform/secretstoreare the refusals, over the fake.- The build check of S10-tech-stackS10-tech-stack: Technology ChoicesFix languages, libraries, packaging, and repository layout, with the reason for each choice. fails a bundle whose helper has a
group more or less than its row in 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”,
and one where
wbor any other program outside the table has an entitlement that names a group:keychain-access-groups, the application identifier, or application groups. It also fails each entitlement outside the build’s allowlist, such asget-task-allowin a team build, and a program another team signed. A profile that doesn’t decode, or names another team or two, fails it too. So does the app executable with the entitlements Xcode signed it with, as if step 7 hadn’t signed it again. The tests are theTestC05BuildCheckones ininternal/appbundle, with every case of S17-01-bundleS17-01-bundle: The BundleWhat a Wraith Box bundle holds, and how mise run build builds and signs it., “The entitlement check”.TestC05BuildSigningIdentitysees the build choose the team’s one Apple Development identity by the OU of its certificate, and fail on none or two. One certificate listed twice counts once.TestParseTeamininternal/platform/codesignrefusescodesignoutput with twoTeamIdentifierlines, or a value that isn’t a team ID.
Builds without a team, and development builds
Section titled “Builds without a team, and development builds”-
In an ad-hoc signed build:
- see
wb setuprefuse the Keychain backend withkeychain-needs-teamand name the setup steps of 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”; - see
wb-proxydrefuse a binding fetch and a CA issue,wb-credsetrefuse the write ofwb cred set, andwb-guestadminrefuse the items ofwb image buildand of a rotation, each with the same rule and logged, before any Keychain call; - see
wb setupstill install the services and exit nonzero.
The
wb setupcases areTestC05SetupAdhocKeychainininternal/setup. A bundle with profile files and ad-hoc signatures is still ad-hoc:wb setupreads the signature. The store’s own refusal isTestC05StoreNeedsTeamininternal/platform/secretstore, over the fake, andTestC05AdhocShim, which opens the darwin backend from the ad-hoc test binary on macOS CI.TestNoShim, whichgo:testruns withCGO_ENABLED=0, sees a darwin build without cgo refuse every call withstore-shim-missing. - see
-
In a development build, see
wb setup,wb cred listand the session-start audit record name the signing team and say the grant is team-wide. Thewb setupcase isTestC05SetupTeamReport, which also sees the accept logged underkeychain-team. -
Give
wb setuphelpers that don’t agree on one team: another team’s signature, an ad-hoc one among team ones, an unreadable signature, and a profile that is missing, a link, of another team, without a team name, or of another team name. See each refused withkeychain-team-mixedafter the install, and a nonzero exit (TestC05SetupTeamMixed).
Cleanup of generated items
Section titled “Cleanup of generated items”- End a build that passed and one that failed, and see
wb-hostdstartwb-guestadmin-cleanup, which deletes that build’swbadmin/build/<build>item and logs it (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 8). Make that run fail, and seecleanup-failedlogged and the item removed by the next run. The test comes with the end of a build inwb-hostd, which no code has yet.
wb-credset
Section titled “wb-credset”- Pass a third argument, one argument, an environment variable not on
its fixed list, an unknown operation, and a binding name outside the
fixed form, and see each refused with
credset-refusedbefore any store call. - Run
wb cred set, and seewb-credsetget the value on its standard input only, never in its arguments or environment. - Run
wb cred list, and see it print names and no value.
TestC05CredsetRefused in internal/credset is the first case, and
TestC05CredsetWrite, TestC05CredsetWriteRefusedValue,
TestC05CredsetList, TestC05CredsetDelete,
TestC05CredsetDeleteMissing, TestC05CredsetStoreErrors and
TestC05CredsetNeedsTeam run each operation over the fake store. Each
searches the output for the value and finds none.
TestC05CredsetAdhocWrite and TestC05CredsetAdhocRefused in
cmd/wb-credset run the test binary as wb-credset on macOS. They see
it confine itself, and refuse with keychain-needs-team and
credset-refused. TestC05CredsetStartRefused sees it exit 1 when it
can’t set its core file limit to 0 or can’t confine itself, before it
reads its standard input. It logs a refusal with credset-no-core,
the sandbox’s rule, or credset-not-confined.
The wb cred side is in internal/credcmd. Its tests put a copy of the
test binary at wb-credset’s place in a bundle, and run it as the
helper. TestC05CredSetFromPipe and TestC05CredSetFromPrompt see wb
pass the value to the helper on its standard input only, with two arguments
and an empty environment. The value is in nothing wb or the helper
prints or logs. TestC05CredSetNewline sees one trailing newline
removed, and TestC05CredSetValueRefused an empty or too long value
refused before the helper starts. TestC05CredNameInvalid sees a bad
name refused with exit 2 before anything is read.
TestC05CredHelperRule, TestC05CredHelperNoDecision and
TestC05CredHelperKilled see wb print the helper’s rule and its fix to the
user, and a helper that ended on SIGKILL named.
TestC05CredList, TestC05CredListBadName and TestC05CredRm cover
list and rm. TestC05CredHelperOutputCut sees output longer than
wb keeps fail the run, and TestC05CredHelperNoRead a helper that
exits without reading the value. TestC05CredBundleCheck sees another
build version, an unstamped wb, a missing Info.plist and a linked
helper path refused. TestC05CredNoCore and TestC05CredPromptLimit
cover the core file limit and the prompt’s line limit, and
TestC05CredHostLater and TestC05CredWindowsLater a host later in
the platform matrix.
On 2026-11-10 the maintainer ran wb cred on the head of PR744PR744 (merged): feat(wb): wb cred set, list and rm through wb-credsetwb cred set, wb cred list and wb cred rm now manage the binding secrets in the store.
(9b3f461a) with a team build installed in ~/Applications. Each step
passed, with no Keychain dialog:
wb setupexited 0 and printed the note on team-wide groups;wb cred setfrom a pipe and from the prompt, which showed no characters, each ended withcredset-done;wb cred listprinted both names, and the team note on standard error;wb cred rmremoved both. A secondrmprinted only the note on standard error, withstore-item-not-found, and exited 0. A list after it printed no names;- with an ad-hoc build,
wb setuprefused withkeychain-needs-teamand exited 1, andwb cred setexited 255 with the same rule; - no output file held a value.
A first try of wb cred set, run through a remote session while the
console screen was locked, got store-locked (-25308). The system log
showed the Keychain locked, and Xcode got the same error. The fix wb
prints names the Mac’s own screen for that reason
(TestC05CredLockedFix).
Signing profile
Section titled “Signing profile”Spec: 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”.
- Give
wb setupandwb statusa profile that expires in 29 days, and see them print the date and the fix. Give them one that expires in 31 days, and see them print nothing about it. Seewb-hostdlog the warning at start for the first and not the second. - Build with
WB_TEAM_IDset and no profile from Xcode, and see the build fail before it makes the bundle.TestC05BuildMissingProfileincmd/wb-dev-appfeeds the build’s profile check a missing profile, a directory, and a profile of another team or of two. - Send a fake
wb-launcherreport of a group helper’s exit onSIGKILL, and seewb-hostdlogsigning-profile-expiredwith an expired profile, and a plain exit with a valid profile and with none. - With an expired profile, see
wb setup,wb statusandwb claudeprint the date andsigning-profile-expired, andwb cred setdo the same whenwb-credsetexits onSIGKILL. - See
wb-launcheraccept a table whose entries nameContents/Helpers/<name>.app/Contents/MacOS/<name>in the installed bundle, and still refuse one under<data>.
Host tests
Section titled “Host tests”Spec: 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” and “The group of each call”; 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., “No Keychain dialogs” and rule 7.
These need the data protection keychain, so they run only on a Mac
with a team and its profile, in an attended session
(docs/agents/host-work.md). mise run store:host-test, with
WB_TEAM_ID set and after a team build of app:bundle, signs the
test binary of internal/platform/secretstore with the team’s
identity into .scratch/store-test/wb-store-test.app, with the
binding and ca groups, and into wb-store-test-binding.app, with
binding alone. Each bundle gets a copy of the app’s profile. It runs
them with an empty environment but for WB_STORE_HOST_TEST=1,
WB_STORE_HOST_STEP and WB_STORE_HOST_G2_OUT. The tests, and the
read-back of an item’s attributes that only they use, build only with
the wbstorehost tag, which the task sets and no program’s build does.
CI lints them with the tag and doesn’t run them, and without the
variables each one skips. Each test
item is wraithbox/binding/wbtest-<random> or
wraithbox/ca/wbtest-<random>/wbtest-<random>, removed when its test
ends, and the run fails when a wbtest- item is left. The maintainer
sees no dialog at any step. The same task runs the CA key’s host tests
of C02-streams-and-tlsC02-streams-and-tls: Streams, TLS, and the Inspection CAThe test cases for the streams wb-proxyd takes over: the hand-off from wb-netd, the first-byte and TLS checks, upstream addresses, the HTTP request form, and the inspection CA's leaves, rotation, and keys., “CA key”, in the bundles wb-hwkey-test.app,
with the ca group, and wb-proxyd.app, with both groups. Their CA
items are wraithbox/ca/wbtest-<random>/<CA id>, and each test
deletes its items by name. wb-proxyd may not list the ca group.
TestC05HostSweep in wb-store-test.app lists the groups through the
backend instead, outside any program’s checks. The sweep-before step
at the start of the run deletes what an earlier run left. The
sweep-after step at the end fails when the run left a wbtest- item.
The sweep deletes only names of the shapes the tests make, each random
part 12 hex digits and a CA id 32, and fails on any other wbtest-
name and leaves it: a user’s binding may be named wbtest-prod
(TestC05HostSweepShapes).
TestC05HostEnvironment: the environment holds only the two variables, the bundle holds its two groups, and dialogs are off after an open.TestC05HostProgramMismatch: the real shim reads the bundle’s own executable and signing identifier, and an open aswb-credsetis refused withstore-program-mismatch.TestC05HostBindingRoundTrip: write, fetch, update by a second write, list and delete of abinding/item, aswb-credsetandwb-proxyd, with the value read back equal and the list holding names only.TestC05HostCARoundTripdoes the same for aca/item. Both read the item’s attributes back: one item, in the group of its role, with the accountwraithbox, withkSecAttrAccessibleWhenUnlockedThisDeviceOnly, and not synchronizable.TestC05HostNotFound: a fetch of a missing item givesErrNotFound.TestC05HostGroupMismatch, in thebinding-only bundle: a fetch of aca/item is refused withstore-group-mismatch, and the same fetch and a list made on the backend past the checks get -34018 from the Keychain.TestC05HostLocked, with-- --lockalone: the test waits while the maintainer locks the screen, sees a fetch giveErrLocked(-25308), then waits for the unlock and sees the same fetch succeed.TestC05HostConfineAfterOpenopens the store, confines the process with the store-only profile of S04-03-self-sandboxingS04-03-self-sandboxing: Self-SandboxingHow each host daemon confines itself at startup, and the wb-launcher that starts confined programs on macOS., and makes a round trip.TestC05HostConfineFirstconfines first, then opens, and sees the open refused withkeychain-needs-team: the profile blocks the read of the process’s own signature (OSStatus 100001).TestC05HostG2, with-- --g2alone: the test holds abinding/item and prints asecurity find-generic-password -s <item>command, which names no group. The maintainer runs it in another terminal, and the test sees it not find the item, and the item still there after (G2 of 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.).
On 2026-11-10 the maintainer ran these on the head of PR743PR743 (merged): feat(go): Keychain item calls in the secret store's cgo shimThe macOS secret store can now really write, read, update, delete and list items in the Keychain, where until now every call stopped before it reached it., with a team build. Each passed:
- the confine-first step still got OSStatus 100001, from the read of the signature before the validity check;
- the lock step got -25308 while the screen was locked, and the fetch succeeded 24 seconds later, after the unlock;
- for G2,
securityprinted “The specified item could not be found in the keychain.”; - the maintainer saw no dialog.
Fuzzing
Section titled “Fuzzing”- The credential parameter scan of query strings and of form and JSON bodies (X22-no-guest-credentialsX22-no-guest-credentials: Clients without guest credentialsWhich common clients (Homebrew against ghcr.io, git, gh, npm, pip, uv, SwiftPM, Go, cargo, Claude Code) break when wb-proxyd removes every guest-supplied Authorization header and cookie on inspected hosts?).
- Item names, which the CA removal list gets from
wb-hostd(T16-hostd-landingT16-hostd-landing: A compromised `wb-hostd` decides what `wb land` brings inwb-hostd faces the guest, and it may read every project's export.git and write every project's landing.git (S04-03-self-sandboxing, "Each host daemon is self-sandboxed").):FuzzItemNameininternal/storeitem.
Conformance
Section titled “Conformance”- Send an attacker-supplied token in a credential parameter that a git
host’s profile names, and get a
403: GitLab’sprivate_tokenin the query string, asprivate%5Ftoken, asprivate_token[], repeated, empty, as a form-encoded body field, as amultipart/form-datapart, as a top-level JSON key, and as a JSON-escaped key ("private\u005ftoken") (X22-no-guest-credentialsX22-no-guest-credentials: Clients without guest credentialsWhich common clients (Homebrew against ghcr.io, git, gh, npm, pip, uv, SwiftPM, Go, cargo, Claude Code) break when wb-proxyd removes every guest-supplied Authorization header and cookie on inspected hosts?). - Send a JSON body that doesn’t parse, or one past the size cap with no
Content-Length, and get a403. - Send a token on a GET, and see it removed.
- Send a credential that is neither a placeholder nor a fixed value, and find a detection finding with its header name and no value.
- Send a credential placeholder outside its binding (another host, a
query string, a body), and get a
403. - From an inspected host with a credential binding, fetch a response
that sets a cookie and has
X-OAuth-Scopes,X-Accepted-OAuth-ScopesandX-OAuth-Client-Idheaders, and see none of them reach the guest, and a log record with each name and no value.
Status: Draft