Finding the Greedy, Prodigal, and Suicidal Contracts at Scale

Alex3917 | 121 points

Some of these bugs are crazy:

> Prodigal contracts. In Figure 6, we give an example of a prodigal contract. The function 'tap' seems to lock Ether because the condition at line 4, semantically, can never be true. However, the compiler optimization of Solidity allows this condition to pass when an input greater than 20 bytes is used to call the function 'tap'. Note, on a byte-code level, the EVM can only load chunks of 32 bytes of input data. At line 3 in 'tap' the first 20 bytes of 'nickname' are assigned to the global variable 'prev' , while neglecting the remaining 12 bytes. The error occurs because EVM at line 4, correctly nullifies the 12 bytes in 'prev', but not in 'nickname'. Thus if 'nickname' has non-zero values in these 12 bytes then the inequality is true. This contract so far has lost 5.0001 Ether to different addresses on real Ethereum blockchain.

Whaaa?

gwern | 6 years ago

It seems pretty clear to me that crypto-currencies and blockchain apps, as a technology, are quite unlike anything that have come before it, and fundamentally don't integrate well with the wider world of technology (at least right now).

An obvious issue is that smart contracts cannot make use of information from the outside world (unless of course, fed from a single centralized party). Perhaps this can one day be worked around with some innovations from game theory, but I have not seen it. This demonstrates a lack of integration with the rest of humankind's technology.

A smart contract, once published, cannot be amended. Let that sink in for a while. This breaks the most basic assumption people have about software companies: that they can be agile, move fast, push updates, and fix things.

As far as I can tell, due to the halting problem, one can never actually prove that a sufficiently complex smart contract will not be explosively broken at some point in the future. (The fix for contracts being explosively broken is a hard fork, which only works if you are explosively broken enough to convince a global majority of the network to go along. Your own token probably isn't important enough.)

Immutability provides a lot of interesting benefits of course, but let's not forget how explosively wrong it can go as well.

It all seems like the kind of tech you wouldn't trust to a bunch of fast moving startups, many of which now have actual VC's invested in their outcomes and will put time pressure on them.

It seems most of the HN crowd is well aware of this stuff. But I think it bears repeating, because man, this fishy odor is intense.

etaioinshrdlu | 6 years ago

Holy moly what? Billions (?) of dollars in contracts that basically the coder screwed up. so this is interesting. A Lawyer who effectively writes an infinite loop in legalese has a lot of issues. More than it seems the coders who write the Ether contract

which means we will start seeing changes that may be

- the death of the no warranty warranty

- Escape hatches in every smart contract (perhaps well-known addresses have specific values and contract is voided)

- The slow professionalisation of software

I mean there is nothing stopping two people writing and acting under a terribly written contract. but when it goes badly they have to take it to professional "coders" (lawyers) who work out how to unfuck it. this sounds a of like that

lifeisstillgood | 6 years ago

I believe this is the problem that Quantstamp is trying to address with their audit service: https://quantstamp.com/auditrequest/

rrggrr | 6 years ago

Does this title to a scholarly paper read like a newspaper headline to anyone but me?

The trading level of ethereum has remained unchanged after the publication of this document?

jeisc | 6 years ago