-
-
Notifications
You must be signed in to change notification settings - Fork 8
Adds to OWASP/mastg#2588 [MASWE-0024] Weak Message Authentication Codes (MAC) #3
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
base: main
Are you sure you want to change the base?
Changes from 12 commits
a2af71d
d6381c7
dedf092
167b9c2
ba0fef2
4b1d324
8eff3e3
c9122d1
b9ab458
a7c258d
8b2bebb
9df0ed1
13c9257
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,33 @@ status: placeholder | |
|
|
||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| Improper use of a MAC, e.g., not using proper nonces or timestamps, may allow MAC forgeries, making it possible to compromise the authenticity and integrity of the data. | ||
| Not applying the MAC in the correct order when using CBC mode during encryption, e.g., creating the MAC before encrypting the data instead of after to ensure the authenticity and integrity of the encrypted data. | ||
| Another common issue is using an HMAC with any type of general-based hashing algorithm like MD5, SHA-1, SHA-2 or even SHA-3 on low-entropy input like user-supplied passwords, pins or other user-controlled predictors. HMACs aren't designed for low-entropy inputs or low-entropy keys. Doing so will result in producing "weak" message digests that can easily be exploited. | ||
| Deprecated or risky HMAC implementations like HMAC-MD5 or HMAC-SHA1 are vulnerable to collision attacks that would compromise the authenticity and integrity of the data. Collision attacks can also be made possible through truncating the HMAC digest. If truncating is necessary for interoperability, never truncate the digest below 128 bits and use the full HMAC whenever possible. Finally, never create checksums using non-cryptographically secure algorithms like CRC‑32, which are not meant for cryptographic purposes. | ||
|
|
||
| ## Impact | ||
|
|
||
| - **Loss of authenticity**: Improper use of MAC may allow an attacker to compromise the authenticity of the data, making the data appear authentic. | ||
| - **Loss of Integrity**: Improper use of MAC may allow an attacker to alter the data, thereby compromising its integrity. | ||
| - **Loss of Confidentiality**: Using MAC for other purposes than authentication may lead to a complete loss of confidentiality. | ||
|
|
||
| ## Modes of Introduction | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's also structure this section into MAC and HMAC and their respective "issues". Also the draft section in header, has more inspiration, like insecure hash function for HMAC (we can link to related WE)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added all the cases mentioned in the header now. |
||
|
|
||
| - **Not including a timestamp**: Creating a MAC for message authentication without using a proper timestamp that can be validated to protect against MAC forgery. | ||
| - **Using a MAC with low-entropy keys**: Using low-entropy inputs or low-entropy keys as input to a HMAC. | ||
| - **Using a MAC with a predictor**: Using data controlled by the user to create a HMAC signature. | ||
| - **Using a deprecated or risky MAC implementation**: Using e.g, HMAC-MD5 or HMAC-SHA1, which are known to be vulnerable to collision attacks. | ||
| - **Using a non-cryptographically secure algorithm**: Using CRC‑32, which is not meant to be used for cryptographic purposes. | ||
| - **Truncating the HMAC digest too much**: Truncating the final HMAC digest makes it shorter than 128 bits. | ||
|
|
||
| ## Mitigations | ||
|
|
||
| - **Use MAC with a timestamp**: Generate the MAC over a message with the timestamp included. This should protect the application against replay attacks within a reasonable amount of time. Reasonable, meaning a time frame that is short enough to prevent an attacker from sending an identical message and long enough to allow the message to be sent and digested. | ||
| - **Do not use HMAC together with a low-entropy key**: Ensure the keys used are generated using cryptographically secure PRNGs (CSPRNG) generate random numbers that pass statistical randomness tests, and are resilient against prediction attacks. | ||
| - **Do not use a MAC together with a predictor**: Ensure HMACs | ||
cpholguera marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **Do not use deprecated HMAC implementations**: Deprecated HMAC implementations could contain errors that allow for collision attacks. Therefore, only use recommended libraries and functions. | ||
| - **Do not use non-cryptographically secure algorithms**: Algorithms like e.g. CRC‑32 is not meant to be used for cryptographic purposes. | ||
cpholguera marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **Use the complete HMAC digest and avoid truncation**: When possible, always use the complete HMAC digest. When truncating is necessary, never make it shorter than 128 bits. | ||
Uh oh!
There was an error while loading. Please reload this page.