Property
Languagecsharp
Severityhigh
CWECWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
OWASPA02:2021 - Cryptographic Failures
Confidence LevelHigh
Impact LevelMedium
Likelihood LevelHigh

Description#

The code is generating cryptographic keys using System.Random, which is not secure for cryptographic purposes because its output can be predicted. You should use System.Security.Cryptography.RandomNumberGenerator to generate cryptographic keys safely.

Impact#

If an attacker can predict or reproduce the keys generated by System.Random, they may be able to decrypt sensitive data, forge signatures, or impersonate users. This exposes the application to serious risks such as data breaches and loss of confidentiality.