Author Topic: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2  (Read 30333 times)

0 Members and 1 Guest are viewing this topic.

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1528
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #25 on: July 24, 2015, 10:56:45 pm »
I don't believe that the designer took any special measures (to the code part) to prevent those kind of attacks.
So far, someone was able only watch osciloscope waveforms and you were not able to guess all numbers needed to unlock safe lock, because of there are so many combinations that small variation in power waveform lets say at nth digit will confuse you and you end only with lost time  :-DD

In my opinion, it could be much more interesting watch waveforms of VLF signals from nature to find strange signals in noise than trying to complete mission impossible with power analysis like this  :-DMM

Anyway, it is interesting from another point of view-howto write MPU code to do NOT give so much fun to make any power analysis attempt and probably simply sensing temperature changes (TRNG) and taking random actions in interrupt generated so often that main code will be interrupted within a few instructions at random intervals should create random power line readings and this is what I want to test in my home security software  :popcorn:
Yep, it can help write better MPU code, but if guys from this established security company didn't wrote this software in a way that pressing any numpads doesn't create random power line response doesn't sounds well and I'd rather never bought his safe lock after watching osciloscope power line waveforms shown in this video, so yeah it can help find better security company and write better own software.
Good job overall @EEVBLOG  :-+
« Last Edit: July 24, 2015, 11:04:55 pm by eneuro »
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1528
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #26 on: July 24, 2015, 11:35:35 pm »
it may be possible to tell if how many of the leading digits entered are correct.
:palm:
What about my example pseudo-code
Code: [Select]
char[6] correct = “123456”
char[6] entered = “314159”
bool isok= true;

bool check_code() {
    for (i=0; i<6; i++){
        if (correct[i] != entered[i]) {
          isok= isok & false;           
        } else {
           isok= isok & true;  // :P
        }

    }
    return isok;
}

Simply, show me other successfull power line analysis with.. source code writen by... noob, else probably you are loosing your time or... learning howto use your scope trying catch those power line waveforms :-DD
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #27 on: July 24, 2015, 11:46:48 pm »
it may be possible to tell if how many of the leading digits entered are correct.
:palm:
What about my example pseudo-code
Code: [Select]
char[6] correct = “123456”
char[6] entered = “314159”
bool isok= true;

bool check_code() {
    for (i=0; i<6; i++){
        if (correct[i] != entered[i]) {
          isok= isok & false;           
        } else {
           isok= isok & true;  // :P
        }

    }
    return isok;
}

Simply, show me other successfull power line analysis with.. source code writen by... noob, else probably you are loosing your time or... learning howto use your scope trying catch those power line waveforms :-DD

With that code they just need to try only 10 combinations since only the last digit has to be correct, no need for power analysis.

Nevermind, it's an and I missed it.

Edit: But power analysis might be feasible since doing an and with true might require different power level than doing an and with false.
« Last Edit: July 24, 2015, 11:49:57 pm by miguelvp »
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1528
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #28 on: July 25, 2015, 12:09:32 am »
Nevermind, it's an and I missed it.
No problem. People and "big" car manufacturers has bigger security issues right now than guessing 6 digit safe lock code ;)

I hope none of EEVBLog member is "lucky" owner of this hacked car  :-DD

Chrysler recalls 1.4 million hackable cars
Quote
Chrysler is recalling 1.4 million vehicles that can be remotely hacked over the Internet.

Jeep remotely hacked at 100 km/h

12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #29 on: July 25, 2015, 12:34:23 am »
One problem with

Code: [Select]
        if (correct[i] != entered[i]) {
          isok= isok & false;           
        } else {
           isok= isok & true;  // :P
        }

Valid digits will have different execution times than invalid ones due to the branch caused by the comparison result.
So timing the power levels will tell you if you have none right or some right, then it's just a MasterMind game
 

Offline DanielS

  • Frequent Contributor
  • **
  • Posts: 798
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #30 on: July 25, 2015, 02:00:48 am »
Anyway, it is interesting from another point of view-howto write MPU code to do NOT give so much fun to make any power analysis attempt and probably simply sensing temperature changes (TRNG) and taking random actions in interrupt generated so often that main code will be interrupted within a few instructions at random intervals should create random power line readings and this is what I want to test in my home security software  :popcorn:
There is no need to generate random events. As someone else wrote earlier, instead of doing plain-text match check, you can hash the key presses and compare against the key hash and add a "salt" value which may be generated when the password is set so the attacker cannot use a rainbow table of known power draw patterns to break the hash.
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1528
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #31 on: July 25, 2015, 07:36:07 am »
One problem with
...
Valid digits will have different execution times than invalid ones due to the branch caused by the comparison result.
No problem-I dign't optimized this code-you should write such critical parts of code in assembler, since C compiler might optimize and completely remove this part of source code, since it doesnt chang elogical value  ;)
Code: [Select]
isok= isok & true;  // :P
Anyway it can be rewriten as, but of couse written in assembler, so NOP instructions can be added to get exactly the same execution time in those two cases  :P
Code: [Select]
        if (correct[i] != entered[i])
          isok= isok & false;           
        }
        if (correct[i] == entered[i])
           isok= isok & true;  // :P
        }
Of course code above will be optimized, so as I said assembler statements have to be used to avoid any optimizations ;)

As someone else wrote earlier, instead of doing plain-text match check, you can hash the key presses and compare against the key hash and add a "salt" value
Of course, only NOOB could write security software with password stored in MPU memory in clear form, so no chance to get anything interesting based on execution times differencies during enetring password  :popcorn:
« Last Edit: July 25, 2015, 07:42:31 am by eneuro »
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline EEVblogTopic starter

  • Administrator
  • *****
  • Posts: 37730
  • Country: au
    • EEVblog
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #32 on: July 25, 2015, 07:43:35 am »
How about a theory that the various (non-repeateable) waveforms might be caused by varying time between keypresses ?
(What struck me with that idea is that you reach with your right hand to get the scope back into single-shot).
This.

It seemed too repeatable for that to be the case. I did more off-camera.
 

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5126
  • Country: nl
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #33 on: July 25, 2015, 08:13:09 am »
How about a theory that the various (non-repeateable) waveforms might be caused by varying time between keypresses ?
(What struck me with that idea is that you reach with your right hand to get the scope back into single-shot).
This.

It seemed too repeatable for that to be the case. I did more off-camera.

I was not thinking about the good key versus bad key waveform but about the different waveforms you get for good key.
Keyboard error: Press F1 to continue.
 

Offline wreeve

  • Supporter
  • ****
  • Posts: 91
  • Country: gb
    • embedded u systems limited
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #34 on: July 25, 2015, 09:18:09 am »
Dave; if you did crack this with a simple resistor and 'scope would you publish? From what you said quite a few of these safes out in the wild. I am interested in the moral stand-point here.
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #35 on: July 25, 2015, 10:11:27 am »
Dave; if you did crack this with a simple resistor and 'scope would you publish? From what you said quite a few of these safes out in the wild. I am interested in the moral stand-point here.
I certainly would, and I hope Dave would too.

So far Dave hasn't done anything that millions of other people couldn't have tried. If there's a vulnerability at this level of obviousness then:
a) The crooks already know it.
b) The manufacturers deserve to have their company shut down.

PS: If you want to know the lengths people go to to crack stuff then watch some of the "DEFCON" videos on youtube. You might read about Playstation/Xbox hacks in the press but the effort that goes into those hacks is astonishing.

eg.



« Last Edit: July 25, 2015, 10:13:01 am by Fungus »
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #36 on: July 25, 2015, 10:22:53 am »
Or this one:



Quite incredible.
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #37 on: July 25, 2015, 05:32:40 pm »
Or this one - hacking the Xbox TPM:



