EMZETT.
Login

Side-channel and timing attacks

In short: Side-channel attacks gain secrets not by breaking the algorithm but from side effects such as computation time, power consumption or cache behaviour.

In more detail: If a comparison takes longer the more characters match, an attacker can guess a password or token character by character. Shared CPU caches also reveal access patterns (Spectre, Meltdown). Countermeasures are constant run time and isolation.

In Depth

  • Timing attack: Different run time reveals information. Countermeasure: constant-time comparison (crypto.timingSafeEqual, hmac.compare_digest).
  • Cache attacks: Flush+Reload, Prime+Probe.
  • Spectre/Meltdown: The CPU’s speculative execution leaks data via cache state.
  • Power and acoustic analysis: For smart cards, hardware.
  • Error messages as a side channel: “User does not exist” vs. “wrong password” reveals accounts.
  • Countermeasures: Constant run time, blinding, isolation (no shared hardware for the untrusting), updates/microcode.
  • In practice: Always use constant-time comparison for tokens and MACs.

See also: Key derivation and password hashing (Argon2), Memory hierarchy and cache lines