OWASP Top 10 Security Lab

A02

Cryptographic Failures

Discover and exploit weak cryptographic implementations

What are Cryptographic Failures?

Cryptographic Failures, previously known as Sensitive Data Exposure, is the second most critical web application security risk. It occurs when applications fail to properly protect data in transit and at rest through weak cryptographic implementations.

🎯 Common Failure Scenarios

  • Weak Hashing Algorithms: Using MD5, SHA1, or other deprecated algorithms
  • Poor Key Management: Hardcoded keys, weak key generation, inadequate key rotation
  • Inadequate Encryption: Custom crypto implementations, weak ciphers
  • Data Transmission: Missing HTTPS, weak TLS configurations
  • Password Storage: Plaintext or weakly hashed passwords

⚠️ Real-World Impact

  • Complete compromise of user credentials and personal data
  • Financial fraud and identity theft
  • Regulatory violations (GDPR, HIPAA, PCI-DSS)
  • Reputation damage and loss of customer trust

🛡️ Prevention Strategies

  • Use Strong Algorithms: AES-256, RSA-2048+, SHA-256+, bcrypt/scrypt
  • Proper Key Management: Secure generation, storage, and rotation
  • Perfect Forward Secrecy: Ephemeral key exchange
  • Authenticated Encryption: AES-GCM, avoid ECB mode
# Vulnerable Hash Storage password = "user123" hash = md5(password) # WEAK! # Secure Hash Storage password = "user123" salt = generate_random_salt() hash = bcrypt(password + salt, cost=12) # STRONG! # Vulnerable Encryption key = "1234567890123456" # Hardcoded! cipher = AES.new(key, AES.MODE_ECB) # Weak mode! # Secure Encryption key = os.urandom(32) # Random 256-bit key iv = os.urandom(16) # Random IV cipher = AES.new(key, AES.MODE_GCM, iv) # Strong!