Skip to content

feat(auth): compare-and-swap on wrapped user secrets uploads - #111

Merged
kipavy merged 1 commit into
mainfrom
feat/wrapped-secrets-cas
Oct 14, 2026
Merged

kipavy merged 1 commit into
mainfrom
feat/wrapped-secrets-cas

Conversation

@kipavy

@kipavy kipavy commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

PUT /v1/auth/wrapped-user-secrets now takes an optional expected_wrapped_user_secrets and only writes when the stored value matches it (IS NOT DISTINCT FROM, one atomic UPDATE). On a mismatch it returns 409. A request that omits the field expects NULL. The legacy migration, the only existing caller, runs only when the value is NULL, so released clients behave exactly as before.

GET /v1/meta advertises wrapped_secrets_cas: true. Clients must not write wrapped secrets on a server that lacks the flag.

Why: the client branch VoltiusApp/voltius fix/identity-off-vault-key moves the team identity into the wrapped secrets and repairs the stored copy on any device that finds the right key. Without this check, a device holding stale secrets could overwrite a password change made on another device. The account would then no longer open with the new password.

Deploy before the client. A client from that branch never writes without the flag, so the order is safe either way. The flag is what turns the repair on.

Tests: 3 DB-backed handler tests (first upload with no expectation, replace only the expected value, refuse an overwrite without an expectation) and a meta test. The full suite passes (734). Clippy is clean.

It was also exercised end to end against a client build. A stale device's overwrite was refused with 409, and the new password's secrets stayed intact.

A device repairing its stored team identity must not overwrite a password
change made on another device. The upload now names the value it replaces
and the server answers 409 when the row holds something else.
@kipavy
kipavy merged commit 37a8305 into main Oct 14, 2026
1 check passed
@kipavy
kipavy deleted the feat/wrapped-secrets-cas branch October 14, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant