←back to thread

178 points saikatsg | 8 comments | | HN request time: 1.026s | source | bottom
Show context
miki123211 ◴[] No.42208092[source]
Timing attacks are such a pernicious idea.

You look at the code and see that there's an auth check in place, you test the code to verify that the auth check has no bugs, you make sure that information is never shared with people who don't have authorization to access it, and yet it turns out it can be accessed as if there was no auth check at all.

To make matters worse, everything can be fine for some time, and then some clever optimization in the CPU, the compiler, cache layer or the database engine introduces a completely unexpected side channel.

replies(2): >>42208294 #>>42214191 #
GoToRO ◴[] No.42208294[source]
would adding random delays prevent this?
replies(5): >>42208493 #>>42208931 #>>42208951 #>>42208997 #>>42209530 #
1. pwagland ◴[] No.42209530[source]
No, it only makes it take longer to get the underlying secret.

Timing attacks are already dealing with "noisy" data, task scheduling et al, so they all boil down to some level of statistical analysis on the response times. Adding noise to that slows you down, but the underlying bias on the timings is still there.

replies(2): >>42211601 #>>42212364 #
2. ozim ◴[] No.42211601[source]
So in practice it prevents the attack as real world attackers have limited resources and try to find easier targets.
replies(1): >>42212417 #
3. GoblinSlayer ◴[] No.42212364[source]
So you need to compute this statistics and add just the right delay to even out the bias.
replies(1): >>42212411 #
4. saagarjha ◴[] No.42212411[source]
At that point you’ve implemented a constant-time algorithm.
replies(2): >>42213531 #>>42214443 #
5. saagarjha ◴[] No.42212417[source]
That’s what everyone says until they realize they understated the costs to attempt such an attack.
6. Alex-Programs ◴[] No.42213531{3}[source]
It works quite well in practice though. I wonder if you could make an ergonomic library for it.

Just add a macro to a function and it'll keep track of how long past executions took to execute and add artificial delays to ensure all subsequent executions are at least that long. If they're longer, extend the minimum time by 2x.

Perhaps apply an AIMD algorithm to it? Though there's still room for exploitation there, it'd just take a lot longer to find. Just letting the programmer specify the minimum time might be better in practice.

replies(1): >>42217803 #
7. GoblinSlayer ◴[] No.42214443{3}[source]
It can be implemented once, by, say, nginx and enabled by a devops instead of every random outsourced java webapp.
8. endofreach ◴[] No.42217803{4}[source]
Good luck explaining CEO / PM you need slower response times.