mirror of
https://github.com/RobustaStudio/semsec.git
synced 2026-11-27 07:47:03 +01:00
Aligns rule metadata with the MIT LICENSE file. Changes "All rights reserved" to "MIT - For the open-source community" across all 262 rules in 13 files. Closes #6
154 lines
5.6 KiB
YAML
154 lines
5.6 KiB
YAML
# ============================================================================
|
|
# Robusta Studio - Cryptography & Secrets Security Rules
|
|
# Copyright (c) 2026 Robusta Studio. All rights reserved.
|
|
#
|
|
# Rules for weak crypto algorithms, insecure PRNG, hardcoded secrets,
|
|
# and disabled TLS certificate verification.
|
|
# Derived from 60,517 real-world CVE and HackerOne vulnerability records.
|
|
# Dataset: PentesterFlow/OffsecCyber
|
|
#
|
|
# Usage: semgrep --config crypto-secrets.yaml /path/to/project
|
|
# ============================================================================
|
|
|
|
rules:
|
|
|
|
# -- CWE-327 | Weak Cryptographic Algorithms --------------------------------
|
|
|
|
- id: robusta-py-crypto-md5-password
|
|
patterns:
|
|
- pattern-either:
|
|
- pattern: hashlib.md5($PASSWORD).hexdigest()
|
|
- pattern: hashlib.md5($PASSWORD.encode(...)).hexdigest()
|
|
- metavariable-regex:
|
|
metavariable: $PASSWORD
|
|
regex: .*(pass|pwd|secret|token|key).*
|
|
message: >
|
|
MD5 used to hash a password — trivially reversible with rainbow tables.
|
|
Use bcrypt, scrypt, or argon2id for password hashing.
|
|
metadata:
|
|
cwe: ["CWE-328"]
|
|
confidence: HIGH
|
|
impact: HIGH
|
|
author: Robusta Studio
|
|
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
|
|
severity: ERROR
|
|
languages: [python]
|
|
|
|
- id: robusta-py-crypto-ecb-mode
|
|
pattern: AES.new($KEY, AES.MODE_ECB, ...)
|
|
message: >
|
|
AES-ECB leaks patterns in ciphertext — identical plaintext blocks
|
|
produce identical ciphertext blocks. Use AES-GCM for authenticated
|
|
encryption or AES-CBC with HMAC.
|
|
metadata:
|
|
# -- CWE-327 | Weak Cryptographic Algorithms --------------------------------
|
|
confidence: HIGH
|
|
impact: HIGH
|
|
author: Robusta Studio
|
|
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
|
|
severity: ERROR
|
|
languages: [python]
|
|
|
|
- id: robusta-js-crypto-createcipher
|
|
pattern: crypto.createCipher(...)
|
|
message: >
|
|
crypto.createCipher() uses weak key derivation (single MD5 pass, no salt).
|
|
Deprecated since Node 10. Use crypto.createCipheriv() with a proper key
|
|
and random IV, or use scrypt/pbkdf2 for key derivation.
|
|
metadata:
|
|
# -- CWE-327 | Weak Cryptographic Algorithms --------------------------------
|
|
confidence: HIGH
|
|
impact: HIGH
|
|
author: Robusta Studio
|
|
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
|
|
severity: ERROR
|
|
languages: [javascript, typescript]
|
|
|
|
- id: robusta-py-crypto-weak-random
|
|
patterns:
|
|
- pattern-either:
|
|
- pattern: random.randint(...)
|
|
- pattern: random.choice(...)
|
|
- pattern: random.random()
|
|
- pattern-inside: |
|
|
...
|
|
$TOKEN = ...
|
|
...
|
|
message: >
|
|
Standard random module used for security-sensitive token generation.
|
|
CVE-2024-29868: weak PRNG in recovery token → account takeover (CVSS 9.1).
|
|
Use secrets.token_urlsafe() or secrets.token_hex().
|
|
metadata:
|
|
cwe: ["CWE-338"]
|
|
confidence: MEDIUM
|
|
impact: HIGH
|
|
author: Robusta Studio
|
|
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
|
|
references:
|
|
- https://nvd.nist.gov/vuln/detail/CVE-2024-29868
|
|
severity: WARNING
|
|
languages: [python]
|
|
|
|
- id: robusta-js-crypto-math-random-token
|
|
patterns:
|
|
- pattern: Math.random()
|
|
- pattern-inside: |
|
|
...
|
|
$TOKEN = ...
|
|
...
|
|
message: >
|
|
Math.random() is not cryptographically secure — predictable token generation.
|
|
Use crypto.randomBytes() or crypto.randomUUID().
|
|
metadata:
|
|
cwe: ["CWE-338"]
|
|
confidence: MEDIUM
|
|
impact: HIGH
|
|
author: Robusta Studio
|
|
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
|
|
severity: WARNING
|
|
languages: [javascript, typescript]
|
|
|
|
# -- CWE-295 | Improper Certificate Validation -----------------------------
|
|
|
|
- id: robusta-py-tls-verify-false
|
|
patterns:
|
|
- pattern-either:
|
|
- pattern: requests.get(..., verify=False, ...)
|
|
- pattern: requests.post(..., verify=False, ...)
|
|
- pattern: requests.put(..., verify=False, ...)
|
|
- pattern: requests.delete(..., verify=False, ...)
|
|
- pattern: requests.request(..., verify=False, ...)
|
|
- pattern: httpx.get(..., verify=False, ...)
|
|
- pattern: httpx.post(..., verify=False, ...)
|
|
message: >
|
|
TLS certificate verification disabled — enables MitM attacks.
|
|
H1: improper certificate validation allowed connection to revoked certs.
|
|
Remove verify=False; add CA bundle if using internal PKI.
|
|
metadata:
|
|
cwe: ["CWE-295"]
|
|
confidence: HIGH
|
|
impact: HIGH
|
|
author: Robusta Studio
|
|
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
|
|
severity: ERROR
|
|
languages: [python]
|
|
|
|
- id: robusta-js-tls-reject-unauthorized
|
|
patterns:
|
|
- pattern-either:
|
|
- pattern: process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
|
|
- pattern: process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'
|
|
- pattern: |
|
|
{rejectUnauthorized: false}
|
|
message: >
|
|
TLS certificate verification disabled — enables MitM attacks.
|
|
Remove rejectUnauthorized: false; use a custom CA if needed.
|
|
metadata:
|
|
cwe: ["CWE-295"]
|
|
confidence: HIGH
|
|
impact: HIGH
|
|
author: Robusta Studio
|
|
license: "MIT - Copyright (c) 2026 Robusta Studio. For the open-source community."
|
|
severity: ERROR
|
|
languages: [javascript, typescript]
|