So much work...manually putting in 'bodge wires' on the chip die, all through a wire mesh that zaps the chip if you break it.


« Last Edit: July 25, 2015, 05:40:56 pm by Fungus »
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14180
  • Country: de
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #38 on: July 25, 2015, 07:43:11 pm »
So the vulnarability helps to get first 5 digits - possibly within something like 20 min average 40 min worst case. For the last digit you still have to test without help - so after 3 tries you get the time penelty: still about 30% chance to get the right code by that time. It depends how the safe reacts an the 4 th and furhter wrong entries: it may already give an even longer timeout after number 4, or just after number 6.

There is also the question if removing the battery may restart the sequence, or possibly need an inital waiting time of maybe 30 min or so - which would be good.

 

Offline Badger

  • Newbie
  • Posts: 5
  • Country: gb
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #39 on: July 25, 2015, 11:01:45 pm »
One problem with
...
Valid digits will have different execution times than invalid ones due to the branch caused by the comparison result.
No problem-I dign't optimized this code-you should write such critical parts of code in assembler, since C compiler might optimize and completely remove this part of source code, since it doesnt chang elogical value  ;)
Code: [Select]
isok= isok & true;  // :P
Anyway it can be rewriten as, but of couse written in assembler, so NOP instructions can be added to get exactly the same execution time in those two cases  :P
Code: [Select]
        if (correct[i] != entered[i])
          isok= isok & false;           
        }
        if (correct[i] == entered[i])
           isok= isok & true;  // :P
        }
Of course code above will be optimized, so as I said assembler statements have to be used to avoid any optimizations ;)

As someone else wrote earlier, instead of doing plain-text match check, you can hash the key presses and compare against the key hash and add a "salt" value
Of course, only NOOB could write security software with password stored in MPU memory in clear form, so no chance to get anything interesting based on execution times differencies during enetring password  :popcorn:

If you were trying to show timing / power resistant code, this would have been a bettter example:

Code: [Select]
bool ok = true;
for (i=0;i<6;i++)
    ok &&= (correct[i] == entered[i])
return ok

From what little I can understand of your posts, you've missed the point; whether it's possible to write timing / power attack resistant code is irrelevant.

Who knows how this specific system is implemented? Do you know the designers were careful to avoid code timing / powerline attacks? I strongly suspect not.

The entire safe logic could be comfortably implemented in a cheap 8-bit micro and it only needs to handle a single user. The micro is on the "secure" side of the safe - there could well be no hashing or salting. This is a minimal, commodity electonic device - not a full-blown unix system.

Whether it's possible to measure the subtle time differences on a scope... well, I think that's unlikely. I'd like to see Dave try though - please have a look at any differences in behaviour after entire codes - correct, fully incorrect and incorrect but starting with correct digits - have been entered.
« Last Edit: July 25, 2015, 11:18:25 pm by Badger »
 

Offline Bud

  • Super Contributor
  • ***
  • Posts: 6905
  • Country: ca
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #40 on: July 25, 2015, 11:40:24 pm »
I used the Rigol because it was right there at the time. It also probably helps that is has a "low noise" 500uV front end the others don't.

This sucker does not have it either. The 500uV thingy is not more than a marketing gimmick. It is a Digital Zoom, NOT a proper amplification range. From the attached pictures it can be seen that 500uV/ setting has twice as less ADC steps than on 1mV/ (or any other higher input range, I have verified). What rigol did on 500uV they just stretched by 200% the data sampled at 1mV per division. And they even did not bother interpolating it to at least look better on the screen. The 500uV/ display contains NO more details about the signal than 1mV/. And everyone sucked their BS up.
Facebook-free life and Rigol-free shack.
 

