Timing attacks

Theory and practice

Joris Zwart logo
Cause
int strcmp(char[] s1, char[] s2) {
    int i = 0

    while (s1[i] == s2[i]) {
        if (s1[i] == 0 || s2[i] == 0) {
            return 0
        }
        i++
    }

    return s1[i] - s2[i]
}            
        
Mitigations?

I ask you, the public!

CPU times are small compared to network times!

So it can never work!

Just add a random delay!
Add a fixed delay, then!
Our users don't do that!

Famous last words...

Facts
Network delays, never speeds up
Network delays follows a pattern
Network noise follows a distribution
Advanced attacks

Wasn't this already?

HTTP/2
2 packets, 1 request

Eliminates network noise!

Lessons learned
Timing is subtle
Don't assume what is right
Use constant time libraries
joriszwart.nl/timing-attacks