Cryptography Vulnerabilities Overview
Cryptography Vulnerabilities Overview
Using Weak Cryptographic Algorithms
Using Weak Cryptographic Algorithms
- Use modern, well-vetted algorithms (AES-256, ChaCha20-Poly1305)
- Avoid deprecated algorithms (DES, MD5, SHA-1, RC4)
- Use authenticated encryption (AEAD) modes like GCM or ChaCha20-Poly1305
- Follow recommendations from security standards organizations
- Keep cryptographic libraries updated
Insufficient Key Length
Insufficient Key Length
- Use at least 2048 bits for RSA keys (4096 bits for long-term security)
- Use at least 256 bits for symmetric encryption keys (AES-256)
- Use at least 256 bits for elliptic curve cryptography (ECC)
- Follow current recommendations from security standards organizations
- Plan for periodic key rotation and algorithm updates
Hardcoded Cryptographic Keys
Hardcoded Cryptographic Keys
- Store keys in secure key management systems
- Use environment variables or configuration files for key references
- Implement proper access controls for keys
- Use key derivation functions when appropriate
- Implement key rotation policies
Insecure Random Number Generation
Insecure Random Number Generation
- Use cryptographically secure random number generators
- Avoid Math.random() for security-sensitive operations
- Ensure proper seeding of random number generators
- Use platform-specific secure random APIs
- Consider entropy sources for critical applications
Using ECB Mode for Encryption
Using ECB Mode for Encryption
- Avoid ECB mode for all but the most basic use cases
- Use CBC mode with a random IV for each encryption
- Prefer authenticated encryption modes like GCM or ChaCha20-Poly1305
- Ensure IVs are randomly generated for each encryption
- Validate message integrity when using non-authenticated modes
Missing Certificate Validation
Missing Certificate Validation
- Always validate SSL/TLS certificates
- Never set
rejectUnauthorized: falsein production - Implement proper certificate pinning for high-security applications
- Keep trusted certificate authorities updated
- Implement proper certificate revocation checking
Using Deprecated Hash Functions
Using Deprecated Hash Functions
- Use modern hash functions (SHA-256, SHA-3)
- For passwords, use specialized password hashing functions (bcrypt, Argon2, PBKDF2)
- Always use salts with password hashes
- Implement proper key stretching with sufficient iterations
- Keep hashing libraries updated
Insufficient Entropy for Key Generation
Insufficient Entropy for Key Generation
- Use cryptographically secure random number generators
- Ensure proper seeding of random number generators
- Consider hardware random number generators for critical applications
- Avoid predictable seeds like timestamps
- Implement proper entropy collection during key generation
Improper Certificate and Key Storage
Improper Certificate and Key Storage
- Use secure key management systems
- Implement proper file permissions (e.g., 0600)
- Consider hardware security modules (HSMs) for critical keys
- Encrypt private keys at rest
- Implement proper access controls and audit logging
Lack of Forward Secrecy
Lack of Forward Secrecy
- Use ephemeral Diffie-Hellman (DHE) or Elliptic Curve Diffie-Hellman (ECDHE) key exchange
- Prioritize cipher suites that support forward secrecy
- Configure servers to honor cipher order
- Regularly rotate long-term keys
- Keep TLS configurations updated with current best practices
Weak Password-Based Key Derivation
Weak Password-Based Key Derivation
- Use specialized key derivation functions (PBKDF2, Argon2, scrypt)
- Use a sufficient number of iterations or work factor
- Always use a unique salt for each password
- Use appropriate key length for the target algorithm
- Adjust work factors as hardware capabilities increase
Missing Authenticated Encryption
Missing Authenticated Encryption
- Use authenticated encryption modes (GCM, ChaCha20-Poly1305)
- Verify authentication tags before decrypting data
- Use libraries that implement authenticated encryption correctly
- Consider using higher-level cryptographic libraries
- Implement proper error handling for authentication failures
Insecure Cryptographic Storage
Insecure Cryptographic Storage
- Use appropriate cryptographic techniques for different types of data
- Hash passwords with specialized password hashing functions
- Encrypt sensitive data with strong algorithms
- Implement proper key management
- Regularly rotate encryption keys
- Implement proper access controls for encrypted data
Using Broken or Risky Cryptographic Libraries
Using Broken or Risky Cryptographic Libraries
- Use well-maintained, actively supported libraries
- Prefer libraries that have undergone security audits
- Keep libraries updated to the latest secure versions
- Monitor security advisories for cryptographic libraries
- Consider using higher-level cryptographic APIs when possible
Improper Certificate Validation
Improper Certificate Validation
- Always validate SSL/TLS certificates
- Verify both the certificate chain and the hostname
- Consider implementing certificate pinning for high-security applications
- Keep trusted certificate authorities updated
- Implement proper certificate revocation checking