Skip to main content
Founding Partner + 7-Day Trial
Tier B Enterprise Fleet · 12-Language Immunity EngineAutoExtinguish: true (4-Gate Vericoding)

AutoExtinguish: true — emits OS CSPRNG or WebCrypto primitives matched to Node, browser, Edge, or native targets.

Commercial boundary: ciphermap immunity scan, immunity extinguish --apply, immunity attest (CycloneDX 1.6 CISA IBOM & OpenVEX 0.2.0), and ciphermap mcp require Tier B Enterprise Fleet. Offline proof and IBOM verification (--verify-proof, attest --verify) and the ciphermap demo sandbox run Free.

Back to docs
IMM-CSPRNG-001HIGHCISA Secure-by-Design Pledge · CWE-330 · NIST SP 800-53 Rev. 5 (SC-13, IA-5)

Weak Non-Cryptographic PRNG in Security Token, OTP, or Secret Generation

Severity: HIGH

Predictable user-space PRNGs (V8 xorshift128+ Math.random, Mersenne Twister Python random, Go math/rand, Java java.util.Random) allow attackers who observe a handful of outputs to recover internal state and predict password-reset codes, OTPs, CSRF nonces, or API keys. IMM-CSPRNG-001 distinguishes security-sensitive token/secret contexts from benign UI jitter/shuffling and emits runtime-aware CSPRNG replacements—including WebCrypto globalThis.crypto.getRandomValues in 'use client', Edge, and Worker files.

Remediation checklist

  • Go: replace math/rand with crypto/rand; Python: replace random.choice/randint/getrandbits with secrets.token_urlsafe or secrets.randbelow.
  • TypeScript & JavaScript: use node:crypto.randomBytes / randomInt on Node backends and globalThis.crypto.getRandomValues in browser/Edge runtimes.
  • Java & Kotlin: use java.security.SecureRandom; C#: RandomNumberGenerator.GetBytes / GetInt32; Rust: OsRng; PHP: random_bytes / random_int.

Illustrative Code Examples

These fragments explain migration direction. They are not complete applications or compiler-verified patches for your project.

Vulnerable — predictable Math.random() / Python random for reset token

terminal · zsh
// TypeScript: predictable xorshift128+ state in password reset token
export function generateResetToken(): string {
  return Math.random().toString(36).slice(2);
}

Remediated — OS/WebCrypto CSPRNG token generation (4-Gate verified)

terminal · zsh
// TypeScript: runtime-safe CSPRNG entropy
import crypto from "node:crypto";
export function generateResetToken(): string {
  return crypto.randomBytes(24).toString("base64url");
}

Scan your own repository for IMM-CSPRNG-001 locally (0 code egress)

Preview proposed changes free with ciphermap fix . --dry-run --offline --no-telemetry. Eligibility depends on the installed build, call shape, module format, and migration context. The bundled RSA fixture has a classical key-size candidate; that does not make it post-quantum secure. Persisted digests and unsupported contexts may be declined. Applying supported candidates requires an entitlement, explicit verifier consent, and the required project tools. Review the actual verification result before adopting a change.

Other rule families