Enjoy Sharing Technology!

Software,Develope,Devops, Security,TroubleShooting

Sunday, November 14, 2021

fortify scan: Weak Encryption: Insecure Mode of Operation

 Abstract:

Do not use cryptographic encryption algorithms with an insecure mode of operation. The mode of operation of a block cipher is an algorithm that describes how to repeatedly apply a cipher's single-block operation to securely transform amounts of data larger than a block.

Explanation:

The mode of operation of a block cipher is an algorithm that describes how to repeatedly apply a cipher's single-block operation to securely transform amounts of data larger than a block. Some modes of operation include Electronic Codebook (ECB), Cipher Block Chaining (CBC), Cipher Feedback (CFB), and Counter (CTR).

ECB mode is inherently weak, as it produces the same ciphertext for identical blocks of plain text. CBC mode is vulnerable to padding oracle attacks. CTR mode is the superior choice because it does not have these weaknesses.

Example 1: The following code uses the AES cipher with ECB mode:

  ...

  var objAesCryptoService = new AesCryptoServiceProvider();

  objAesCryptoService.Mode = CipherMode.ECB;

  objAesCryptoService.Padding = PaddingMode.PKCS7;

  objAesCryptoService.Key = securityKeyArray;

  var objCrytpoTransform = objAesCryptoService.CreateEncryptor();

  ...

Recommendations:

Avoid using ECB and CBC modes of operation when encrypting data larger than a block. CBC mode is somewhat inefficient and poses a serious risk if used with SSL [1]. Instead, use CCM (Counter with CBC-MAC) mode or, if performance is a concern, GCM (Galois/Counter Mode) mode where they are available.

Example 2: The following code uses the AES cipher with GCM mode:

  ...

  var cipher = new AesGcm(securityKeyArray)

  ...

  

  

Share:

0 comments:

Post a Comment

Search This Blog

Weekly Pageviews

Translate

Blog Archive