Chapter 28 Key Takeaways: Cryptography for Hackers

Core Principles

  1. You do not need to break the math. Real-world cryptographic vulnerabilities almost always stem from implementation errors, configuration mistakes, and protocol design flaws -- not from weaknesses in the underlying algorithms. Understanding how cryptography is used incorrectly is far more valuable than understanding how to factor large primes.

  2. The mode matters as much as the cipher. AES-256 in ECB mode is less secure than AES-128 in GCM mode. Block cipher mode of operation determines whether patterns are preserved, whether authentication is provided, and whether padding attacks are possible. Always assess the full construction, not just the algorithm name.

  3. Perfect Forward Secrecy is non-negotiable. Without PFS (ECDHE/DHE key exchange), an attacker who records encrypted traffic today and obtains the server's private key tomorrow can decrypt everything. With PFS, each session uses unique, ephemeral keys that are discarded and cannot be recovered.

Technical Essentials

  1. Understand the TLS handshake. Knowing how ClientHello, ServerHello, key exchange, and certificate verification work enables you to identify weaknesses at each step. TLS 1.3 eliminated entire categories of attack by removing CBC mode, RSA key exchange, compression, and renegotiation.

  2. Historical attacks teach recurring patterns. BEAST (predictable IVs), POODLE (padding without MAC coverage), DROWN (cross-protocol key reuse), and ROBOT (Bleichenbacher oracle) are not just history -- they represent classes of vulnerability that continue to appear in new contexts. Learn the pattern, not just the specific attack.

  3. Certificates are a trust framework, not a guarantee. PKI weaknesses -- self-signed certificates, expired certificates, missing pinning, weak signatures, and Certificate Transparency gaps -- provide practical attack vectors during penetration tests. Certificate chain validation is a testable control.

  4. Padding oracles are devastating and common. Any system using CBC mode that responds differently to valid versus invalid padding creates a padding oracle. AEAD ciphers (GCM, ChaCha20-Poly1305) eliminate this entire class of attack by combining encryption and authentication.

  5. JWT security depends on implementation. The none algorithm attack, algorithm confusion, weak signing keys, and JKU injection are common vulnerabilities in JWT-based authentication. Every JWT implementation should be tested for these flaws.

  6. Password hashing is not encryption. Passwords should be hashed with a purpose-built function (bcrypt, Argon2, scrypt), not encrypted with a symmetric cipher. Per-user salts prevent rainbow table attacks. Computational cost prevents brute-force attacks.

Strategic Insights

  1. TLS configuration assessment is a core pentesting skill. Tools like testssl.sh, sslyze, and Nmap's ssl-enum-ciphers script should be in every tester's toolkit. Automated scanning catches the majority of TLS misconfigurations.

  2. Post-quantum cryptography is a present concern. The "harvest now, decrypt later" threat makes post-quantum migration urgent for data with long confidentiality requirements. NIST has standardized ML-KEM, ML-DSA, and SLH-DSA. Hybrid implementations are being deployed now.

  3. The gap between theory and practice is where breaches live. Adobe had encryption but used ECB mode. Servers had TLS but also supported SSL 3.0. Applications used JWT but accepted the none algorithm. Cryptographic audits must assess not just whether encryption exists, but whether it is implemented correctly.

Career Applications

  • Penetration testers: TLS assessment, JWT testing, and cryptographic implementation review are standard engagement deliverables
  • Security engineers: Proper TLS configuration, certificate management, and key rotation are operational requirements
  • Application developers: Understanding cryptographic primitives prevents implementation errors that lead to breaches
  • Compliance professionals: PCI DSS, HIPAA, and GDPR all have specific cryptographic requirements that must be validated
  • Security architects: Post-quantum migration planning and cryptographic agility are emerging strategic priorities