fix(kdf): neutralize the /migrate-kdf endpoint server-side (6c-1 / 6c-4)

6c-1 removed the client caller, but the server handler stayed armed: a stray
authed+CSRF'd call could still re-encrypt only 1 blob of 8 (data loss) or
rewrite a -v2 account's hash_algo (permanent lockout, 6c-4). Gutted the ~165
destructive lines and replaced the body with an auth+CSRF gate then HTTP 410.
Both risks are now closed server-side, not merely unreachable by convention.
The vestigial kdfMigration login signal is left (client ignores it, endpoint
410s) — removing it would cascade through a login-path param for no benefit.
Fixed the now-false comments pointing at migrate-kdf.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-07-20 05:43:39 +01:00
parent 47aec30934
commit 370432f638
2 changed files with 27 additions and 188 deletions
+9 -6
View File
@@ -729,11 +729,14 @@ l'a déjà fait (et après **6c-2** les deux sont sur la même base de temps).
### 6c-4. 🟡 `/migrate-kdf` rétrograderait un compte `-v2` (verrouillage définitif)
> ⛔ **SANS OBJET depuis 6c-1 (2026-07-16).** Le chemin migrate-kdf est
> désactivé côté client (fonction `runKdfMigration` supprimée, triggers
> retirés). L'endpoint reste inerte (rien ne l'appelle) → ce scénario de brick
> n'est plus atteignable. Garde à ré-ajouter uniquement si migrate-kdf revenait
> un jour.
> ✅ **RÉSOLU 2026-07-16.** Au-delà de 6c-1 (client), l'endpoint serveur
> `HandleMigrateKdf` a été **vidé de ses ~165 lignes destructrices** et remplacé
> par un reject `410` après auth+CSRF ([Auth.pas:656](delphi-backend/Handlers/PM.Handler.Auth.pas)).
> Un appel isolé ne peut donc plus **ni corrompre** (6c-1) **ni brick** un compte
> -v2 (6c-4) : les deux sont fermés côté serveur, pas seulement « inatteignables
> par convention ». Le signal `kdfMigration` du login reste (vestigial, client
> l'ignore, endpoint = 410) — non retiré car câblé via un paramètre sur le
> hot-path login, churn sans bénéfice.
Le garde d'idempotence ([Auth.pas:722](delphi-backend/Handlers/PM.Handler.Auth.pas:722))
ne court-circuite que si l'algo vaut `pbkdf2-sha256`. Un compte `argon2id-v2` ou
@@ -950,7 +953,7 @@ Le second est correct **dans les deux cas** (no-op si c'était déjà le défaut
| **6c-2** | 🟠 | — | ✅ **Fait** — `expires_at` en UTC. Ferme §2.2. |
| **6c-3** | 🟡 | — | ✅ **Fait** — CSRF lié à la session présentée (token_hash). |
| **6c-9** | ❓ | — | ✅ **Fait** — `ForeignKeys=On` explicite. |
| **6c-4** | 🟡 | — | ⛔ **Sans objet** — l'endpoint migrate-kdf est inatteignable depuis 6c-1. |
| **6c-4** | 🟡 | — | ✅ **Fait** — endpoint migrate-kdf vidé + reject 410 (ferme 6c-1 & 6c-4 côté serveur). |
| **6c-5** | 🔵 | Trivial | À faire — 5 lignes × 2 endroits (fail-fast params Argon2). |
| **6c-6/7/8** | 🔵 | Faible | À faire — cohérence / hygiène, aucune urgence. |