Most active commenters
  • tptacek(3)

←back to thread

178 points saikatsg | 19 comments | | HN request time: 0.63s | source | bottom
1. 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 #
2. GoToRO ◴[] No.42208294[source]
would adding random delays prevent this?
replies(5): >>42208493 #>>42208931 #>>42208951 #>>42208997 #>>42209530 #
3. tptacek ◴[] No.42208493[source]
It depends on the kinds of attacks you're thinking of. For the stuff Kettle is doing, probably yes. For cryptographic side channels, probably no.
4. wiredfool ◴[] No.42208931[source]
One thing that I’ve done where I previously had a random delay is implement a delay till a constant time from the start of the request. So all of the timing you get out is effectively how well sleep can target a time.
5. jack_pp ◴[] No.42208951[source]
or you could benchmark the functions that compare secrets to user input and figure out how much time it's supposed to take, add 0.5s to the average and always add time before responding to get to that target so essentially your response time is constant regardless of input
replies(1): >>42209246 #
6. Filligree ◴[] No.42208997[source]
Random delays specifically do not, as they average out. Delays until a specific point in time do work, so long as the delay is never negative.
replies(1): >>42212098 #
7. tptacek ◴[] No.42209246{3}[source]
Important to keep in mind here that the timing attacks Kettle is talking about generally do not take the form of "providing secret input to a function with variable timing".
replies(1): >>42211707 #
8. 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 #
9. ozim ◴[] No.42211601{3}[source]
So in practice it prevents the attack as real world attackers have limited resources and try to find easier targets.
replies(1): >>42212417 #
10. jack_pp ◴[] No.42211707{4}[source]
He says this exact same thing in the Defense at the end:

> Finally, yes I do recommend using constant-time functions when comparing user input with secret keys. Just ask anyone who says this is an actual threat to provide a proof of concept.

11. bostik ◴[] No.42212098{3}[source]
This particular case would be a fantastic fit for timer wheel.[0] Instead of writing a brittle implementation of "after a fixed time in the future" logic yourself, you queue the outgoing event to occur after N ticks [of granularity X], and let the dedicated data structure engine do the work for you.

0: https://www.snellman.net/blog/archive/2016-07-27-ratas-hiera...

12. GoblinSlayer ◴[] No.42212364{3}[source]
So you need to compute this statistics and add just the right delay to even out the bias.
replies(1): >>42212411 #
13. saagarjha ◴[] No.42212411{4}[source]
At that point you’ve implemented a constant-time algorithm.
replies(2): >>42213531 #>>42214443 #
14. saagarjha ◴[] No.42212417{4}[source]
That’s what everyone says until they realize they understated the costs to attempt such an attack.
15. Alex-Programs ◴[] No.42213531{5}[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 #
16. emilfihlman ◴[] No.42214191[source]
Fortunately a quick fix is to first go through a cryptographically secure trapdoor function that makes the initial check security time invariant, like with sha256 with a random salt, before checking exact byte matching.
replies(1): >>42216885 #
17. GoblinSlayer ◴[] No.42214443{5}[source]
It can be implemented once, by, say, nginx and enabled by a devops instead of every random outsourced java webapp.
18. tptacek ◴[] No.42216885[source]
This is an old (and unpopular) countermeasure for simple string timing attacks, but that's not what this article is talking about and that countermeasure isn't reasonable in most of the cases Kettle is talking about.
19. endofreach ◴[] No.42217803{6}[source]
Good luck explaining CEO / PM you need slower response times.