-
-
Notifications
You must be signed in to change notification settings - Fork 23
Fixes OWASP/mastg#2585 [MASWE-0021] Weak Hashing #2
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
Open
sydseter
wants to merge
19
commits into
OWASP:main
Choose a base branch
from
sydseter:MASWE-0021
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
02e96fa
Fixes #2585
sydseter 293a15a
Change status
sydseter f7898fe
Add back description and topic
sydseter a14aded
Correct title
sydseter 4975668
Update MASWE-0021.md
sydseter 53f44d1
Remove description and tooics
sydseter 3a4d507
Remove new line
sydseter c5705b9
Update weaknesses/MASVS-CRYPTO/MASWE-0021.md
sydseter 0ea1664
Update weaknesses/MASVS-CRYPTO/MASWE-0021.md
sydseter 8fcbceb
Refine descriptions of hashing algorithm risks
sydseter 0fefdeb
Merge branch 'main' into MASWE-0021
sydseter 2c832ec
Apply suggestions from code review
cpholguera 6d59a30
Update weaknesses/MASVS-CRYPTO/MASWE-0021.md
sydseter ed0ac56
Update weaknesses/MASVS-CRYPTO/MASWE-0021.md
sydseter 76d8933
Update weaknesses/MASVS-CRYPTO/MASWE-0021.md
sydseter 8dec838
Update weaknesses/MASVS-CRYPTO/MASWE-0021.md
sydseter ca8cb0c
Remove duplicate entries in MASWE-0021.md
sydseter d889d1b
Revise MASWE-0021 to clarify hashing practices
sydseter 78c56c7
renamed MASWE-0021 -> MASWE-0119
sydseter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| --- | ||
| title: Improper Hashing | ||
| id: MASWE-0119 | ||
| alias: improper-hashing | ||
| platform: [android, ios] | ||
| profiles: [L1, L2] | ||
| mappings: | ||
| masvs-v1: [MSTG-CRYPTO-4] | ||
| masvs-v2: [MASVS-CRYPTO-1] | ||
| cwe: [328] | ||
|
|
||
| refs: | ||
| - https://developer.android.com/privacy-and-security/cryptography#deprecated-functionality | ||
| - https://cwe.mitre.org/data/definitions/328.html | ||
| - https://en.wikipedia.org/wiki/Collision_attack | ||
| - https://csrc.nist.gov/pubs/sp/800/131/a/r2/final | ||
| - https://csrc.nist.gov/pubs/sp/800/185/final | ||
| - https://csrc.nist.gov/pubs/fips/202/final | ||
| - https://csrc.nist.gov/pubs/fips/180-4/upd1/final | ||
| - https://csrc.nist.gov/pubs/ir/8547/ipd | ||
| status: new | ||
|
|
||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| Using deprecated, risky, or broken hash algorithms may compromise data integrity and make offline attacks practical. In mobile apps this often appears in three areas: hashing for integrity of local data, hashing of passwords or PINs, and hashing or deriving keys from low-entropy identifiers. Weak or misused hash functions allow adversaries to tamper with data, find collisions, recover secrets, or brute force hashed values. | ||
|
|
||
| Hash functions that no longer provide adequate [collision](https://en.wikipedia.org/wiki/Collision_attack) or [preimage](https://en.wikipedia.org/wiki/Preimage_attack) resistance, such as MD5 and SHA-1, enable adversaries to craft different inputs that produce the same hash or to recover the original input more efficiently than brute force. Similarly, using generic fast hash functions for low-entropy inputs like passwords, PINs, device identifiers, or email addresses allows practical offline brute force or dictionary attacks. | ||
|
|
||
| Hash-based KDFs such as HKDF are suitable only when the input secret already has high entropy. They are not appropriate as substitutes for password hashing functions because they do not provide work factors or memory hardness. | ||
|
sydseter marked this conversation as resolved.
|
||
|
|
||
| ## Impact | ||
|
|
||
| - **Account compromise**: Storing passwords, PINs, tokens, or other low-entropy secrets using fast generic hash functions such as SHA-256 allows attackers who obtain the hashes to perform offline brute force attacks and recover credentials. | ||
| - **Loss of integrity**: If an app uses a collision-prone or structurally weak hash to protect configuration files or offline data, an attacker may modify the data and still pass integrity checks by generating a colliding value. | ||
| - **Loss of confidentiality**: If encryption keys or key encryption keys are derived by hashing low-entropy input, such as device identifiers or user passwords, attackers can brute force the hash, recover the key, and decrypt protected data. | ||
|
sydseter marked this conversation as resolved.
|
||
|
|
||
| ## Modes of Introduction | ||
|
|
||
| - **Using a deprecated, risky, or broken hashing algorithm**: Examples include MD5 and SHA-1, which have practical collision attacks faster than the birthday bound. | ||
| - **Using non-resource-intensive algorithms on low-entropy input**: For example, hashing passwords or PINs with a single SHA-256 call instead of using a proper password hashing function with salt and work factor. | ||
| - **Using unsafe or overly short truncation of hashes**: For instance, truncating a message digest to below the recommended lengths reduces its security strength. [NIST SP 800-107 Rev 1](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-107r1.pdf) indicates: "The length of truncated message digests used shall be at least twice the desired security strength required for the digital signature". | ||
|
|
||
| ## Mitigations | ||
|
sydseter marked this conversation as resolved.
|
||
|
|
||
| - **Choose collision-resistant algorithm with sufficient bit-lengths**: Choose SHA-2 (256, 384, or 512 bits) or the SHA-3 family for integrity and fingerprinting purposes. | ||
| - **Match the algorithm to the purpose**: Use password hashing functions for passwords and PINs. Use hash-based KDFs only when the input secret already has high entropy. Do not treat general-purpose hash functions as password hashing or key stretching mechanisms. | ||
| - **Avoid truncating hashes too aggressively**: As stated in [NIST SP 800-107 Rev 1](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-107r1.pdf), ensure that when truncating digests, the truncated length is at least twice the targeted security strength. | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.