Commit dcb3f03
Fix flaky 2FA encryption test for AES-256-CBC wrong-key behavior
AES-256-CBC without authentication doesn't guarantee that wrong-key
decryption throws — it only throws when PKCS7 padding is invalid,
which is probabilistic (~255/256 chance). About 1 in 256 runs, the
decryption silently produces garbage instead of throwing.
Changed the test to verify the correct security property: wrong-key
decryption must never return the original secret. Both outcomes
(throw or garbage) are acceptable.
Audited production usage: both decryptSecret call sites in
two-factor-authentication.service.ts always use the correct key via
generateOtpSecretEncryptionKey(userId, workspaceId), so the
silent-garbage behavior cannot affect end users.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent b107020 commit dcb3f03
File tree
1 file changed
+11
-4
lines changed- packages/twenty-server/src/engine/core-modules/two-factor-authentication/utils
1 file changed
+11
-4
lines changedLines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | | - | |
90 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
| |||
0 commit comments