Live data from Hacker News

Android RNG Weakness Renders Bitcoin Wallets Insecure

bitcoin.org

71–80 of 105 posts

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#71
post #24
post #11

Earlier quoted context omitted.

That second link doesn't seem to be the current problem. The current problem is that the same random number is being returned more than once.

On the other hand, the author of the Bitcoin Wallet Android app thinks it's a SecureRandom problem: https://code.google.com/p/bitcoin-wallet/source/detail?name=...

Yeah but the current problem with SecureRandom is that it returns the same random number more than once. That armoredbarista page only describes cases where the numbers are less random than they should be, not that they are returned multiple times.

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#72
post #6

Iä! Digital Signature Algorithm! The Black Goat of the Woods with a Thousand Crypto Bugs! I don't know the Bitcoin software involved at all, but I can sketch out an attack that might shed some light on it, and, more importantly, instill an appropriate fear of DSA into you: To generate a DSA key, you come up with primes p and q and a generator g, which process is a paralytic non-Euclidian brain injury I will not attem…

Well then...first I learned something about DSA, and now I'm 1/3 of the way through re-reading The Black Goat of the Woods with a Thousand Young. Jesus Christ I am a nerd. Iä! Iä!

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#73
post #61

Earlier quoted context omitted.

So your position is that Debian didn't go far enough? They should have disabled OpenSSL's CSPRNG entirely and redirected its internal calls to perform IO operations on /dev/[u]random?

Modulo the fact that Debian shouldn't be mucking with the inner workings of packages in the first place, sure; stubbing out OpenSSL's CSPRNG with calls to the OS CSPRNG seems like a reasonable plan. It is, by the way, part of the NaCL design too.

Last I heard, there were still some "security oriented" OSes using RC4 for their /dev/random.

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#74
post #24
post #11

Earlier quoted context omitted.

That second link doesn't seem to be the current problem. The current problem is that the same random number is being returned more than once.

On the other hand, the author of the Bitcoin Wallet Android app thinks it's a SecureRandom problem: https://code.google.com/p/bitcoin-wallet/source/detail?name=...

That commit series doesn't actually appear to use the new class, besides initialising it.

