Skip to content
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

[MASWE-0023] Weak Padding #2922

Merged
merged 21 commits into from
Jan 16, 2025
Merged
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a4d6067
Added MASWE-0019.md
jmariasantosdekra Aug 5, 2024
6d2ee8e
Removed blank spaces from MASWE-0019.md
jmariasantosdekra Aug 5, 2024
d09e475
Added newline at the end of MASWE-0019.md
jmariasantosdekra Aug 5, 2024
611a6df
Update weaknesses/MASVS-CRYPTO/MASWE-0019.md
jmariasantosdekra Sep 4, 2024
45ad705
Update weaknesses/MASVS-CRYPTO/MASWE-0019.md
jmariasantosdekra Sep 4, 2024
531a37a
Update weaknesses/MASVS-CRYPTO/MASWE-0019.md
jmariasantosdekra Sep 4, 2024
49dadc5
Update weaknesses/MASVS-CRYPTO/MASWE-0019.md
jmariasantosdekra Sep 4, 2024
f7fe868
Update weaknesses/MASVS-CRYPTO/MASWE-0019.md
jmariasantosdekra Sep 4, 2024
ed95b33
Update weaknesses/MASVS-CRYPTO/MASWE-0019.md
jmariasantosdekra Sep 4, 2024
ff7dff2
Update weaknesses/MASVS-CRYPTO/MASWE-0019.md
jmariasantosdekra Sep 4, 2024
9b7a164
Update MASWE-0019.md
jmariasantosdekra Sep 4, 2024
722d802
Update weaknesses/MASVS-CRYPTO/MASWE-0019.md
cpholguera Sep 4, 2024
903993b
Merge branch 'OWASP:master' into master
jmariasantosdekra Oct 15, 2024
b660943
Merge branch 'OWASP:master' into master
jmariasantosdekra Oct 28, 2024
61a1fb5
Added MASWE-0023.md content
jmariasantosdekra Oct 28, 2024
8adaaea
Removed newlines and blank spaces
jmariasantosdekra Oct 28, 2024
74d6df0
Added final blankspace
jmariasantosdekra Oct 28, 2024
0f3b756
Update weaknesses/MASVS-CRYPTO/MASWE-0023.md
jmariasantosdekra Jan 10, 2025
336a22f
Update MASWE-0023.md
jmariasantosdekra Jan 10, 2025
06ea678
Update MASWE-0023.md
jmariasantosdekra Jan 14, 2025
3251f66
remove some unneded points
cpholguera Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions weaknesses/MASVS-CRYPTO/MASWE-0023.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,37 @@ profiles: [L1, L2]
mappings:
masvs-v1: [MSTG-CRYPTO-4]
masvs-v2: [MASVS-CRYPTO-1]
mastg-v1: [MASTG-TEST-0014]

refs:
- https://developer.android.com/privacy-and-security/cryptography#deprecated-functionality
- https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
- https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38a.pdf
- https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/TechGuidelines/TG02102/BSI-TR-02102-1.pdf?__blob=publicationFile
draft:
description: The use of weak padding such as NoPadding, ZeroPadding, etc. in a security
sensitive context should be avoided to ensure the integrity and authenticity of
the data.
topics:
- NoPadding
- PKCS1-v1_5
status: draft

---
jmariasantosdekra marked this conversation as resolved.
Show resolved Hide resolved

## Overview

Outdated or weak padding schemes, such as PKCS1v1.5 or other padding schemes that fail to comply with secure standards, such as NIST SP 800-56B are not recommended for use. These padding schemes include vulnerabilities that may allow attackers to undermine security mechanisms, such as padding oracle attacks.
jmariasantosdekra marked this conversation as resolved.
Show resolved Hide resolved

## Impact

Weak padding schemes can completely undermine the security of the cryptographic algorithms, exposing sensitive data to attackers, and making systems vulnerable to various attacks. This can lead to:

jmariasantosdekra marked this conversation as resolved.
Show resolved Hide resolved
- **Data breaches**: Weak padding can lead to unauthorized access to sensitive data, resulting in data breaches.
- **Loss of data integrity**: Padding attacks may aid attackers in manipulating ciphertext, leading to unauthorized data modifications.
- **Compromised confidentiality**: Weak padding may aid attackers in recovering plaintext from encrypted data.
jmariasantosdekra marked this conversation as resolved.
Show resolved Hide resolved

## Modes of Introduction

- **Insecure padding scheme**: Using padding schemes that are vulnerable to attacks, such as PKCS1V1.5 or PKCS#7 when used with CBC mode of operation.
- **Custom padding solutions**: Implementing custom or non-standard padding schemes that have not been sufficiently tested or that lack certification.
- **Improper padding validation**: Failure to correctly validate and handle padding errors, potentially leaking information to attackers via error messages or timing discrepancies.
- **Outdated cryptographic libraries**: Using libraries or algorithms with known padding vulnerabilities (e.g. Padding Oracle).

## Mitigations

- **Use standard cryptographic libraries and avoid custom cryptography**: Avoid developing custom cryptographic algorithms with custom padding schemes. Always prefer well-established and widely accepted cryptographic libraries such as OpenSSL, BoringSSL, or platform-specific libraries such as Android's Conscrypt and Apple's CryptoKit. These libraries have undergone extensive testing and are regularly updated to address new security threats.
- **Implement proper and secure padding validation**: Use established and secure padding schemes, ensuring that padding is properly validated when necessary for the encryption mode. When possible, use authenticated encryption modes like GCM, which eliminate the need for padding and include built-in integrity verification.
- **Regularly update cryptographic libraries**: Ensure the cryptographic libraries in use are up-to-date to avoid known vulnerabilities related to padding attacks.
- **Perform periodic security audits**: If using custom cryptography is unavoidable, perform regular security audits (including thorough code reviews) to identify and remediate any flaws in your custom cryptographic implementations. Engage external security experts to provide an unbiased assessment.