Sjors Provoost

sjors@sprovoost.nl
I disagree with nvk on several things, but I like his uncompromising approach to hardware and shipping. Testing for weak entropy is hard, this is absolutely a mistake I could have made, and I would also be furious if this lost my funds. I've been trying to come up with a witty name though. Stolecard? Goxbox? "MicroSiphon inside"?
idk. it seems to me a competent human code audit should of caught the bad wallet seed generation. basic test automation cases are never enough for highly critical functions
Maybe, if the audit was specifically about seed generation. I've worked (mostly as a reviewer) on this exact topic for two wallets: 1. the blockchain .info web wallet (after the Android incident, but that was a different codebase) 2. the Bitcoin Core wallet (when openssl was replaced) In both cases, part of the strategy was to xor the kitchen sink. So had I reviewed the code, I probably would have suggested to xor more. That would have reduced the impact. But unlike browsers and desktop operating systems, hardware wallets don't have a lot "more". I don't think I would have caught the main issue. Maybe, because I've played with esp32 before, with the help of an LLM* and a few days of time, I would have fully understood the build pipeline, and maybe realized the problem. Just maybe. Let's also not forget that hardware wallet competitors spend a lot of time and energy "hacking" each other to show off at conferences. They probably focussed more on seed extraction than generation, and therefore missed it. Security researchers also, even without a bounty, had an incentive to find and responsibly disclose this, for prestige alone. Yet they didn't. * = that's not actively hostile to security research
You are assuming it was developed following standard software dev practices. I checked the firmware repo after the fix, no regression test! In fact the only seed generation test looks to me like a hacked together mock that string matches stdout. You should also read the latest article on @npub1z6dx97f…5uf7n9, it does a very nice analysis of the commits that introduced the bugs. Looking at the commits, it seemed quite evident to me CK's software dev practices are abyssmal, definitely counter to NVK's claim about the care CK puts into their products. I still believe the bug probably would have been found much earlier if this firmware was actually MIT licensed, instead of it's current source available status. And that is purely because of NVK's lack of understanding of FOSS licenses.
I just read that article. Assuming there's no documentation *elsewhere* then I agree that the process was bad. And I would have noticed the huge commits and brought that up. This is a case where you need multiple developers in a team to keep each other honest, and say: hey, you're touching critical (build system) code that's over your head. We need to hire someone external to help with this library migration.
I also agree that writing your own cryptographic library merely for licensing reasons is a big risk. Since nobody else will use it, review is limited to security researchers, but that's still a big audience and they didn't find the issue. A random competitor that slavishly copies your firmware is not going to help you find the bug. But it's mainly a wrapper around well respected libraries like libsecp and libwally. And it's quite common for libraries to make you bring your own entropy, since that depends on the target environment.
I don't the un-FOSS-ness was a critical factor, because Google Zero and Ledger will happily look at it for the opportunity to find a bug. That said, it's worth considering whether FOSS needs to be a minimum security requirement for critical code paths. But remember that the secure enclaves are proprietary black boxes. So you'd have to treat them as unsafe and somehow get enough entropy to be cryptographically secure without it. That's a bar no hardware wallet today meets, afaik.
Can see missing the issue in review, especially wrt to the huge PR diff. But this should have been integration tested - both for entropy and proper library symbols. Dusty's article is great. Hindsight is 20/20 tho.
Entropy is hard to test. You'd have to have to run it on (slow) real hardware billions of times to find a 32 bit collision. In a simulator you don't expect to use the real TRNG. Checking library symbols is not a typical thing for an integration test, though it might have been good (in hindsight) to run a whitelist of symbols you want to see. Bitcoin Core does some of that:
GitHub · github.com/bitcoin/bitcoin/blob/master/contrib/guix/symbol-check.pybitcoin/contrib/guix/symbol-check.py at master · bitcoin/bitcoinBitcoin Core integration/staging tree. Contribute to bitcoin/bitcoin development by creating an account on GitHub.
What about bitwise collision counting as a signal? You're right - I wouldn't have thought to check for symbols prior to seeing the fix. Hindsight.
I don't think there is any, just full seed collisions. Unless the software pseudo-RNG is so bad that a few million device runs would reveal a lack of uniformity. Perhaps the lesson is that test code random number generators should yield sequential numbers, that are easier to guard against.
The closed-source stuff is more complicated, of course, but I’d expect any HWW to have at least two streams of actually random values and going forward I’d expect them to be (if at all possible within reasonable bounds) pulling a few KiB of output from each and doing at least basic statistics tests on them.

← More from Sjors Provoost