Offline DanielS

  • Frequent Contributor
  • **
  • Posts: 798
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #41 on: July 26, 2015, 05:46:04 am »
Whether it's possible to measure the subtle time differences on a scope... well, I think that's unlikely.
The mask-programmable controller in there runs at maybe a few MHz and 2-4 cycles per instruction. Timing analysis at somewhere in the neighborhood of 1MIPS should not be particularly difficult as long as you manage to get a decent amplitude signal to look at. Here though, what Dave sees is only 20ms long dips with no distinct features in them aside from the RC filter waveform shape from the shunt measurement resistor and the lock's power filtering caps.
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1528
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #42 on: July 26, 2015, 08:28:30 am »
This is a minimal, commodity electonic device - not a full-blown unix system.
To compute MD5 on 8bit MPU like tiny ATTiny85 less than 1KB of code needed, so no need for any Unix systems  :palm:
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline f4eru

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: 00
    • Chargehanger
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #43 on: July 26, 2015, 09:22:21 pm »
Quote
I am interested in the moral stand-point here.

look at responsible disclosure practices....

https://en.wikipedia.org/wiki/Responsible_disclosure

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #44 on: July 27, 2015, 02:55:58 am »
Quote
I am interested in the moral stand-point here.

look at responsible disclosure practices....

https://en.wikipedia.org/wiki/Responsible_disclosure
That's for software. Safe manufacturers can't really issue a patch for people to download.
 

Offline dgtl

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ee
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #45 on: July 27, 2015, 08:49:47 pm »
For even better constant-time behaviour, you can avoid any conditionals by using XOR operator:
Code: [Select]
char result=0;
for (i=0;i<6;i++)
    result |= (correct[i] ^ entered[i]);
return result==0
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #46 on: July 27, 2015, 09:04:59 pm »
For even better constant-time behaviour, you can avoid any conditionals by using XOR operator:
Code: [Select]
char result=0;
for (i=0;i<6;i++)
    result |= (correct[i] ^ entered[i]);
return result==0
Nope. That could lead to a lot of false positives (when two errors give the same result they cancel out to zero).

There's all sorts of CRCs and hashes you could use and get constant time, XOR isn't one of them.
 

Offline dgtl

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ee
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #47 on: July 27, 2015, 09:58:41 pm »
Perhaps I'm misunderstanding your comment. Using ORed byte-wise XOR to compare 2 memory areas in a time-constant fashion is a quite common technique, ie:
BSD: http://cvsweb.netbsd.org/bsdweb.cgi/src/common/lib/libc/string/consttime_memequal.c?rev=1.4&content-type=text/x-cvsweb-markup
Linux: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/crypto/memneq.c#n82
The idea is not CRCing the words and comparing CRCs; it is still byte-wise comparision. XOR result is one iff the operands are inequal. The results are ORed together and finally the comparision to zero checks that none of the XOR checks triggered inequality. Of course, this solution only helps for timing attacks when comparing two memory segments both in memory. It still leaves a lot of vulnerabilities open, ie power analysis during comparision; flash read vulnerabilities; brute force vulnerabilities etc.
 

Offline helius

  • Super Contributor
  • ***
  • Posts: 3639
  • Country: us
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #48 on: July 27, 2015, 11:16:03 pm »
Nope. That could lead to a lot of false positives (when two errors give the same result they cancel out to zero).
:palm:  A &cplus; B &iff; &not;(A &equiv; B)
&therefore; (A &cplus; B)=0 &iff; A=B
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16642
  • Country: 00
Re: EEVblog #771 - Electronic Safe Lock Powerline Attack Part 2
« Reply #49 on: July 28, 2015, 04:52:04 am »
Nope. That could lead to a lot of false positives (when two errors give the same result they cancel out to zero).
:palm:  A &cplus; B &iff; &not;(A &equiv; B)
&therefore; (A &cplus; B)=0 &iff; A=B
My bad, I misread the code.   :-[

Perhaps I'm misunderstanding your comment. Using ORed byte-wise XOR to compare 2 memory areas in a time-constant fashion is a quite common technique, ie:
Yep, you're right.   :-[ :palm:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf