[VS-NfD] Separate token keys with HKDF and replace the homegrown JWT with jose
#188
Labels
No Label
area:auth
area:docs
area:export
area:ops
area:storage
area:supply-chain
auth
backend
blocked
collab
deployment
docs
effort:L
effort:M
effort:S
frontend
plugins
qa
vs-nfd
vs-nfd:blocker
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: stwaidele/dorfteich#188
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Plan reference:
docs/vs-nfd/20-massnahmenplan.md-> Phase 2, lines 1+2ADR: ADR 0020
Effort: L (3–5 AT)
Depends on: —
Deliberately merged from two plan checkboxes — the plan itself justifies
it: both touch
packages/shared/src/token-crypto.ts, and doing themseparately costs 5–6 AT instead of 3–5.
Context
One secret currently serves two unrelated purposes. Purpose-bound subkeys
derived via HKDF make a compromise of one path non-transferable, and a
vetted JWT implementation removes hand-written crypto from the trust
boundary. This does not introduce a new security base function
(§52 VSA) — it narrows crypto the application already performs.
Current state
COLLAB_TOKEN_SECRET(packages/shared/src/env.ts:55,142) signscollaboration tokens (
apps/collab/src/index.ts:46,apps/api/src/pages/pages.service.ts:383) and unsubscribe tokens(
apps/api/src/notifications/digest.service.ts:161,apps/api/src/notifications/notifications.controller.ts:51).packages/shared/src/token-crypto.ts:1,37implements a compact HS256 JWTwith
node:crypto(createHmac,timingSafeEqual). The file headerdocuments the reason: identical code in the CommonJS api and the ESM
collab server.
josenorjsonwebtokenis a dependency of any workspacepackage.
apps/api/src/notifications/unsubscribe-token.ts:14prefixes a
PURPOSEconstant into the HMAC input.Acceptance criteria
secret; no code path signs with the root secret directly.
jose, HS256 only,with the algorithm allowlist asserted by a test.
(CommonJS) and the collab server (ESM) — the reason the homegrown
implementation existed.
new derivation accepted) long enough to cover links already in sent
mail; the window's length and expiry date are documented.
rejected;
alg: noneandRS256are rejected.docs/architecture/security.md§"Secrets & configuration" documentsthe key hierarchy;
deploy/compose/.env.exampledocuments the rootsecret's role.
Out of scope
Rotation automation, moving secrets into an external KMS, and any change to
session cookies (see #190).
Delivered by PR #239, merged to main as
3d1f4fd. CI run 472 green; shared/collab/api suites green locally. Closing.