create account

PSA: Bug with Electrum Wallet - Seed Generation Vulnerability! by profitgenerator

View this thread on: hive.blogpeakd.comecency.com
· @profitgenerator ·
$2.73
PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!
<CENTER>![electrum.png](https://steemitimages.com/DQmZudN7GeojGNuN2h8DBkGJSzweaUr4byy6bcDJc2GSrdf/electrum.png)</CENTER>
<BR/>

First of all there is no need to panic, you are probably not affected by this bug, but I just put this out as a PSA since I have found a serious bug in the way Electrum generates it's seed but only if you generate it from the command interface. 

# You are **`NOT`** affected by this bug:
* If you have generated your Electrum wallet / Seed, from the GUI interface. So if you use Electrum's GUI version, like probably 99% of other users do, then this bug does **`NOT`** affect you at all.
* If you have generated your Electrum wallet / Seed, from the command line/terminal interface but without using the `--entropy` command

<br/>

# You **`ARE`** affected by this bug:
* If you have used the `--entropy` command in the console/terminal, and in fact it's very probable that your wallet seed has very little entropy, in fact so little that it could be dangerous to store any Bitcoins in those wallets, since the seed can be easily guessed by a computer running all day guessing private keys, [which hackers are already doing](https://www.youtube.com/watch?v=foil0hzl4Pg).

<br/>

---------------------------

<br/>

# Issue

So the problem is with the `--entropy` command which triggers the `custom_entropy` variable and part of code, which I have already found pretty strange in my code audit:
* https://steemit.com/programming/@profitgenerator/electrum-bitcoin-wallet-code-audit

So I had to contact the developer to tell him about this issue, and it turns out I am right, I found a serious bug:
* https://bitcointalk.org/index.php?topic=2012226.0

So if you just use the GUI Electrum, then this is of no concern to you, but it is of concern to people who like to add some extra entropy to their wallets, and who thought this is a safe way to do it, only to turn out that it's not.

There are 2 issues, 1 is the quality of the user generated entropy, which is more like a user related problem, since people will just enter their birthdate or their phone number there which has 0 entropy but they think it's secure. However I guess most tech savvy people who use the console are hopefully not this dumb.

But the main issue is a cryptographic issue. The part of the code in the `mnemonic.py` file:

`custom_entropy * (my_entropy + nonce)`

This code tries to imbue the custom entropy into that pre-generated random number by multiplying with it. I am not crypto expert but I have done my research and many experts agree that multiplying is a very shitty way of adding entropy.

In fact it doesn't add entropy, it can actually lower it, because multiplication can only create [smooth numbers](https://en.wikipedia.org/wiki/Smooth_number) and not primes.

So if you have a dice which has 6 outcomes and hence 2.5850 bits of entropy.

If I want to add another 2.5850 bits of entropy to it, to obtain 5.17 bits, then if you multiply the numbers it will be less than that, it will be only 3.807 bits instead of 5.17 bits. Ok so it adds some entropy, but not the full amount.

If we add a small block of entropy to a large one like a 1000 sided hypothetical dice (9.9658 bits) multiplied with a 6 sided dice (2.5850 bits), it should be 12.5508 bits, but in reality its just 11.5172 bits. So it looks like it doesn't destroy the large stack of entropy, but it certainly destroys the smaller stack.

I write a quick python code so that you can play around with this concept:

```python

import math

array=[]
x=1
y=1

for x in range (999):   # from 0 to 999 
 for y in range (5):    # from 0 to 5
  prod=(x+1)*(y+1)      # cycle through 1000 x 6 sized cycle and multiple all numbers in this range from 1 to 6000
  array.append(prod)    # add the product to the array

fin=sorted(set(array))  # remove duplicates, since we are only interested in how many unique combinations (entropy) the multiplicator operator can give; then sort it by ascending order
length=len(fin)         # length of the array 

print fin
print "length: "+str(length)
print "bits: "+str(math.log(length,2)) # log2 of the length is it's Shannon entropy value
```

<BR/>

So this proves that multiplication doesn't lower the total entropy below the higherst number, but it lowers the entropy of the lowest number significantly.

So the Electrum script creates like a 128 bit number, if it replaces like 20 bits of the RNG with your custom entropy, which it doesn't, then that 20 bits might as well just be 10 bits, even if you generated them by yourself using a dice, simply because multiplication lowers it. Of course if you put there your phone number or your birthdate, that by definition has 0 entropy.

So instead of having a 128 bit strong seed, you get something like 100 bits, which is still relatively strong, but kind of not recommended.

The only way to maintain entropy is to concatenate the strings. So if you add 2 x  6 sided dice's entropy together, you do that by concatenation, not multiplication. And then the largest value becomes 66, which is 6.04439 bits, which is higher than the 5.17 bits expected, however this is only the informational size of it, it still only contains 5.17 bits of entropy. So it may be a larger informational size (because the [base 10 number system](https://en.wikipedia.org/wiki/Decimal) is inefficient), but the entropy of it will only be maximum 5.17 bits.

<br/>

# What to do?

Well if you are not affected by it, then nothing. If you are, then you probably want to generate a new wallet, through the GUI of course or without using that `--entropy` command, and send your bitcoins there.

It's not a very urgent issue, because I doubt you used more than 20 bits of custom entropy, but if you did then it is urgent, something like a 80 bit seed can already probably can be cracked by a supercomputer, or just some nerd running ASICs at home to crack people's private keys. [Remember they are already doing this](https://www.youtube.com/watch?v=foil0hzl4Pg).

You know this is why it's good to know Python language and some basic cryptographic concepts, because just like that, problems can arise, so the smarter you are the easier you can handle them. 

I have had some math background, so it was not hard for me to understand these, but I really recommend everyone to just learn programming and some basic cryptographic knowledge, at least the concepts of entropy, make sure you understand them.

It's just basic due diligence, if you want to play in the Cryptocurrency markets safely, it can definitely be an asset to know the basic concepts.


------------------------------------------

**Sources:**
* Electrum software is the Copyright of Thomas Voegtlin licensed with [MIT license](https://opensource.org/licenses/MIT).
* https://electrum.org

-------------------------------------------


<CENTER><H1>Upvote, ReSteem & <a href="https://steemit.com/@profitgenerator" target='_blank'><img src='https://s4.postimg.org/cfz9b1mnh/bluebutton.png' border='0' alt='bluebutton'/></a></H1>
</CENTER>
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorprofitgenerator
permlinkpsa-bug-with-electrum-wallet-seed-generation-vulnerability
categoryelectrum
json_metadata{"tags":["electrum","bitcoin","security","education","mathematics"],"image":["https://steemitimages.com/DQmZudN7GeojGNuN2h8DBkGJSzweaUr4byy6bcDJc2GSrdf/electrum.png","https://s4.postimg.org/cfz9b1mnh/bluebutton.png"],"links":["https://www.youtube.com/watch?v=foil0hzl4Pg","https://steemit.com/programming/@profitgenerator/electrum-bitcoin-wallet-code-audit","https://bitcointalk.org/index.php?topic=2012226.0","https://en.wikipedia.org/wiki/Smooth_number","https://en.wikipedia.org/wiki/Decimal","https://opensource.org/licenses/MIT","https://electrum.org","https://steemit.com/@profitgenerator"],"app":"steemit/0.1","format":"markdown"}
created2017-07-13 15:13:33
last_update2017-07-13 15:13:33
depth0
children10
last_payout2017-07-20 15:13:33
cashout_time1969-12-31 23:59:59
total_payout_value2.316 HBD
curator_payout_value0.410 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,037
author_reputation68,549,319,463,075
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id8,350,941
net_rshares665,581,959,661
author_curate_reward""
vote details (33)
@btcunchained ·
Thanks for the update buddy... Luckily not using electrum wallet
properties (22)
authorbtcunchained
permlinkre-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170713t191805697z
categoryelectrum
json_metadata{"tags":["electrum"],"app":"steemit/0.1"}
created2017-07-13 19:18:09
last_update2017-07-13 19:18:09
depth1
children2
last_payout2017-07-20 19:18:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length64
author_reputation490,718,345,731
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,373,584
net_rshares0
@profitgenerator ·
$0.29
Don't get me wrong Electrum is a very secure and very well reviewed software used by many whales.

It's just this particular bug that is there, if you would use Electrum the default way through the GUI then this doesn't affect people.

It only affects people who like to play around, tweak things and generate seeds the unusual way, which is why that only should be done by experts who know what they are doing.

But your average users just use the GUI version, which is totally safe to use. Besides even this issue will probably get patched in the next version, so it's no big deal.

People just have to be aware of things, cryptocurrencies are still largely in beta, anything can happen.
πŸ‘  
properties (23)
authorprofitgenerator
permlinkre-btcunchained-re-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170714t075227900z
categoryelectrum
json_metadata{"tags":["electrum"],"app":"steemit/0.1"}
created2017-07-14 07:52:36
last_update2017-07-14 07:52:36
depth2
children1
last_payout2017-07-21 07:52:36
cashout_time1969-12-31 23:59:59
total_payout_value0.217 HBD
curator_payout_value0.072 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length689
author_reputation68,549,319,463,075
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,429,935
net_rshares68,117,285,974
author_curate_reward""
vote details (1)
@btcunchained ·
Cool ☺️ that's for replying bro πŸ‘ yes the whole of cryptocurrency is a large scale experiment
properties (22)
authorbtcunchained
permlinkre-profitgenerator-re-btcunchained-re-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170714t101622013z
categoryelectrum
json_metadata{"tags":["electrum"],"app":"steemit/0.1"}
created2017-07-14 10:16:24
last_update2017-07-14 10:16:24
depth3
children0
last_payout2017-07-21 10:16:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length93
author_reputation490,718,345,731
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,440,820
net_rshares0
@izbing ·
Thank you very much for this information. Fortunately I'm not affected.
properties (22)
authorizbing
permlinkre-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170713t151723161z
categoryelectrum
json_metadata{"tags":["electrum"],"app":"steemit/0.1"}
created2017-07-13 15:17:24
last_update2017-07-13 15:17:24
depth1
children0
last_payout2017-07-20 15:17:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length71
author_reputation6,706,719,896,087
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,351,334
net_rshares0
@live2love ·
$0.02
Making the world a safer place! Good work!
πŸ‘  
properties (23)
authorlive2love
permlinkre-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170713t151549107z
categoryelectrum
json_metadata{"tags":["electrum"],"app":"steemit/0.1"}
created2017-07-13 15:15:51
last_update2017-07-13 15:15:51
depth1
children1
last_payout2017-07-20 15:15:51
cashout_time1969-12-31 23:59:59
total_payout_value0.017 HBD
curator_payout_value0.004 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length42
author_reputation343,924,648,853
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,351,181
net_rshares5,481,384,556
author_curate_reward""
vote details (1)
@profitgenerator ·
$0.02
Yes it was actually an accident that I have discovered it, it looks like the bad code has been there for more than 1 year now, I wonder how many people are affected by it. Well most people use the GUI electrum, but maybe some big exchanges, merchants, or large whales could have used the custom entropy command, and they could have now a vulnerable wallet.
πŸ‘  
properties (23)
authorprofitgenerator
permlinkre-live2love-re-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170713t152514900z
categoryelectrum
json_metadata{"tags":["electrum"],"app":"steemit/0.1"}
created2017-07-13 15:25:36
last_update2017-07-13 15:25:36
depth2
children0
last_payout2017-07-20 15:25:36
cashout_time1969-12-31 23:59:59
total_payout_value0.017 HBD
curator_payout_value0.004 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length356
author_reputation68,549,319,463,075
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,352,129
net_rshares5,451,122,270
author_curate_reward""
vote details (1)
@qagiri ·
@profitgenerator
Good Post!
Thanks for sharing.
properties (22)
authorqagiri
permlinkre-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170713t214757891z
categoryelectrum
json_metadata{"tags":["electrum"],"users":["profitgenerator"],"app":"steemit/0.1"}
created2017-07-13 21:48:00
last_update2017-07-13 21:48:00
depth1
children0
last_payout2017-07-20 21:48:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length47
author_reputation5,207,321,068,642
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,386,483
net_rshares0
@rulesforrebels ·
I'm too stupid to know how I did it and if I'm in danger lol
properties (22)
authorrulesforrebels
permlinkre-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170713t153657646z
categoryelectrum
json_metadata{"tags":["electrum"],"app":"steemit/0.1"}
created2017-07-13 15:36:57
last_update2017-07-13 15:36:57
depth1
children1
last_payout2017-07-20 15:36:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length60
author_reputation13,562,276,538,272
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,353,233
net_rshares0
@profitgenerator ·
$0.03
Well you use the graphical version of electrum not the console, are you? In that case this is no problem to you.

If you say you are not tech savvy then you probably don't play around with the console, so this doesnt affect you.
πŸ‘  
properties (23)
authorprofitgenerator
permlinkre-rulesforrebels-re-profitgenerator-psa-bug-with-electrum-wallet-seed-generation-vulnerability-20170714t074925100z
categoryelectrum
json_metadata{"tags":["electrum"],"app":"steemit/0.1"}
created2017-07-14 07:49:36
last_update2017-07-14 07:49:36
depth2
children0
last_payout2017-07-21 07:49:36
cashout_time1969-12-31 23:59:59
total_payout_value0.025 HBD
curator_payout_value0.007 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length228
author_reputation68,549,319,463,075
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,429,684
net_rshares7,844,853,797
author_curate_reward""
vote details (1)
@steemitboard ·
Congratulations @profitgenerator! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/votes.png)](http://steemitboard.com/@profitgenerator) Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard)

If you no longer want to receive notifications, reply to this comment with the word `STOP`

> By upvoting this notification, you can help all Steemit users. Learn how [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-profitgenerator-20170714t021841000z
categoryelectrum
json_metadata{"image":["https://steemitboard.com/img/notifications.png"]}
created2017-07-14 02:18:39
last_update2017-07-14 02:18:39
depth1
children0
last_payout2017-07-21 02:18:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length700
author_reputation38,975,615,169,260
root_title"PSA: Bug with Electrum Wallet - Seed Generation Vulnerability!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id8,405,835
net_rshares0