Skip to content

Timing attack in OTA authentication #1127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
skorokithakis opened this issue Dec 1, 2015 · 4 comments · Fixed by #3836
Closed

Timing attack in OTA authentication #1127

skorokithakis opened this issue Dec 1, 2015 · 4 comments · Fixed by #3836

Comments

@skorokithakis
Copy link
Contributor

skorokithakis commented Dec 1, 2015

Since the comparison function of the secret for OTA authentication is not constant-time, it is possible for an attacker to discover the OTA secret over the network and flash whatever firmware they like.

The following article has an explanation and fix:

http://blog.ircmaxell.com/2014/11/its-all-about-time.html

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@projectgus
Copy link

Interesting observation!

I saw this being discussed on gitter and I took a look at the code. I don't see how it's exploitable, but maybe I'm missing something.

Calling String.equals() to compare the challenge hash response is vulnerable to a timing attack. If you had multiple attempts at sending challenge responses then you could decode what the challenge response hash should be from the timing.

However, as soon as a challenge response fails the OTA system drops back to the OTA_IDLE state and the next time around it generates a new nonce, meaning a totally new challenge hash.

So I'm not sure how you'd attack that, but maybe I'm missing something.

(Also, there's a strong chance the WiFi transmit timing is jitterier than the timing difference between a 1-byte memcmp and a 32-byte memcmp, but that's probably not a good thing to rely on.)

@skorokithakis
Copy link
Contributor Author

That's true, but theoretically-hard crypto attacks have a weird way of being exploited in the end. In this case, the fix is so simple that I'd rather add the two extra lines and be safe than sorry.

@projectgus
Copy link

Fair enough. :)

@igrr igrr added this to the 2.1.0 milestone Dec 5, 2015
@igrr igrr modified the milestones: 2.1.0, 2.2.0 Feb 27, 2016
@tablatronix
Copy link
Contributor

Could also do preffered double hash hmac comparison, you gotta avoid any optimizations for real protection, but I have no idea the state of the crypto atm, A simple ord comparison should be better than nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants