Commit e8ef982
authored
The change-password handler validated strength via checkPassword (zxcvbn only,
returns the raw string) then persisted it verbatim. The user model has no
pre-save hash hook, so the new password landed in the DB in plaintext — storing
credentials at rest AND locking the user out on next signin (comparePassword
compares the entered password against the stored plaintext, never matching).
Mirror the sibling reset() path: hashPassword(checkedPassword) before persisting.
Tests: strengthen the change-password success test to read the stored value and
assert bcrypt format (/^$2[aby]$/), plus a runtime signin oracle (new password
authenticates, old one 401). This bug shipped undetected because no test ever
checked the persisted value. Verified the strengthened test fails on the
pre-fix code.
Follow-up (out of scope, downstream ops): remediate any already-corrupted rows
with a plaintext password persisted before this fix.
1 parent 2344d4c commit e8ef982
2 files changed
Lines changed: 24 additions & 3 deletions
File tree
- modules
- auth/controllers
- users/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
| 167 | + | |
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| |||
| 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 | | - | |
| 84 | + | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
92 | 112 | | |
93 | 113 | | |
94 | 114 | | |
| |||
0 commit comments