4 ms·
strcmp has its own issues. What they actually should have done is use a cryptography library with properly implemented comparison, because it is surprisingly ea
by benchaney 9y ago
strcmp has its own issues. What they actually should have done is use a cryptography library with properly implemented comparison, because it is surprisingly easy to get wrong.
Also, fixed length hashes aren't strings. They shouldn't use the same functions as strings.
Edit: Using a proper cryptography library also might have saved them from using MD5. At the very least, most modern libraries have a warning that is is deprecated and should not be used for new projects.
- dom0 9y agoYep, even if they had used memcmp/strncmp correctly the AMT would still be vulnerable to a timing attack here, which is probably even easy, because it runs on a low-power system with, I assume, not much background activity.
- benchaney 9y agoIn addition to timing attacks, if the attacker supplied a non null terminated string, it could potentially cause a memory overrun. This may not be possible depending on how the string is handled on ingress, but if it is, it would likely have serious consequences.
- qb45 9y agoThe attacker supplies ""-enclosed string and the HTTP parser is supposed to verify this. Maybe they used some in-place HTTP parser and that's why they didn't have zero-termination to use strcmp. And btw, it's not clear if the code was C to begin with. I believe large chunk of ME firmware is said to be written in Java, which kinda makes sense for a network facing system considering how shitty string.h is. It would be interesting if somebody found that they are using some COTS webserver, C/Java - doesn't matter, and see if there are some CVEs for it.
- benchaney 9y agoI doubt using Java would really help in this case, because in order to use Java they would have to port the entire JVM to whatever platform they are using. Doing this without introducing any security bugs is about as difficult as just doing everything in C to begin with. By the way, the fact that the issue was with strncmp very strongly suggests that the issue was in C code.
- dom0 9y agoSome security paper showed ARM disassembly of the issue, although I'm not sure if that was this specific issue or just another "strncmp-induced" issue. (Btw. there are many smaller Java VMs for stuff like Java Card and JEFF)
- qb45 9y agoThey use ARC architecture and some embedded JVM. Of course this doesn't guarantee that the AMT web server runs on this JVM. Few years ago somebody published analysis of the ME firmware for servers (desktop version was compressed with unknown algorithm). I'm sure you can google this for details. > the fact that the issue was with strncmp But we don't know for sure if it was strncmp. It's a logic bug, which can be implemented in any language. But again, maybe this server runs outside JVM and is written in C.
- qb45 9y ago> Also, fixed length hashes aren't strings. In HTTP everything is a string. > Using a proper cryptography library also might have saved them from using MD5. HTTP, again. Browser sends MD5 whether you like it or not.
- benchaney 9y ago> In HTTP everything is a string. Once you parse it out of HTTP it is no longer as string (or at least it should no longer be a string). >HTTP, again. Browser sends MD5 whether you like it or not. They are quite clearly doing verification themselves. They can use whatever algorithm they want.
- qb45 9y agoIt has to be MD5. They use HTTP digest auth, which uses MD5. You send a nonce, the browser throws a popup asking for password and returns md5(nonce+pass). No way around it.
- rusanu 9y agoThey were implementing HTTP Digest[0]. This leaves no room to choose something other than MD5. And I'm not sure what other HTTP authentication scheme they could had chose for firmware (ie. cannot take dependency on anything in infrastructure, like PKI or Kerb) [0] https://en.wikipedia.org/wiki/Digest_access_authentication https://en.wikipedia.org/wiki/Digest_access_authentication