https://thisdata.com/blog/timing-attacks-against-string-comparison/
This is a fairly important attack class which is usually overshadowed by solved problems like SQL Injections and XSS.
With a thousand requests over an hour, an adversary can deduce a string purely on how long string comparison takes. This is one reason that it's critically important to use constant time compares in cryptography, session tokens, password hash checks, reset tokens, etc. otherwise, an attacker can deduce them string character by character.
For Go, the constant time compare function would be subtle.ConstantTimeCompare()
For PHP, it would probably be hash_equals()
I'm not sure about other languages, but they're bound to have their own facilities.
If you don't see hash_equals in use in a PHP software, then it's likely vulnerable.
This is a fairly important attack class which is usually overshadowed by solved problems like SQL Injections and XSS.
With a thousand requests over an hour, an adversary can deduce a string purely on how long string comparison takes. This is one reason that it's critically important to use constant time compares in cryptography, session tokens, password hash checks, reset tokens, etc. otherwise, an attacker can deduce them string character by character.
For Go, the constant time compare function would be subtle.ConstantTimeCompare()
For PHP, it would probably be hash_equals()
I'm not sure about other languages, but they're bound to have their own facilities.
If you don't see hash_equals in use in a PHP software, then it's likely vulnerable.
Last edited:







