Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix(2FA): increase backup codes length for improved security

Rudy B.a9a873c293c4
diff --git a/src/components/modals/TwoFactorSuccessModal.module.css b/src/components/modals/TwoFactorSuccessModal.module.css
index 2804fe91c..aba87fdd5 100644
--- a/src/components/modals/TwoFactorSuccessModal.module.css
+++ b/src/components/modals/TwoFactorSuccessModal.module.css
@@ -1,5 +1,5 @@
.dialog {
- width: 480px;
+ width: 620px;
max-width: 95vw;
}
diff --git a/src/lib/two-factor/backup-codes.ts b/src/lib/two-factor/backup-codes.ts
index a201cf24e..256131d26 100644
--- a/src/lib/two-factor/backup-codes.ts
+++ b/src/lib/two-factor/backup-codes.ts
@@ -11,9 +11,9 @@ export async function generateBackupCodes(): Promise<{
const plaintext = Array.from(
{ length: BACKUP_CODE_COUNT },
() =>
- randomBytes(5).toString('hex').toUpperCase() +
+ randomBytes(8).toString('hex').toUpperCase() +
'-' +
- randomBytes(5).toString('hex').toUpperCase(),
+ randomBytes(8).toString('hex').toUpperCase(),
);
const hashed = await Promise.all(plaintext.map(code => bcrypt.hash(code, BCRYPT_ROUNDS)));
return { plaintext, hashed };