Live data from Hacker News

The bug which lost more than $600M in various cryptocurrencies a few hours ago

twitter.com

61–70 of 126 posts

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#61
post #27

Earlier quoted context omitted.

A lot of these contracts, and especially those owned by first-tier cryptocurrency companies, are reviewed by 3rd party auditors. Of course that doesn't completely remove the risk, but certainly at least ensures that no obvious bugs are missed.

It’s very hard to take this claim seriously in this thread, which details a huge (and somewhat obvious) security vulnerability in a currency worth at least $600m (an amount anyone would assume is “first-tier”).

I had never heard of this bridge before the attack. The fact that a project manages to attract half a billion in capital unfortunately doesn't say all that much, since so much capital is flowing in so fast to every project with a pulse.

And the bug wasn't really obvious, although the lack of input sanitation is something an auditor (given enough time) would probably point out.

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#62
post #40
post #7

So as someone very critical of the whole DeFi / Smart Contracts philosophy (purely in terms of practicality, not the high-level concepts behind it) - please explain to me how the impacts of those bugs are going to be mitigated going forward. At will and ex-post broadcasting "oops, we had a bug - please roll back or block the bad actors" doesn't strike me as a solid solution, nor a fair & automated one. I was under th…

At least up to this point, the amount of growth in the industry from moving fast and having buggy software (as opposed to moving slow and having fully verified software) has more than made up for all the hacks. For every $600 million dollar hack, there's been $6 billion dollars in gains from growth in the industry. Moving slower means fewer hacks, but it also means lower growth, and the growth is the more important m…

There are several issues with this. The main one is how can people trust a product that will let them lose money in the name of growth.

The second one is that the more money, the more incentives to hack. And given that transactions are irreversible, you only need each bug once, you don't care that it's fixed later. So if a bug can report a hacker millions of dollars, there's going to be quite a lot of hackers researching, probably with more effort there than the effort put in best practices, audit and formal verification.

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#63
post #2

Can someone help ELI5 please? [EDIT] Okay not 5... maybe like 25 but not in crypto tech.

If I understood it correctly, there was one contract (EthCrossChainManager) which could call arbitrary methods on other contracts, the methods being identified by a 4-byte hash. There was another contract (EthCrossChainData) which had a method the attacker wanted to call, since it allowed to change relevant public keys, but which had a check on the identity of the caller. However, that check allowed the former contract to call the later. So the attacker only had to find a method name which led to the same 4-byte method identifier, and trick one contract into calling the other; the first one though it was calling an arbitrary function on an unrelated arbitrary contract, while the second one thought it was a legitimate internal call from the related first contract.

As another comment mentioned, this is a classic "confused deputy" vulnerability.

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#64
post #2

Can someone help ELI5 please? [EDIT] Okay not 5... maybe like 25 but not in crypto tech.

Ethereum smart contract functions (i.e. methods) are addressed based on a four-byte hash of the signature, within the context of the smart contract itself (a smart contract is analogous to a Java or Python class instance, having state and logic). So, after compilation, a function will be addressed like ., if you can imagine.

This is distinct from other languages where methods and functions are addressed unambiguously by the full signature as a string (like in Python), or by a specific memory address (like in C).

In most situations this addressing scheme works very well, because in practical terms there will never be a hash collision inside of a smart contract, and if there were such a collision, the compiler would catch it and fail to compile, and the EVM would reject any bytecode containing such a conflict. Regardless, this is not a problem within Ethereum.

