String Comparison Timing Attacks
sjoerdlangkemper.nl
sjoerdlangkemper.nl
Standard way being trying to measure the precise differences between requests. The smaller the difference the more requests are needed to level things out and that just becomes pretty impractical quickly but still possible in some situations.
If you actually wanted to do a timing attack on the web you'd probably want to do something like a "Timeless Timing Attack" [0]. At a high-level the idea is to measure relative timing differences rather than the precise difference. Answering which request completes faster rather than how much faster.
The specific attack from the paper is taking advantage of HTTP/2 multiplexing to send two requests within a single packet, ensuring they arrive at the same time. Then uses the response order to determine which was processed faster/slower. It still requires making multiple requests to smooth out the data just not as much since you're only interested in the relative competition time.
Its not practical everywhere, but its more practical for the web than the traditional technique.
[1] https://www.usenix.org/conference/usenixsecurity20/presentat...
See for example the cryptopals exercise https://cryptopals.com/sets/4/challenges/31
Experience has shown that this is even detectable remotely.
When auditing any cryptographic library, this is one of the first things I look for.
For context: the GPS signal that your phone fixes to is something like -120dB under the noise floor, there is a way to recover that.
It was at the time rumors spread about statistical attacks on tor with man-in-the-middle agents and corrupted nodes.
The rumors said the author of the published thesis was asked nicely by "authorities" to un-publish it...
In the time it takes to research the timing behavior of your runtime, you could have reached for a constant-time comparison instead.
Similarly, in the time it takes you to reach the conclusion the comparison you're using isn't vulnerable, you could have reached for a secure compare instead.
I'm not convinced this post makes a compelling case against the best practice of always using a secure compare for secret strings.
> The time differences for individual characters are often below one nanosecond, making it virtually impossible to detect remotely.
What I'm taking away is: scrutinizing the algorithm used for string comparison should be low priority compared to other security-related concerns.
I learned about it when someone suggested using compression to address scenarios where Tailwind CSS is duplicated in HTTP responses, and a BREACH attack was suggested as a potential downside to consider.