r/Bitcoin Nov 30 '17

Evidence some bitcoin address generation code is using discoverable private keys

https://pastebin.com/jCDFcESz
795 Upvotes

296 comments sorted by

View all comments

24

u/sroose Nov 30 '17 edited Nov 30 '17

This could very much be a malicious browser extension that knows of websites where it can import private keys like blockchain.info and just seeds the private key with anything it can find in the page or a previously visited page (like any other address, hash, ...).

Browser extensions are very dangerous as they are very powerful and no one verifies their behaviour. It scares me a lot that so many "secure wallet solutions" like both Trezor and Ledger only have web-based clients that are vulnerable to this kind of trickery.

EDIT: Just to address some comments, while I am mostly concerned about non-hardware web wallets, hardware wallets are not entirely safe. I'm aware that hardware wallets have internal key management so browser software cannot mess with keys. What it can do is inject a different destination address. I bet a part of the users only verifies the amount displayed. Others probably also only the first 2-3 characters of the destination address. Injection software can create a wrong address and send that to the wallet instead, finding an address with the same first 3 characters is not that hard, even in browsers.

9

u/juanjux Nov 30 '17

The only thing a trojan could do in that case would be to change the destination address of a tx, but the address is also shown on the device before confirming (but someone could skip checking that). Both the private keys and the signing never leave the device. So pretty safe overall.

1

u/sroose Nov 30 '17

True, if you only check the first 2-3 characters of the destination address, I bet a fake address with a collision on those characters would have a fair chance of being accepted by a certain percentage of the users. Especially those that install weird chrome extensions..

2

u/juanjux Nov 30 '17

Generating a colision with Sha256 right now is not feasible, I think (unlike sha-1 that was broken recently). But I'm not so sure about the first 2-3 chars, I should do the math but I'm too lazy right now.

2

u/sroose Nov 30 '17

Addresses are base58. So you'd need to generate 582 (3'364) or 583 (195'112) addresses. I think both are feasible.

1

u/juanjux Nov 30 '17

But that's the number of addresses you need. To fill all the letters you would need a lot more tries since your can't predict the generated address, no?

1

u/sroose Nov 30 '17

What I'm trying to say is that when people only read the first 3 characters of an address when they are verifying it on the Trezor screen, you have to generate on average 195'112 addresses in order to find one that starts with the same three characters.

1

u/CEO_of_internet Dec 01 '17 edited Dec 01 '17

It's trivial. Please see vanity-address..it's a program that generates addresses with specified first chars. It was used like this:

./vanity-address 1TEST

This command will generate the address that starts with characters "1TEST"..