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.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
fix(2FA): add `hex` key validation for `TWO_FACTOR_ENCRYPTION_KEY`
Rudy B.ebcc61c2b682
diff --git a/src/lib/two-factor/crypto.ts b/src/lib/two-factor/crypto.tsindex cc0cca056..3901351e4 100644--- a/src/lib/two-factor/crypto.ts+++ b/src/lib/two-factor/crypto.ts@@ -5,7 +5,9 @@ const ALGORITHM = 'aes-256-gcm';/** Loads and validates the 256-bit encryption key from TWO_FACTOR_ENCRYPTION_KEY. */function getKey(): Buffer {const hex = process.env.TWO_FACTOR_ENCRYPTION_KEY;- if (!hex || hex.length !== 64) throw new Error('TWO_FACTOR_ENCRYPTION_KEY is missing or invalid');+ if (!hex || hex.length !== 64 || !/^[0-9a-fA-F]{64}$/.test(hex)) {+ throw new Error('TWO_FACTOR_ENCRYPTION_KEY is missing or invalid');+ }return Buffer.from(hex, 'hex');}