Cryptographic Timing Attack Vulnerabilities
What it is
A critical vulnerability where cryptographic operations leak sensitive information through timing variations. Attackers can exploit differences in execution time to extract secrets like encryption keys, passwords, tokens, or other sensitive data by measuring how long cryptographic operations take to complete.
💡 Why This Fix Works
The vulnerable code uses character-by-character comparison with early exit, allowing attackers to determine the position of the first incorrect character by measuring response time. The secure version uses crypto/subtle.ConstantTimeCompare which always takes the same time regardless of where differences occur, checks all keys without early termination, and enforces a minimum response time to prevent timing analysis.
Why it happens
Typical mistakes in app/data layers enable this vulnerability.
Root causes
Fixes
Detect This Vulnerability in Your Code
Sourcery automatically identifies cryptographic timing attack vulnerabilities and many other security issues in your codebase.