﻿# V5903\. OWASP\. A cryptographically weak cipher algorithm is used in security\-sensitive code\. Consider using a stronger alternative\.

The analyzer has detected the use of a cryptographically weak encryption algorithm in security\-sensitive code\. 

Vulnerabilities related to weak encryption can be classified under the following categories in the OWASP Top 10 Application Security Risks 2025:

* [A04:2025 Cryptographic Failures](https://top10.owasp.org/2025/A04_2025-Cryptographic_Failures/)
* [A07:2025 Authentication Failures](https://top10.owasp.org/2025/A07_2025-Authentication_Failures/)

The following weak encryption algorithms can be dangerous: [DES](https://en.wikipedia.org/wiki/Data_Encryption_Standard), [RC2](https://en.wikipedia.org/wiki/RC2), and [RC4](https://en.wikipedia.org/wiki/RC4)\. They handle key lengths of up to 64 bits, which can be brute\-forced using modern technology in a relatively short amount of time\.

It is also recommended to replace the following encryption algorithms: [Triple DES](https://en.wikipedia.org/wiki/Triple_DES), [Blowfish](https://en.wikipedia.org/wiki/Blowfish_(cipher)), [CAST5](https://en.wikipedia.org/wiki/CAST-128), [TEA \(XTEA\)](https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm), and [Skipjack](https://en.wikipedia.org/wiki/Skipjack_(cipher))\. Their crypto\-resistance may be lower than that of modern ones due to outdated encryption parameters, such as small block and/or key sizes\. 

As an alternative, you can use one of the modern encryption algorithms that support block and key sizes of 128 bits or more: [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard), [Kuznyechik](https://en.wikipedia.org/wiki/Kuznyechik), [Twofish](https://en.wikipedia.org/wiki/Twofish), [Serpent](https://en.wikipedia.org/wiki/Serpent_(cipher)), [ChaCha20](https://en.wikipedia.org/wiki/Salsa20#:~:text=%5B20%5D-,ChaCha%20variant,-edit), etc\.

The example:

```cpp
func ProcessRequest(w http.ResponseWriter, r *http.Request) {
  ....
  data := []byte(r.FormValue("data"))

  key := ....
  ct := make([]byte, len(data))

  block, _ := des.NewCipher(key)
  ....
  json.NewEncoder(w).Encode(
    map[string]string{"ct": hex.EncodeToString(ct), 
                      ....},
  )
}
```

Arbitrary data is encrypted using the outdated DES algorithm\. This algorithm leaves data relatively vulnerable to a number of cryptographic attacks\. To avoid security issues, you can replace DES with a more secure algorithm that meets current standards, such as AES:

```cpp
func ProcessRequest(w http.ResponseWriter, r *http.Request) {
  ....
  key := ....
  block, _ := aes.NewCipher(key)
  ....
}
```

You can find more recommendations for secure data encryption on the OWASP Cheat Sheet Series pages, such as:

* [Password Storage Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html)
* [Cryptographic Storage Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html)