fix: user passwords cleanup#1202
Merged
Merged
Conversation
1. Adds benchmarks comparing bcrypt and our pbkdf2 settings 1. Changes the pbkdf2 hash iterations back to 65k. 1024 is insecure 1. Gets rid of the short circuit when the user isn't found, preventing timing attacks which can reveal which emails exist on a deployment
Codecov Report
@@ Coverage Diff @@
## main #1202 +/- ##
==========================================
- Coverage 66.27% 65.35% -0.92%
==========================================
Files 265 261 -4
Lines 16681 16750 +69
Branches 157 157
==========================================
- Hits 11055 10947 -108
- Misses 4484 4658 +174
- Partials 1142 1145 +3
Continue to review full report at Codecov.
|
kylecarbs
approved these changes
Apr 28, 2022
| // uses pbkdf2 to ensure FIPS 140-2 compliance. See: | ||
| // https://csrc.nist.gov/csrc/media/templates/cryptographic-module-validation-program/documents/security-policies/140sp2261.pdf | ||
| func Compare(hashed string, password string) (bool, error) { | ||
| // If the hased password provided is empty, simulate comparing a real hash. |
Member
There was a problem hiding this comment.
Is this so attackers can't use a timing attack to check if the user has no password set?
Contributor
Author
There was a problem hiding this comment.
It's for users that don't exist, so that there's no difference in response times based on if the user exists or not.
kylecarbs
pushed a commit
that referenced
this pull request
Jun 10, 2022
1. Adds benchmarks comparing bcrypt and our pbkdf2 settings 1. Changes the pbkdf2 hash iterations back to 65k. 1024 is insecure 1. Gets rid of the short circuit when the user isn't found, preventing timing attacks which can reveal which emails exist on a deployment ``` $ go test -bench . goos: linux goarch: amd64 pkg: github.com/coder/coder/coderd/userpassword cpu: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz BenchmarkBcryptMinCost-16 1651 702727 ns/op 5165 B/op 10 allocs/op BenchmarkPbkdf2MinCost-16 1669 714843 ns/op 804 B/op 10 allocs/op BenchmarkBcryptDefaultCost-16 27 42676316 ns/op 5246 B/op 10 allocs/op BenchmarkPbkdf2-16 26 45902236 ns/op 804 B/op 10 allocs/op PASS ok github.com/coder/coder/coderd/userpassword 5.036s ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
timing attacks which can reveal which emails exist on a deployment