All rules
GCI0048InfoSecurity

Insecure Random in Security Context

Detects System.Random instantiation within 5 lines of security-sensitive identifiers such as token, apikey, salt, or password. System.Random is not cryptographically secure.

Why this rule exists

System.Random is a linear congruential generator with a predictable seed. Using it for tokens, salts, or password resets makes those values guessable by anyone who can observe a few outputs.

Code example

Triggers the rule
+ var rng = new Random();
+ var token = rng.Next().ToString("x");
Passes the rule
+ var bytes = RandomNumberGenerator.GetBytes(32);
+ var token = Convert.ToHexString(bytes);

Configuration

Disable or adjust the severity of this rule in .gauntletci.json:

{
  "rules": {
    "GCI0048": { "enabled": true, "severity": "Info" }
  }
}

See Configuration for the full schema.

Related rules

Implemented in src/GauntletCI.Core/Rules/Implementations/GCI0048_*.cs.

About the author

Eric Cogen -- Founder, GauntletCI

Twenty years in .NET production. Most of those years, the bugs that hurt me were not the ones tests caught. They were the assumptions I did not know I was making: a removed guard clause, a renamed method that still did the old thing, a catch {} that turned a page into a silent dashboard lie. GauntletCI is the checklist I wish I had run before every commit. It runs the rules I learned the hard way, so you do not have to.