← all rules

code/py-insecure-random

Insecure randomness: random module used for security token

mediumCode regexweak-cryptoCWE-338python

What it detects

Python's random module is not cryptographically secure. Use secrets.token_* for tokens and secrets.choice for sampling.

How it runs

Applied line-by-line via a tagged regex with language-specific gating. Comments are skipped. Designed for high-confidence patterns where AST parsing would be overkill.

Found a false positive or want this rule tuned? File an issue. You can also suppress per-repo via a .repoguardignore line.