Use of RSA Algorithm without OAEP

The software 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

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.

Weaknesses without Software Fault Patterns

CWE identifiers in this view are weaknesses that do not have associated Software Fault Patterns (SFPs), as covered by the CWE-888 view. As such, they represent gaps in...

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.