craig-intake-keyring — Signer-Key Registry Sidecar

craig-intake-keyring is a minimal workspace service (services/craig-intake-keyring/, container port 8010) introduced by ADR-042 §D8 (MR8 / #688). It exists only for the standalone-SHINES deployment.

Why it exists

craig-intake is a stateless edge (ADR-017): it validates and forwards, with no service-side DB of its own. But the standalone signature-only API needs two pieces of state: the registered public keys and the JWS replay-dedup records. Rather than smear that state into the edge, which would break ADR-017, the keyring isolates it in one tiny companion service. Crucially, it re-exposes the same HTTP contracts craig-security and craig-cases already serve, so intake’s existing SignerAuthClient and JwsReplayClient just point at the sidecar instead. No new client is needed, and JWS is verified in standalone mode exactly as it is in integrated mode.

The store holds only public keys (a passkey’s private key stays in the reporter’s authenticator; a machine client keeps its own) and replay records — all publishable, so encryption would be obscurity, not security (Kerckhoffs). This still holds after the ADR-042 §D8 amendment (2026-08-26) moved the store off an unencrypted flat JSON file onto an unencrypted Postgres database — the data’s sensitivity didn’t change, only whether one instance or N can serve it.

A browser offers a passkey only in a secure context: HTTPS, or localhost. The intake pages must therefore be served over HTTPS in production, from an origin on the keyring’s list; elsewhere /keygen, /passkeys and the report page’s signing block explain that a passkey cannot be used and offer no signing. The pages are described in Browser pages and passkeys.

Re-exposed contracts (consumed by intake unchanged)

  • GET /v1/security/signer-keys/by-kid/{kid}: returns the SignerKeyInfo shape intake deserializes, with a synthetic nil partner_id and the literal partner_status: "active", the exact value the verifier accepts, since there is no partner tenancy. It returns HTTP 404 for an unknown, pending, revoked, or expired key. Key lifecycle is enforced by withholding the key, mirroring craig-security. The response also names the key’s credential_kind, jws or webauthn (ADR-082 D1): a verifier must refuse a proof of the other kind.

  • POST /v1/cases/_internal/jws-replay-check: takes { partner_id, jti, iat } and dedups by jti. The unchanged client carries no kid; jti is a per-submission UUID, so cross-holder collision is negligible. It returns HTTP 200 for first-seen, HTTP 401 for a replay, and records past a configurable retention window are pruned. Since #732 the body optionally carries the signing receipt (signer_kid, payload_sha256, jws) — appended to the separate append-only signing_receipts evidence table on every ACCEPTANCE (a replay appends nothing; the dedup prune never touches it), making each accepted submission’s signature evidence durable and re-verifiable against the registered key (ADR-042 § Amendment 2026-08-29). An over-cap signer_kid (> 64) is a 400 and a payload_sha256 that is not 64 lowercase hex is the extractor’s 422, both before the jti is recorded; jws is bounded by the 16 KiB body limit only (#2366).

    • Passkey evidence (ADR-082 D3, #2196). The body may carry webauthn_receipt in place of the three JWS receipt members: {signer_kid, payload_sha256, authenticator_data, client_data_json, signature}, the last three unpadded base64url. On first-seen the keyring appends a webauthn row to signing_receipts holding the signed bytes, the signature, the flags byte and the signature counter, so the assertion re-verifies later from the stored row, the original canonical payload and the registered key. A body carrying both receipt shapes, or a whole passkey receipt that does not decode, is 400 with nothing written. A partial one is a plain dedup, as for JWS.

  • The receipt’s jws is bounded at intake (#2566). Intake refuses an X-JWS-Signature compact over 8 KiB (JWS_COMPACT_MAX) as the uniform 401, before it verifies or forwards it. The replay check’s body around a compact at the bound therefore fits this service’s 16 KiB body limit, and intake never meets the keyring’s 413.

Key lifecycle

  • POST /keys/register: accepts a browser-generated public JWK and a holder label (reusing craig_security_contracts::RegisterSignerKeyRequest), and stores it pending. It is unauthenticated by design: anyone may propose a key, but an admin must approve it before it can sign an accepted report. It allowlist-validates the algorithm to ES256 (ECDSA over the P-256 curve with SHA-256, the JOSE/JWA signature algorithm identifier), rejects a duplicate kid (HTTP 409), and is bounded by a max_keys cap (HTTP 429).

    • Passkeys (ADR-082 D2, #2195). The same route takes a second body. A body with "kind": "webauthn" registers a passkey: user_identifier, display_name, iat (epoch seconds) and the base64url attestation_object and client_data_json of the browser’s registration ceremony. A body with no kind member is the JWK registration above, unchanged; a kind of any other value or type, null included, a repeated kind, or a JSON body that is not an object is 400. The keyring verifies the ceremony itself before storing anything: the webauthn.create type; a challenge equal to SHA-256 of the canonical {display_name, iat, user_identifier}, which ties the labels an administrator approves to the credential created; an allowed origin; the RP ID hash; user presence and user verification; an iat no more than 5 minutes old or 30 seconds ahead; an ES256 P-256 key; and, when device-bound credentials are required, a credential that is not backup-eligible. Any failure is the fixed 400, which names no check. Success stores a new identity with one pending webauthn key whose kid is derived from the credential ID (wa_ + base64url of its SHA-256), and answers {kid, signer_key_id, status}. A credential already registered is 409; a full store is 429, counted with the JWK keys under the same lock. Labels holding a control character are refused, not cleaned: the challenge binds them as sent. intake’s POST /signed/v1/keys/register relays a passkey body to the keyring byte for byte.

  • PUT /keys/{kid}/approve (pending → approved) and PUT /keys/{kid}/revoke (→ revoked, terminal) form the admin lifecycle, gated by a constant-time admin-token bearer check (subtle::ConstantTimeEq over SHA-256 digests; an unset token fails closed). These are operator-only; there is no browser approve/revoke UI.

  • GET /webauthn/config (ADR-082 D2, #2194) serves the passkey policy this keyring owns: {rp_id, allowed_origins, require_device_bound}, from the required CRAIG_INTAKE_KEYRINGWEBAUTHN_RP_ID and WEBAUTHN_ALLOWED_ORIGINS (plus WEBAUTHN_REQUIRE_DEVICE_BOUND; WEBAUTHN_MAX_ACTIVE_PER_IDENTITY is read by later units). It is internal and unauthenticated, carrying no secret. Both SHINES intake instances fetch it at boot and refuse to start without it, so a change needs an intake restart.

  • PUT /identities/{identity_id}/revoke (ADR-082 D5, #2200): admin-token gated like approve and revoke. It revokes every passkey of one identity with a single generation bump, the backstop for devices a reporter added without an administrator. An unknown identity is 404; a missing or wrong token is 401. GET /keys shows each passkey’s identity_id, with its credential_kind and backup_eligible; it still omits the JWK and user_identifier.

  • verify-receipt (ADR-082 D4, #2201). craig-intake-keyring verify-receipt --jti <uuid> --payload <file> re-verifies every signing receipt stored for one submission. It needs only CRAIG_INTAKE_KEYRING__DATABASE_URL, runs its session read-only, and never serves or migrates. <file> is the submission’s report JSON, which the keyring never holds. For each receipt it prints the receipt id, kind, kid, the signer’s labels, when it was stored, a passkey’s flags, and VALID or INVALID: with the failing check: the payload must hash to the recorded value; the key registered for the kid must be of the receipt’s kind; the signature must verify under it; a JWS’s signed header must name this kid, jti and the recorded iat; a passkey’s signed client data must bind this jti, the recorded iat and that hash, and its signed authenticator data must carry the registered RP ID, user presence and verification, and the recorded flags. The origin inside a passkey’s signed client data is not compared with the WebAuthn policy, which the command does not load. Exit codes: 0 when every receipt is valid, 1 when any is not, 2 when no receipt is stored for the jti or the payload cannot be read as JSON. The output names the signer, so treat it as you would the key list.

  • POST /self-service (ADR-082 D5, #2198): a reporter’s operations on their own passkeys. The body is {op, credential_id, authenticator_data, client_data_json, signature, jti, iat}; op is tagged by kind: view, rename (display_name), revoke (target_kid) or add_device (new_kid, attestation_object, registration_client_data_json, registration_iat). The keyring verifies the assertion itself, over a challenge of SHA-256 of the canonical {op, iat, jti} plus the operation’s bound members: display_name for a rename, target_kid for a revoke, and for an add both new_kid and attestation_digest (unpadded base64url SHA-256 of the new device’s attestationObject, so the new public key cannot be swapped after signing), and spends the jti in its replay store.

    • Who may do what. A pending passkey may view, rename and revoke itself. An approved one may also revoke any passkey of its identity and add a device. A revoked or expired passkey, a failed assertion, a replayed jti and an operation the signer may not perform are all the same 401.

    • Answer. Every operation answers the identity as it now stands: its labels and, per passkey, kid, effective status, created_at, backup_eligible and whether it signed this request. Never a JWK or a credential ID.

    • Rename changes the identity’s display_name only, needs no re-approval, and logs the old and new names as one structured event. Revoke is terminal and bumps the revocation generation in the same transaction; a kid outside the signer’s identity is 404, like an unknown one.

    • Add device verifies the new device’s registration ceremony over the identity’s stored labels and requires it to derive to the new_kid the signer’s assertion bound (400 otherwise; 409 for a known credential; 429 for a full store). The new passkey is approved, with a generation bump, while the identity holds fewer active passkeys than CRAIG_INTAKE_KEYRING__WEBAUTHN_MAX_ACTIVE_PER_IDENTITY (default 3), and pending otherwise. The count and the insert run under a per-identity lock, so concurrent adds across keyring instances cannot approve past the cap. Administrator approval is not limited by the cap.

    • Reaching it. intake’s POST /signed/v1/passkeys relays the request to the keyring byte for byte and returns its view; the keyring’s 400, 401, 404, 409 and 429 come back as bare statuses.

  • GET /keys (#714) is a metadata-only list of registered keys for the view-keys testing aid: kid, display_name, an effective status (an approved key past expires_at reads expired, mirroring lookup_active), created_at, and expires_at. It deliberately omits the public_key_jwk and the partner-scoped holder identifier. It’s gated default-off by CRAIG_INTAKE_KEYRING__ENABLE_KEY_LIST: when off, the route is simply absent (HTTP 404, with no existence signal); when on, it’s unauthenticated like register, with the gate plus the internal-only deployment boundary as the protection. The browser reaches it only through the same-origin intake proxy GET /signed/v1/keys.

SignerAuthClient (services/craig-intake/src/api/signer_auth.rs, ADR-045, #747) caches by kid with split lifetimes: an approved key for 5 s (POSITIVE_CACHE_TTL), so a revoke stops verifying within 5 s, and an absent key (None) for 60 s (NEGATIVE_CACHE_TTL), so a key approved after its absence was cached may wait up to 60 s for its first successful verify. On the standalone-SHINES path a keyring revocation-generation bump evicts the cache at once (#892); the 5 s TTL is the fallback there. Tests register and approve a fresh kid so a pre-approval None is never cached.

Store + operations

  • Store: the craig_intake_keyring Postgres database (signer_keys, replay_records, and the #732 append-only signing_receipts), applied via the fleet’s standard ADR-063 migration gate (docker compose up craig-intake-keyring-migrate before the app boots). Like every other service database it carries the ADR-063 schema_compat_floor (migration 20261007110000_schema_compat_floor, #2605), which the serving boot’s FloorCheck::Enforce reads on an Ahead schema; 20261007120000_passkey_identities raises it to its own version. The service can run as N horizontally-scaled instances sharing the one database: duplicate-kid rejection and approve/revoke are exact via ordinary Postgres constraints/row updates; register’s `max_keys capacity check is exact via a transaction-scoped advisory lock serializing register calls fleet-wide; and replay_check — the security-critical operation — is a single atomic upsert (INSERT …​ ON CONFLICT …​ DO UPDATE …​ WHERE), so two instances racing the same jti cannot both accept it as first-seen. See docs/modules/ROOT/pages/plans/archive/keyring-postgres-backend.adoc and the ADR-042 amendment for the full design and the two S3-based alternatives rejected before this one.

  • Credential kinds (ADR-082 D1/D4, #2193): every signer_keys row has a credential_kind, jws or webauthn. A jws row is today’s key, with its holder labels on the row. A webauthn row is a passkey: it belongs to one signer_identities row, which carries the labels. A trigger refuses any change to user_identifier, the identifier an admin approves on; display_name is the label ADR-082 D5 lets the reporter change. It records its credential_id (unique), the rp_id it was created under, and whether it was backup_eligible at registration; its own label columns are NULL. Reads join the identity and resolve the labels with COALESCE, so every read path returns labels for both kinds. signing_receipts likewise holds exactly one evidence shape per row: the detached JWS compact, or the WebAuthn authenticator_data, client_data_json, DER signature, flags and sign_count. CHECK constraints make a mixed row unrepresentable in both tables; rows written before the migration are jws and unchanged. A second trigger, signer_keys_webauthn_binding_fixed, refuses any change to a webauthn row’s identity_id, credential_kind, credential_id, rp_id, public_key_jwk or kid, including turning a jws row into one, so an approved passkey cannot move to another identity, credential or key pair; KeyringState::register writes jws rows only. Passkey registration and verification arrive in later units (U4, U5).

  • Image: Alpine, musl, rustls; runs non-root, with a HEALTHCHECK.

  • Devstack: a craig-intake-keyring compose service plus an xtask port mapping (container port 8010; the host port is ephemeral, allocated by cargo xtask dev and recorded in .ports.env — cargo xtask dev status shows the live mapping — while the raw docker compose fallback still publishes the default host port 8012). The admin token is the devstack-only ADMIN_TOKEN: devstack-keyring-admin-token.

Deployment boundary

The keyring is internal-network-only in production: no CORS, and it’s never host-published. The registration page proposes a passkey by POSTing same-origin to an intake proxy (POST /signed/v1/keys/register), which forwards server-side to the sidecar, so the browser only ever talks to intake’s origin (ADR-042 §D9). The devstack host-port mapping exists purely as a test convenience, letting the signed-API e2e and the Rust integration tests drive the admin approve route directly.

Edit this page · latest