Simply initialising it is insufficient, because you need to call addProvider() (cf. https://developer.android.com/reference/java/security/Securi... ) to actually have any effect.

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#75
post #74
post #24

Earlier quoted context omitted.

On the other hand, the author of the Bitcoin Wallet Android app thinks it's a SecureRandom problem: https://code.google.com/p/bitcoin-wallet/source/detail?name=...

That commit series doesn't actually appear to use the new class, besides initialising it. Simply initialising it is insufficient, because you need to call addProvider() (cf. https://developer.android.com/reference/java/security/Securi... ) to actually have any effect.

The LinuxSecureRandom class has a 'static initializer' block, which will run as soon as the class is loaded. (That is, triggered by the reference and initialization call, but just before.)

It purports to install LinuxSecureRandom as a new systemwide default (LinuxSecureRandom, lines 56-57).

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#76
post #37

Earlier quoted context omitted.

you should use your OS's CSPRNG (here, /dev/random) to the exclusion of any other RNG Bad advice. Use your OS's CSPRNG to get a seed, but work with your own PRNG (say, HMAC_DRBG) internally. Going to the OS every time you want a few bits is both very slow and makes it far easier for local attackers to see when you're using entropy.

Strongest possible disagree. For instance, the Debian OpenSSL bug was an entirely unforced error stemming from applications that chose to use Debian OpenSSL's terrible CSPRNG on top of the OS's CSPRNG. The local attacker scenario you're talking about is a theoretical risk when there are attackers running code in the same OS as your CSPRNG; a far more likely concrete flaw is, for instance, a SecureRandom implementatio…

Strongest possible disagree.

Ok, we disagree. It wouldn't be the first time. ;-)

the Debian OpenSSL bug was an entirely unforced error stemming from applications that chose to use Debian OpenSSL's terrible CSPRNG on top of the OS's CSPRNG

I think the biggest problem was that OpenSSL used OpenSSL's CSPRNG after Debian broke it. Having applications all open+read+close /dev/random is not going to prevent that.

a far more likely concrete flaw is, for instance, a SecureRandom implementation that allows developers to specify insecure seed values.

A SecureRandom implementation should not allow the application to provide seed values except as additional input. It should always seed itself from the operating system entropy source, with no option to disable that.

Aside from the issue of performance (which can be severe) and the timing information leakage to local spies, there's a very practical reason to avoid developers read from /dev/random:

  int fd;

  fd = open("/dev/random", O_RDONLY);
  read(fd, buf, buflen);
  close(fd);
I've seen this on a number of occasions, and it works perfectly fine... until your server gets busy, the kernel entropy pool runs down, and /dev/random returns a short read. At that point, all hell breaks loose. To me, this scenario alone is enough to tell developers to use a library's automatically seeded CSPRNG instead of reading from the kernel.

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#77
post #6

Iä! Digital Signature Algorithm! The Black Goat of the Woods with a Thousand Crypto Bugs! I don't know the Bitcoin software involved at all, but I can sketch out an attack that might shed some light on it, and, more importantly, instill an appropriate fear of DSA into you: To generate a DSA key, you come up with primes p and q and a generator g, which process is a paralytic non-Euclidian brain injury I will not attem…

Another interesting thing about DSA is that the signatures allow for public key recovery i.e. given a signed message, you can (usually within 1 or 2 possibilities) determine the public key of the signer. It's a bit like a handwritten signature where everybody can read your name amongst the scrawl.

Most of the time this property is useless, because you want to verify the signature against a known-good key, but it does also mean you're probably not going to want to use DSA to pass signed covert messages.

Schnorr signatures actually have a simpler, and I think more intuitive, construction and don't have this property. They also don't require collision resistant hashes.

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#78
post #61

Earlier quoted context omitted.

Modulo the fact that Debian shouldn't be mucking with the inner workings of packages in the first place, sure; stubbing out OpenSSL's CSPRNG with calls to the OS CSPRNG seems like a reasonable plan. It is, by the way, part of the NaCL design too.

Last I heard, there were still some "security oriented" OSes using RC4 for their /dev/random.

arc4random predates modern OS CSPRNGs.

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#79
post #37

Earlier quoted context omitted.

Strongest possible disagree. For instance, the Debian OpenSSL bug was an entirely unforced error stemming from applications that chose to use Debian OpenSSL's terrible CSPRNG on top of the OS's CSPRNG. The local attacker scenario you're talking about is a theoretical risk when there are attackers running code in the same OS as your CSPRNG; a far more likely concrete flaw is, for instance, a SecureRandom implementatio…

Strongest possible disagree. Ok, we disagree. It wouldn't be the first time. ;-) the Debian OpenSSL bug was an entirely unforced error stemming from applications that chose to use Debian OpenSSL's terrible CSPRNG on top of the OS's CSPRNG I think the biggest problem was that OpenSSL used OpenSSL's CSPRNG after Debian broke it. Having applications all open+read+close /dev/random is not going to prevent that. a far mor…

Linux random/urandom is supposed to prevent short-reads for exactly this reason. You raise an interesting point, but I'm not persuaded that the risk of quietly failing to read from the random device is greater than the risks of adopting an entire new CSPRNG to sit on top of the OS's CSPRNG.

Re: Android RNG Weakness Renders Bitcoin Wallets Insecure

#80
post #78

Earlier quoted context omitted.

Last I heard, there were still some "security oriented" OSes using RC4 for their /dev/random.

arc4random predates modern OS CSPRNGs.

So does OpenSSL. I think it's just not reasonable to expect a widely-portable crypto primitive and protocol library to judge the quality of the host /dev/[u]random and delegate to it. Of course, they seed from the host device and try to estimate the entropy it provides.

Even that OS with the biased /dev/[u]random using RC4 because it was fast would keep a separate RC4 state in each process' libc to avoid the overhead of kernel calls.

Post reply on HN