Timing attacks are real, and most devs don't protect against them.
When you compare two strings with === or strcmp(),
#PHP stops at the first different byte. If the first character matches, it takes slightly longer than if it doesn't.
An attacker can measure response times to guess a secret character by character. HMAC token, API key, CSRF token... byte by byte, statistically.
hash_equals() was added in PHP 5.6 specifically for this. It always compares ALL bytes, regardless of where the first mismatch is. Constant time.
Same applies to
#golang: use crypto/subtle.ConstantTimeCompare().
Same in
#nodejs: crypto.timingSafeEqual().
If you're comparing secrets with == or ===, you may be leaking information through time!