fix(19): WR-03 make scrypt hashing async (threadpool) to avoid event-loop starvation DoS
This commit is contained in:
@@ -255,8 +255,8 @@ meRouter.post(
|
||||
return c.json({ error: 'No local credential found' }, 404);
|
||||
}
|
||||
|
||||
// T-19-07: verify current password before any update
|
||||
const isCorrect = verifyPassword(credRow.passwordHash, currentPassword);
|
||||
// T-19-07: verify current password before any update (WR-03: async scrypt)
|
||||
const isCorrect = await verifyPassword(credRow.passwordHash, currentPassword);
|
||||
if (!isCorrect) {
|
||||
// CR-03: return 403 (NOT 401) for a wrong current password. The PWA's global
|
||||
// MutationCache treats any 401 as "session expired" and arms the re-auth
|
||||
@@ -269,7 +269,7 @@ meRouter.post(
|
||||
try {
|
||||
await db
|
||||
.update(localCredentials)
|
||||
.set({ passwordHash: hashPassword(newPassword) })
|
||||
.set({ passwordHash: await hashPassword(newPassword) })
|
||||
.where(eq(localCredentials.userId, currentUserId));
|
||||
|
||||
return c.json({ ok: true }, 200);
|
||||
|
||||
Reference in New Issue
Block a user