Commit a7d0f4b
fix(security): use CSPRNG for password and OTP generation
Replace Math.random() with cryptographically secure alternatives in two
security-critical code paths:
- generatePassword() in encryption.ts: use randomBytes() (already
imported) instead of Math.random() for deployment password generation
- generateOTP() in chat OTP route: use crypto.randomInt() instead of
Math.random() for authentication code generation
Math.random() is not cryptographically secure — its output is
predictable and can be reconstructed from a few observed values. Both
functions generate authentication material that directly protects user
accounts and deployed workflows.
This PR was authored by Claude Opus 4.6 (AI), operated by @MaxwellCalkin
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8c0a2e0 commit a7d0f4b
File tree
2 files changed
+4
-3
lines changed- apps/sim
- app/api/chat/[identifier]/otp
- lib/core/security
2 files changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | | - | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
0 commit comments