Use of RSA Algorithm without OAEP

The product uses the RSA algorithm but does not incorporate Optimal Asymmetric Encryption Padding (OAEP), which might weaken the encryption.


Description

Padding schemes are often used with cryptographic algorithms to make the plaintext less predictable and complicate attack efforts. The OAEP scheme is often used with RSA to nullify the impact of predictable common text.

Demonstrations

The following examples help to illustrate the nature of this weakness and describe methods or techniques which can be used to mitigate the risk.

Note that the examples here are by no means exhaustive and any given weakness may have many subtle varieties, each of which may require different detection methods or runtime controls.

Example One

The example below attempts to build an RSA cipher.

public Cipher getRSACipher() {
  Cipher rsa = null;
  try {
    rsa = javax.crypto.Cipher.getInstance("RSA/NONE/NoPadding");
  }
  catch (java.security.NoSuchAlgorithmException e) {
    log("this should never happen", e);
  }
  catch (javax.crypto.NoSuchPaddingException e) {
    log("this should never happen", e);
  }
  return rsa;
}

While the previous code successfully creates an RSA cipher, the cipher does not use padding. The following code creates an RSA cipher using OAEP.

public Cipher getRSACipher() {
  Cipher rsa = null;
  try {
    rsa = javax.crypto.Cipher.getInstance("RSA/ECB/OAEPWithMD5AndMGF1Padding");
  }
  catch (java.security.NoSuchAlgorithmException e) {
    log("this should never happen", e);
  }
  catch (javax.crypto.NoSuchPaddingException e) {
    log("this should never happen", e);
  }
  return rsa;
}

See Also

Comprehensive Categorization: Encryption

Weaknesses in this category are related to encryption.

OWASP Top Ten 2021 Category A02:2021 - Cryptographic Failures

Weaknesses in this category are related to the A02 category "Cryptographic Failures" in the OWASP Top Ten 2021.

Encrypt Data

Weaknesses in this category are related to the design and architecture of data confidentiality in a system. Frequently these deal with the use of encryption libraries....

Comprehensive CWE Dictionary

This view (slice) covers all the elements in CWE.

Entries with Maintenance Notes

CWE entries in this view have maintenance notes. Maintenance notes are an indicator that an entry might change significantly in future versions. This view was created...

Weaknesses Introduced During Implementation

This view (slice) lists weaknesses that can be introduced during implementation.


Common Weakness Enumeration content on this website is copyright of The MITRE Corporation unless otherwise specified. Use of the Common Weakness Enumeration and the associated references on this website are subject to the Terms of Use as specified by The MITRE Corporation.