| name | Cryptographic Vulnerabilities |
| description | Crypto implementation analysis — weak algorithms, side-channels, key management flaws, padding oracles, random generation failures, implementation bugs |
| tags | ["crypto","cryptography","security","side-channel","weak-algorithms","key-management","implementation","paddingoracle","rng","nonce","iv","encryption","hmac","signature"] |
| author | Spectra Security Research |
| version | 1 |
Cryptographic Vulnerability Analysis
Overview
This skill analyzes cryptographic implementations for vulnerabilities in algorithm selection, key management, random generation, side-channel leaks, padding oracles, and other implementation flaws.
Analysis Phases
Phase 1: Algorithm Identification
grep -r "DES\|RC4\|MD5\|SHA1" codebase/
grep -r "AES_ECB\|AES_CBC_NO_AUTH" codebase/
grep -r "rsa.*pkcs1" codebase/
Weak Algorithm Indicators:
- DES, 3DES, RC4
- MD5, SHA1
- AES-ECB
- RSA without OAEP/PSS
- DSA
Phase 2: Weak Primitive Detection
2.1 Broken Hash Functions
import hashlib
h = hashlib.md5()
h = hashlib.sha1()
Novelty:
- Check for recent collision attacks
- Look for hash length extension attacks (SHA-2 without HMAC)
- Verify hash usage in signatures
2.2 Weak Encryption Modes
from cryptography.hazmat.primitives.ciphers.modes import ECB
from cryptography.hazmat.primitives.ciphers.modes import CBC
Padding Oracle Detection:
2.3 Weak Random Generation
import secrets
import random.SystemRandom()
// crypto.getRandomValues()
// SecureRandom
Phase 3: Side-Channel Discovery
3.1 Timing Attacks
def constant_time_compare(a, b):
result = 0
for x, y in zip(a, b):
result |= x ^ y
return result == 0
def insecure_compare(a, b):
for x, y in zip(a, b):
if x != y:
return False
return True
3.2 Cache/Timing Side Channels
3.3 Power/EM Side Channels
Phase 4: Padding Oracle Attacks
4.1 CBC Padding Oracle
def decrypt_cbc(ciphertext, key, iv):
plaintext = aes_cbc_decrypt(ciphertext, key, iv)
padding = plaintext[-1]
if plaintext[-padding:] != bytes([padding] * padding):
raise ValueError("Invalid padding")
return plaintext
4.2 RSA Padding Oracle
Phase 5: Key Management Issues
5.1 Hardcoded Keys
grep -r "0x[0-9a-f]\{32,\}" codebase/
grep -r "api_key\s*=\s*["\']" codebase/
grep -r "secret\s*=\s*["\']" codebase/
grep -r "password\s*=\s*["\']" codebase/
# Common locations:
# - Config files (.env, config.json, settings.py)
# - Source code (constant definitions)
# - Version control (git history)
# Novelty:
# - Check for embedded keys in binaries
# - Look for weak key derivation
5.2 Key Derivation Issues
5.3 Key Reuse
Novelty Indicators (PURSUE)
✓ Recent crypto CVEs (2023-2024):
- CVE-2024-33024: Sponge attack on protocol primitives
- CVE-2024-23633: Minerva side-channel
- CVE-2024-26134: OpenSSH reuse attack
✓ Implementation bugs:
- Custom crypto implementations
- Incorrect AEAD usage
- Flawed constant-time code
✓ Protocol-level issues:
- Key exchange flaws (TLS downgrade, DH parameters)
- Certificate validation bypasses
- Protocol confusion attacks
✓ Hardware crypto bugs:
- Intel RDRAND/RDSEED issues
- CPU random number generator flaws
- TPM side-channels
Known Patterns (AVOID)
✗ Basic padding oracle (well-documented)
✗ AES-ECB mode (known weakness)
✗ MD5/SHA1 usage (published collisions)
✗ RSA PKCS#1 v1.5 (known attacks)
Analysis Checklist
Algorithm Selection
Implementation Review
Key Management
Side-Channel Analysis
Quick Reference
| Weakness | Detection | Severity |
|---|
| MD5/SHA1 | grep -r "md5|sha1" | Medium |
| AES-ECB | grep "ECB" | High |
| No IV/IV reuse | Check iv generation | High |
| Weak RNG | rand(), time() seed | High |
| Padding oracle | Error response diffs | Critical |
| Hardcoded keys | Pattern matching | Critical |
| Weak KDF | Low iteration count | High |
| Key reuse | Cross-context | High |
| Timing leaks | Branching on secret | Medium |
| Cache attacks | Table lookups | High |
Notes
- Focus on implementation bugs: Crypto algorithms are usually correct, implementations often flawed
- Side-channels: Timing, cache, power, EM leaks
- Protocol issues: TLS misconfig, certificate validation
- Verification: Document algorithm, implementation issue, exploit
- Responsible disclosure: Crypto bugs can have widespread impact