Skip to content

Add security-insecure-random rule for PHP/WHMCS modules#3

Merged
Stdubic merged 1 commit into
mainfrom
feat/security-insecure-random-rule
Mar 30, 2026
Merged

Add security-insecure-random rule for PHP/WHMCS modules#3
Stdubic merged 1 commit into
mainfrom
feat/security-insecure-random-rule

Conversation

@mladenovic-13

Copy link
Copy Markdown
Collaborator

Detect cryptographically weak PRNG (rand, mt_rand, uniqid, microtime,
time) used for security-sensitive values like tokens, keys, secrets,
nonces, and CSRF tokens. Skips lines with safe alternatives
(random_bytes, random_int, openssl_random_pseudo_bytes).

Summary

  • Add security-insecure-random rule detecting CWE-338 vulnerabilities in PHP/WHMCS modules
  • Two complementary regex patterns: security-named variable assignment and hash-wrapping weak random
  • 12 new tests (7 positive + 5 negative)
  • Vulnerable example module (insecure_random.php) for CLI demo
  • Updated RULES.md (32 → 33 rules) and vulnerable examples README

Type of Change

  • New rule
  • Documentation update

Checklist

  • npm run validate passes (lint + typecheck + tests + build)
  • New rules have positive and negative test cases
  • Documentation updated if needed
  • No any types introduced

Detect cryptographically weak PRNG (rand, mt_rand, uniqid, microtime,
time) used for security-sensitive values like tokens, keys, secrets,
nonces, and CSRF tokens. Two complementary patterns: security-named
variable assignment and hash-wrapping weak random. Skips lines with
safe alternatives (random_bytes, random_int, openssl_random_pseudo_bytes).
@mladenovic-13
mladenovic-13 requested a review from Stdubic March 30, 2026 11:12
@Stdubic
Stdubic merged commit b54f180 into main Mar 30, 2026
12 checks passed

@Stdubic Stdubic left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants