Status: dark spike.
apps/sso-signer (tuturuuu-sso-signer) has no
routes, no workers.dev and no preview URLs, and no CI workflow publishes it.
Nothing in apps/web calls it. Its shipped configuration refuses every sign
request. The design it implements is
Key custody and rotation.What it does
The Worker is not a raw signing oracle. A caller sends structured fields; the Worker builds the SAMLResponse and Assertion itself with
createLoginResponse from packages/sso and signs both with the same
createNodeSigner (xml-crypto 6.4.0, @xmldom/xmldom 0.9.12, node:crypto
X509Certificate) under nodejs_compat. A workerd runtime test proves that the
bundled Worker signs a response that the independent Node-SAML SP from
packages/sso accepts.
The fields: client, protocol (saml), transactionId, kid, subject
(the pairwise subject), attributes (email, firstName, lastName),
profile (entityId, acsUrl), idp (entityId, ssoUrl), request
(id used as InResponseTo, issueInstant, forceAuthn, optional
relayState), assurance (authenticatedAt, mfaVerifiedAt) and
notOnOrAfter, which becomes the assertion expiry (at most two minutes after
the Worker’s clock). The AuthnRequest itself, its signature and the profile’s
request-signing policy are admitted by apps/web; the Worker receives the
admitted request’s bound fields.
Entry points
Callers reach the Worker only through service bindings to named entry points. The default handler answers 404.
A successful sign returns
correlationId, responseId, assertionId,
samlResponse (base64), destination, relayState and expiresAt. A refusal
returns { error, correlationId } and, for protocol refusals, the SAML_ code
as reason. Logs carry the correlation ID and an outcome code only.
Checks, cheapest first
No Durable Object is called before the request HMAC, the body, the permit and the kid binding pass, and the private key is parsed only after every check.- Path and method, then
SSO_SIGNER_FENCE_FLOOR(break-glassstopped). - Request HMAC. Headers
x-ttr-sso-timestamp(Unix ms),x-ttr-sso-nonce(base64url, 16 to 32 bytes) andx-ttr-sso-signature: HMAC-SHA256 withSSO_SIGNER_REQUEST_KEYoverttr-sso-signer-request-v1, method, path, timestamp, nonce and the base64url SHA-256 of the body, joined by newlines. At most 60 seconds of skew. No bearer form exists. - Body against a strict schema.
- Permit.
{ v: 1, id, kid, iat, exp, fields, sig }:fieldsis the base64url SHA-256 ofttr-sso-permit-fields-v1, a newline and the canonical JSON of the wholeinput(so every field, the kid included, is bound), andsigis Ed25519 overttr-sso-permit-v1, a newline and[v, id, kid, iat, exp, fields]. The Worker holds onlySSO_SIGNER_PERMIT_PUBLIC_KEY. Lifetime is at most 60 seconds;iatmay lead the Worker clock by at most 5 seconds. - Kid binding.
SSO_SIGNER_KEYSmaps each kid (lowercase letters, digits and hyphens) to exactly oneclient, oneprotocoland its certificate, for at most eight kids. A mismatch is refused. The private key is the secretSSO_SIGNING_KEY_<KID>(kid upper-cased,-as_). - Stop fence (
SignerControl). With no record it isstopped: a fresh deployment signs nothing until an operator sets it torunning. - Daily budget (
SignerBudget): one unit per admitted request, replays included,SSO_SIGNER_DAILY_BUDGET(default 5,000) per UTC day. - Replay claim (
SignerReplay): the nonce and the permit ID together, all or nothing. - Transaction confirmation.
- Stop fence again, so a stop during the checks above also applies to this request; then build and sign.
Permit wire form
@tuturuuu/sso/signer-permit holds the one implementation of
canonicalJson, fieldsHash and the signed message, and the issuer imports
it as the Worker does. Canonical JSON is RFC 8785 (JCS) restricted to objects
with ASCII identifier keys, well-formed strings, booleans and safe integers,
with absent members omitted, so an absent relayState and an empty one hash
differently. Known-answer vectors, including non-ASCII names and key order,
are pinned in packages/sso/src/__tests__/signer-permit.test.ts.
Durable Objects and cost bounds
All three objects use SQLite storage, are named<role>:<SSO_SIGNER_ENV>, and
set no alarms.
SignerReplaydeletes at most 32 expired rows per claim, inserts at most two, keeps its live count in a meta row instead of scanning, and refuses new claims at 50,000 live rows (fail closed). Rows outlive acceptance: a nonce row is kept 120 seconds (twice the skew) past its timestamp and a permit row 60 seconds past its expiry.SignerBudgetkeeps only the current UTC day’s row.- An isolate remembers a
stoppedfence for 10 seconds and an exhausted budget until its UTC midnight, so a flood against a stopped or exhausted signer costs no object calls.runningis never cached, so a stop applies to the next request.
Transaction confirmation (later slice)
src/transaction-confirmation.ts defines the TransactionConfirmation port:
resolve ok only when the consumed transaction transactionId matches the
bound fields, failing closed on any error. It will be backed by a Worker-only
database role that can read only an approved, consumed, not-yet-signed
transaction; that role needs a migration and lands separately. Until then
every deployed build uses refuseAllConfirmation.
uncheckedLocalConfirmation exists only for the workerd runtime test. It is
behind the build-time constant __SSO_SIGNER_UNCHECKED__
(src/build-defines.ts): the Vite build and unit tests define it false, so
the bundler removes the unchecked branch, and only the runtime test bundle
defines it true. Even there it is selected only when
SSO_SIGNER_TRANSACTION_CHECK is unchecked-local and SSO_SIGNER_ENV is
local. A test bundles the Worker with the production define and checks that
the unchecked path and every test fixture (child_process, Node-SAML) are
absent and that it refuses to sign in workerd with the unchecked bindings set.
Configuration
Key sets (
SSO_SIGNER_REQUEST_KEY, SSO_SIGNER_PERMIT_PUBLIC_KEY,
SSO_SIGNER_CONTROL_KEY) are one base64url 32-byte key, or JSON
{"current","previous"} during a dual-publish rotation.
Tests
apps/sso-signer/src/*.test.ts run under vp test:
- request HMAC: bad signature (key, body, method, path, nonce, flipped byte), skew, malformed headers, bearer refusal, rotation;
- permit: foreign key, changed signature or claim, expiry, future
iat, lifetime over 60 seconds, a mismatch on every structured field (derived from the input’s leaf paths) and rotation; a replayed permit under a fresh nonce; - kid binding: unknown kid, another client or protocol, missing secret, malformed maps;
- replay store bounds, retention past the acceptance edge and concurrent claims of one token, budget cap and day rollover, fence default and control keys, the fence re-read before signing, and the isolate guards;
- the confirmation selection over every mode and environment pair;
- the handler end to end through Node-SAML, including log redaction;
worker-runtime.test.ts: the esbuild bundle in workerd (Miniflare 4,nodejs_compat), through both named entry points. Miniflare 4’s workerd accepts compatibility dates up to 2026-08-06, so the test runs at 2026-08-01; the deployed config’s later date adds no flag the Worker uses. The bundle turns CommonJSrequireof Node built-ins (xml-crypto’srequire("crypto")) intonode:imports, as the Cloudflare Vite plugin does.
Deployment plan
Deployment is held. Each step needs the release authority:- Route choice, later. The Worker stays without routes or custom domains.
apps/webwill reach it through a service binding toSignerEntry; adding any public route or domain is a separate reviewed change. - Staging first. Publish to staging only after the transaction
confirmation slice is merged. The release authority sets
SSO_SIGNER_ENVtostaging, writes the staging secrets and kid map, sets the fence torunningthroughControlEntry, and runs acceptance against the local Node-SAML SP before any real SP. - Rollback. Stop signing at once by setting the fence to
stopped(or deployingSSO_SIGNER_FENCE_FLOOR: 'stopped');apps/webkeeps its Node signer path until the Worker is accepted, so turning the Worker off restores the current behavior. Keep the previous Worker version for a one-step version rollback. - Production deploys and production secrets need the release authority’s explicit ACK. A production kid is written only by the release authority, and rotation follows the dual-publish schedule in the design.