The thing is, Poly Network is a separate thing from Ethereum, and although it does integrate with Ethereum, it does so with its own separate software. The way it interfaces with Ethereum is via several Ethereum smart contracts, including one (smart contract #1) that holds the tokens that it manages on the Ethereum blockchain (valued in the hundreds of millions of dollars), and another (smart contract #2) that permits users of the Poly Network software to invoke arbitrary functions on arbitrary smart contracts already deployed on Ethereum. The Poly Network software talks directly to these smart contracts.

Poly controls these smart contract with a permissions system implemented inside the smart contracts themselves, whereby the invocation of any function of the smart contracts is verified against a list of public keys (i.e. account addresses) that are authorized to make any such invocation. Only users that hold the private keys that correspond to these authorized public keys may invoke the smart contracts' functions; in practice, these keys are controlled by the Poly Network software. Each smart contract stores this list within its own data (analogous to private instance data inside a Java object).

The problem is that the Poly Network proprietary software uses the same authorized key pairs to move funds in and out of smart contract #1 and also to invoke smart contract #2. This means that a user of the Poly Network software can use smart contract #2 to invoke smart contract #1, which is very bad.

What happened is that the hacker figured this out, and used smart contract #2 to update the authorized public key list inside contract #1, which was allowed to happen because he routed the message through the Poly Network software, which dutifully signed the message with its own secure private keys. In other words, the Poly network signed a message from the hacker authorizing the Poly smart contracts to replace the authorized public key list with the hacker's public key, giving the hacker control over contract #1.

It wasn't as simple as this, though. Apparently, although the Poly Network allows any function name to be invoked by the end user, that function is required to be invoked with a signature that includes a particular set of arguments, specifically "(bytes,bytes,uint64)". The hacker wouldn't be able to call "putCurEpochConPubKeyBytes" directly from the Poly Network software, because "putCurEpochConPubKeyBytes" accepts only one argument, not the three arguments that the Poly Network software uses to construct the signature for function invocations sent from contract #2.

So, the hacker had to discover another function name that when combined with the three arguments would result in a four-byte hash that corresponded to the four-byte hash of the function he wanted to invoke. By brute force the hacker discovered that "f1121318093(bytes,bytes,uint64)" has the same four-byte hash as "putCurEpochConPubKeyBytes(bytes)". So the hacker used an invocation to "f1121318093(bytes,bytes,uint64)" to invoke "putCurEpochConPubKeyBytes(bytes)" on contract #1, and thereby replace the authorized public keys for that contract with his own. Having obtained control over contract #1, he was able to transfer out all of the tokens it controlled, to the tune of hundreds of millions of dollars.

There are any number of ways that Poly Network could have prevented this from occurring, most obviously by not allowing contract #2 to invoke contract #1. They also could have done a better job of filtering what kinds of messages users can send from the Poly Network software.

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#65
post #14

Cryptocurrencies are fascinating but the irreversibility is not a feature but a bug. I don't get the appeal for irreversibility. A legitimate trade always occurs between willing partners, why would you be so afraid that the transaction would be cancelled? The only legitimate use that comes to my mind are complex financial instruments where things mostly happens with an assumption that the underlaying assets are very…

One thing I don't understand is this. The vast majority of people will use credit cards (or equivalent) to purchase things. If I wanted to pay with Bitcoin I would get a crypto credit card. Payment processing just isn't the same thing as a currency. It's like expecting the dollar bill to do payment processing. Is lightning network supposed to be that fancy decentralized payment processing platform that is going to ki…

Yes and yes.

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#66
Is the disincentive with lack of security going to be so strong with crypto projects that people finally take it serious enough to make it a first priority?

I don’t like loss or theft ,obviously, but I have to think if regular IT/apps/software/networks etc.. had this big of a material threat, we would see far more secure systems and organizations.

So it would reason that as block chains and crypto eat the world they will raise the bar.

Am I thinking about this right?

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#67
post #7

So as someone very critical of the whole DeFi / Smart Contracts philosophy (purely in terms of practicality, not the high-level concepts behind it) - please explain to me how the impacts of those bugs are going to be mitigated going forward. At will and ex-post broadcasting "oops, we had a bug - please roll back or block the bad actors" doesn't strike me as a solid solution, nor a fair & automated one. I was under th…

Over time, there will be old smart contract code that is trusted because it has been used for so long, and there will be new code that is less trusted because it is new. Time will ensure that smart contract code that is flawed will be discarded and forgotten, or blacklisted, so it will be safe to assume that any old code that is still popular is trustworthy. Time will also ensure that popular code is well understood by experts who would be in a position to detect and understand any problems in the code.

The problem of buggy software will continue to exist for new smart contracts that are introduced and manage to capture value quickly, but as the ecosystem matures and more niches are filled, new code will be less likely to attract large numbers of users, so the scope and impact of any bugs in that code will be much less.

Eventually an equilibrium will be reached whereby survival of the fittest ensures that the smart contracts most people rely upon can be trusted. Effectively, some smart contracts will build brand value, and people will be able to rely on the reputations of these smart contracts. Some people may take a risk on a new smart contract and loose (or win), but most people who follow the heard will not have a problem.

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#68

Is the disincentive with lack of security going to be so strong with crypto projects that people finally take it serious enough to make it a first priority? I don’t like loss or theft ,obviously, but I have to think if regular IT/apps/software/networks etc.. had this big of a material threat, we would see far more secure systems and organizations. So it would reason that as block chains and crypto eat the world they…

Haha, that is a really interesting point. It actually seems inevitable imo.

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#69
post #50
post #43

Earlier quoted context omitted.

> in the case of online sales, the merchant is the known quantity with a reputation This is absolutely not true. There’s plenty of risk buying expensive goods online, lots of problematic merchants. I don’t understand why merchants are inherently more trustworthy than customers?

It's not that merchants are inherently more trustworthy, it's that the buyer has ample opportunity to research the merchant and establish credibility. If there's a merchant that only accepts crypto and the buyer can't get comfortable that the merchant is trustworthy, the buyer can walk away instead of making a purchase. The merchant has much less to go on. There aren't review websites detailing the reputation and his…

I don't quite buy that. The ability to claw back credit card payments to fraudulent merchants enables commerce before credibility is established. This is in the merchant's interest too, especially when they're starting out.

Re: The bug which lost more than $600M in various cryptocurrencies a few hours ago

#70
post #27
post #23

There's a serious fundamental problem with DeFi that can't be solved with blockchains. Someone starts a blockchain company and hires a bunch of devs who make, idk, $40 to $100 per hour to build the thing. Maybe more, it doesn't really matter. Even just one dev or a few devs can make all the contracts needed for this. One day that dev notices a vulnerability in the smart contract he's writing! He has two choices: (a)…

A lot of these contracts, and especially those owned by first-tier cryptocurrency companies, are reviewed by 3rd party auditors. Of course that doesn't completely remove the risk, but certainly at least ensures that no obvious bugs are missed.

As this space evolves, I think there will be insurance and basic best practice safety measures. Also considering that almost all blockchains are open by design, it's no trivial task to liquidate a large sum of stolen tokens. So its not exactly a straight path from writing a script at Starbucks to making hundreds of millions of dollars.
Post reply on HN