Repository navigation
Commit 67beeaa
committed
web: avoid username enumeration on login timing
When the submitted username did not exist, the handler returned without
running the expensive password hash, so a missing account answered
noticeably faster than a wrong password. That timing difference lets an
attacker enumerate valid usernames.
Always verify the password, comparing against a fixed dummy hash when
the account is absent, so both cases take about the same time. Compute
that dummy hash lazily on the first login: it runs 870k PBKDF2
iterations, and every pw subcommand links in this package, so computing
it at init would needlessly slow down unrelated commands.
Signed-off-by: Robin Jarry <robin@jarry.cc>1 parent 9129ebb commit 67beeaa
1 file changed
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
23 | 34 | | |
24 | 35 | | |
25 | 36 | | |
| |||
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
85 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
86 | 107 | | |
87 | 108 | | |
88 | 109 | | |
| |||
0 commit comments