Skip to content
Pwnversity
CRYPTO-BASICSbasic · 6 min · upd. 2026-10

Concepts & common attacks

CWE-327

Well-implemented cryptography is rarely “broken” by brute-forcing the algorithm: it’s broken by how it’s used. This card is the map of the Cryptography area: the concepts you must be clear on and the catalog of implementation flaws that show up again and again in audits, CTFs, and bug bounty. The other cards go deep on each block.

Cryptography is the set of mathematical primitives that provide four security services over data and communications. Understanding which service each primitive offers —and, above all, which one it does not— is what separates a solid deployment from a trivially exploitable one.

Service What it guarantees Typical primitive
Confidentiality Only the recipient reads the message Symmetric/asymmetric encryption
Integrity The message has not been altered Hash, MAC
Authenticity The message comes from who it claims MAC, digital signature
Non-repudiation The sender cannot deny sending it Digital signature (asymmetric)

Confusing these services is the root of most real-world flaws: encryption does not provide integrity (hence authenticated encryption, AEAD), and a hash does not provide authenticity (hence HMAC, not hash(key‖message)).

Kerckhoffs’s principle is the foundation: security rests only on the key, not on the secrecy of the algorithm. A system must stay secure even if the attacker knows every design detail. Hence the golden rule: don’t roll your own crypto; it almost always ends up broken.

The attacker does not attack the algebra of AES or RSA: they look for misuse. An oracle that leaks information (a distinguishable error, a response time, a length), a reused nonce, or a mode without authentication hands them the win without breaking the primitive.

  • Symmetric encryption (AES, ChaCha20): lots of data, shared key. See Symmetric vs asymmetric.
  • Asymmetric encryption (RSA, ECC): key exchange and signing. See PKI & certificates.
  • Hash (SHA-256, SHA-3, BLAKE2): integrity fingerprint. See Hashing & cracking.
  • MAC / AEAD (HMAC, AES-GCM, ChaCha20-Poly1305): integrity + authenticity.
  • KDF (PBKDF2, scrypt, Argon2id): derive a key from a password, slow on purpose.
  • Digital signature (RSA-PSS, Ed25519): authenticity + non-repudiation.

What actually gets exploited in the real world:

  • ECB mode: equal plaintext blocks produce equal ciphertext blocks (the “ECB penguin”); pattern leakage and block cut-and-paste.
  • Reused IV/nonce: catastrophic in CTR and GCM; a GCM nonce must never repeat under the same key. See Symmetric vs asymmetric.
  • Padding oracle: a distinguishable padding error lets you decrypt without the key. See Padding oracle.
  • Missing or misapplied MAC: encrypting without authenticating enables bit-flipping and malleability; use AEAD.
  • Fast hash for passwords: plain SHA-256 is cracked with a GPU; use Argon2id/bcrypt. See Hashing & cracking.
  • Weak RNG: predictable keys and tokens. See Weak randomness (RNG).
  • Non-constant-time comparison: using == on MACs/tokens enables timing attacks.
  • Length extension: SHA-256(secret‖msg) is extensible; use HMAC. See Hashing & cracking.
  • Downgrade: accepting weak algorithms (RC4, MD5, “export” suites) lets an attacker force the weakest. See TLS.
flowchart TD
    A[Ciphertext / token] --> B[Identify primitive and mode]
    B --> C{Which service is missing?}
    C -->|No MAC| D[Malleability / bit-flipping]
    C -->|IV or nonce reuse| E[Keystream reuse]
    C -->|Distinguishable error| F[Find oracle: padding, timing]
    D --> G[Exploit the property, not the algebra]
    E --> G
    F --> G
  1. Identify the primitive and mode: block length, output format, headers.
  2. Ask what’s missing: is there a MAC? is the IV random? is padding validated?
  3. Find the oracle: does the system reveal anything (error, timing, length) on manipulated input?
  4. Exploit the property, not the algebra: malleability, reuse, error oracles.
  • Test ECB by sending repeated blocks and watching for repeated ciphertext.
  • Corrupt encrypted cookies/parameters and measure whether the response or timing changes (oracle).
  • Check whether tokens are predictable (sequential, time-based) with Burp Sequencer.
  • Force a downgrade by offering only weak suites or algorithms during negotiation.
  • Don’t implement your own primitives: use vetted libraries (libsodium, Tink) and AEAD by default (AES-GCM, ChaCha20-Poly1305).
  • Derive password keys with Argon2id; generate keys and nonces with a CSPRNG.
  • Compare secrets in constant time; verify the MAC before decrypting (encrypt-then-MAC).
  • Keep a cryptographic inventory and the agility to rotate algorithms (post-quantum readiness, NIST SP 800-131A).
  • ROBOT (2017): RSA PKCS#1 v1.5 padding oracle revived at Facebook, PayPal, Cisco, and F5.
  • Heartbleed (CVE-2014-0160) and POODLE (CVE-2014-3566): massive impact from implementation/design flaws. See TLS.
  • DROWN (CVE-2016-0800), Logjam (CVE-2015-4000), FREAK (CVE-2015-0204): downgrade to weak “export” crypto.
  • Identify primitive, mode, and ciphertext format
  • Is integrity/authenticity missing? (no MAC → malleability)
  • ECB? → look for pattern leakage with repeated blocks
  • Reused or predictable IV/nonce?
  • Test oracles (padding, error, timing)
  • Passwords: slow hash with salt or crackable?
  • Tokens/keys: CSPRNG or predictable?
  • Are weak algorithms accepted (downgrade)?