-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift: Query for Use of an inappropriate cryptographic hashing algorithm on passwords #15122
Conversation
… (naming consistency, remove unused import).
…ed a password / key rather than a miscellaneous credential.
…g but not for password hashing.
QHelp previews: swift/ql/src/queries/Security/CWE-328/WeakPasswordHashing.qhelpUse of an inappropriate cryptographic hashing algorithm on passwordsHash functions that are not sufficiently computationally hard can leave data vulnerable. You should not use such functions for password hashing. A strong cryptographic hash function should be resistant to:
Password hashing algorithms should be slow and/or memory intensive to compute, to make brute force attacks more difficult. RecommendationFor password storage, you should use a sufficiently computationally hard cryptographic hash function, such as one of the following:
ExampleThe following examples show two versions of the same function. In both cases, a password is hashed using a cryptographic hashing algorithm. In the first case, the SHA-512 hashing algorithm is used. It is vulnerable to offline brute force attacks:
Here is the same function using Argon2, which is suitable for password hashing:
References
|
DCA shows 4 result changes:
The run also shows some "interesting" rows for stage timings, which look like they might be an unintended result of changes to the DCA rules (i.e. they shouldn't be flagged?). Overall analysis time is fine. I will look into this next year and most likely do another DCA run to confirm. |
Everything looks good on the repeat DCA run:
|
swift/ql/src/queries/Security/CWE-328/WeakPasswordHashing.qhelp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Only some minor thoughts and one or two small typos.
swift/ql/src/queries/Security/CWE-328/WeakPasswordHashing.qhelp
Outdated
Show resolved
Hide resolved
swift/ql/src/queries/Security/CWE-328/WeakPasswordHashing.qhelp
Outdated
Show resolved
Hide resolved
swift/ql/src/queries/Security/CWE-328/WeakPasswordHashing.qhelp
Outdated
Show resolved
Hide resolved
swift/ql/src/queries/Security/CWE-328/WeakPasswordHashing.qhelp
Outdated
Show resolved
Hide resolved
Co-authored-by: Ben Ahmady <[email protected]>
Thanks for the docs review @subatoi . All points addressed, but please don't hesitate to make further suggestions if anything isn't quite right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @geoffw0, thank you!
@rdmarsh2 could I have a final 👍 from you (or request more changes). |
New query for Use of an inappropriate cryptographic hashing algorithm on passwords.
This query is designed to be used alongside the existing
swift/weak-sensitive-data-hashing
query, and I've made some adjustments to that query to avoid duplication and to make sure results are reported by the most appropriate query. Previously:Now:
To do this I had to make passwords an explicit kind of sensitive data in Swift (
SensitivePassword
), and I added MAD syntax for it (sensitive-password
). I also fixed the sensitive data regular expressions for mobile phone numbers, added a couple of missing sinks for sensitive data hashing, and made some class names consistent while I was working in this area.TODO: