8 ms·
Simple Contracts are Better Contracts: the Meltdown of the DAO
- Animats 10y agoThere are two fundamental problems with Etherium contracts. 1. They're executable programs. They could have been a set of declarative rules listed in priority order, but no, the designers went overboard and made them general programs with loops and recursion. There are straightforward ways to analyze sets of rules; they're usually amenable to case analysis. It's hard to analyze programs. Writing a declarative contract language is a challenge. But doing so forces the designers to think through what they want the system to be able to do, and what they don't want it to do. Doing contracts as executable programs is punting on the problem. It says "we don't know how to do this, so we'll dump the problem on the users." 2. The stack overflow problem is idiotic. The system should have been designed so that if a program aborts, anything it did is rolled back. That's the design flaw this attack exploits.
- drcode 10y agoTo be fair, ethereum has bytecode at its base- almost certainly someone will wrote a more declarative language on top of it now to help minimize the chance that unexpected calling trees can lead to unexpected behavior. Also, the existing solidity language is pretty well designed, it's just a hard problem and an even better design may be needed.
- Animats 10y agoAlmost certainly someone will wrote a more declarative language on top of it Papering over the mold seldom works. It makes things easier, not more reliable. See C++ templates.
- drcode 10y agoA better example is Haskell, which usually compiles down to a low level C dialect.
- amaks 10y agoAny language can compile to the low level C dialect.
- Animats 10y agoNote that putting a language on top of the existing language won't prevent VM stack overflows of the type used in the attack. It's more likely to hide them.
- deleted 10y ago[deleted]
- naasking 10y ago> To be fair, ethereum has bytecode at its base- almost certainly someone will wrote a more declarative language on top of it now to help minimize the chance that unexpected calling trees can lead to unexpected behavior. The mismatch between executable code and high-level language is a known attack vector called the "full abstraction" problem. This has already been used to subvert the CLR and the JVM. If your bytecode is not inherently secure, and you permit executing arbitrary bytecode, then any language running on top that builds more sophisticated invariants that aren't enforceable via the bytecode are very likely vulnerable.
- deleted 10y ago[deleted]
- sandworm101 10y agoHow many of the TheDAO Curator members are lawyers? Contracts are agreements that are meant to be legally enforceable. The enforcer has always been the King, a local governmental authority and a third party. The very concept of a contract assumes the neutral third party. That third party is to interpret the contract, identify potential scoundrels, nullify illegal contracts and generally make sure everyone isn't playing games. Smart contracts seek to sidestep that ancient structure by replacing the neutral third party with an inflexible machine. Good luck with that. Contract language is also meant as a manifestation of intent. Smart contracts seek a perfect manifestation, dismissing all notions of imperfect knowledge or misunderstanding. Typos rarely matter in real contracts. Intent can trump language where appropriate. But in smart contracts typos are everything. Good luck with that too.
- wolfgke 10y ago> Contract language is also meant as a manifestation of intent. I challenge you to create a formalization of the intent and create a better programming language for smart contracts that includes intent. I could imagine quite well that intent could be formalized to some kind of "firewall" or "sandbox" rules for the smart contract, i.e. that if the execution of the smart contract violates these rules, it will, for example, be canceled by the system.
- sandworm101 10y agoI would counter with the concept that any valid interpretation of intent must come from one with cultural understanding. Machines do not have cultural understanding. They cannot identify language/intent clearly in violation of cultural norms. Before attempting the intent code, I'd first need to see a machine capable of understanding why Shylock's pound of flesh was an illegal contract.
- jsprogrammer 10y agoMachines don't understand. They simply compute. It is up to the programmer to have them perform the appropriate computations.
- nzoschke 10y agoAs a software engineer everything here rings true to me. Use as simple of tools as possible when programming and offer many ways for mere humans to change code and review correctness and review, approve and roll back critical transactions. But this sounds effectively like the status quo with credit cards and Kickstarter. So I'm not sure what a blockchain adds other than a different platform and maintainers than the existing financial and group purchasing corporations.
- alttab 10y agoSimple contracts then are only as scalable, reliable, and secure as the code that runs off the blockchain. Arguably, that defeats the whole purpose because it is then who controls the code (since it is no longer decentralized), controls the contract. If I'm reading this right (I'm not 100% sure of that), this is the equivalent almost of not running a blockchain at all (if the idea is taken to its finality). Storing the who and the what of contracts has never really been the issue, its been the execution and the honoring of the contract that man has not yet solved. But centralizing the code that runs the contracts, and taking it off the blockchain doesn't sound like the way to do it.
- nzoschke 10y agoIt's not like honoring contracts is unsolved. Bookies have been doing it forever with questionable effectiveness. PayPal offers arbitration on stranger to stranger sales. Again with questionable fairness in tough cases. Kickstarter et al are doing a pretty good job as arbitrators and collecting money and issuing refunds more or less fairly.
- nzoschke 10y agoI do see room for improvement in efficiency. Kickstarter and PayPal surely have large teams working on arbitration, review and fraud that could be delegated back to the involved parties vote with some rules. And law suits can be very inefficient. This absolutely could be solved without a block chain.
- TheSpiceIsLife 10y agoThis absolutely could be solved without a block chain. I fail to see how, because a blockchain is just a continuously-growing list of data records hardened against tampering and revision[1]. A blockchain can't compel nor force me to action or inaction, nor enforce any legal penalty for inappropriate action or inaction. The courts exist as an attempt to resolve differences between peoples interpretation of right and wrong, "slap a blockchain on it" won't change that. 1. https://en.wikipedia.org/wiki/Block_chain_(database) https://en.wikipedia.org/wiki/Block_chain_(database)
- Aelinsaar 10y agoJust from reading commentators here at HN, it doesn't seem like these issues were unforeseen. Rather, it seemed that whatever intense optimism exists around cryptocurrencies is capable of overwhelming investor sense in return for the promise of some ideological "win".
- alistproducer2 10y agoI used to run an Ethereum meetup and I was pretty much the only skeptic in the whole group. Everyone I encountered were "true believers."
- skylan_q 10y agoThis is what it looks like to me. They couldn't see the problem happening because culture blinded them from thinking of things in such a way that would allow them to see this coming.
- draw_down 10y agoYes, I agree with that. This was pretty clearly a bad idea from the start. But, to say so was being a "hater" and so forth.
- notahacker 10y agoYup. To be honest, the bug with the implementation of the DAO that allowed someone to appropriate most of its assets is the least of the flaws behind the concept, which was fundamentally "let's put our money in a pool and let the anonymous votes of pool members decide what to do with it", complete with a big disincentive to opposing to stupid or malicious proposals since refraining from voting was the only way to ensure your funds weren't committed to a "contract", and absence of anyone, anywhere being accountable for anything as it's chief/only selling point. Since when was that a $150m opportunity?
- plttn 10y agoI feel like this might be a semi-unpopular opinion, but frankly I'm getting tired of the idea that a blockchain is the solution to every single problem the human race faces. There's this almost religious level of looking the other way whenever there's some sort of failure in a blockchain system, and they always say "that was a one-off situation"
- cyrillic 10y agoIf the contract code can be upgraded by the majority of involved parties, it would be simple to buy 51% of the voting power and change the code to pay out everything else. Each takeover would double your wallet. Am I missing something here?
- brbsix 10y ago51% attacks are a known issue. A sustained 51% attack is pretty much an existential threat to any blockchain. So I doubt the issue gets any better when dealing with individual contracts. https://blog.ethereum.org/2014/05/15/long-range-attacks-the-serious-problem-with-adaptive-proof-of-work/ https://blog.ethereum.org/2014/05/15/long-range-attacks-the-... http://ethereum.stackexchange.com/a/544 http://ethereum.stackexchange.com/a/544
- cyrillic 10y agoThank you for your valuable input. The problem I see is not in having 51% of the whole capacity of the blockchain, but of the smaller entities/organizations/contract codes. With the proposed simple contracts, the little 'start-up' contract codes with little voting power will easily get acquired by bigger ones, which then vote for a code change to pay out the remaining shares. This is much more realistic that the traditional 51% attacks. Letting the majority of a small DAO-like organization vote for code change (which translates to law-change) will not only be used to fix bugs, but to change the contract to the majorities advantage. This may eventually result in one single big contract code that incorporates every new organization on the horizon.
- nawitus 10y agoIt should be possible to define that you need e.g. 90% of the shareholders to approve a change to the contract. The 90% could still steal money from the 10%.
- brbsix 10y agoIt is. The example code for a DAO [0] illustrates how everything from minimum quorum for proposals to margin of votes for a majority is configurable. However like you said, so long as the contract is mutable, it's possible for a majority to subvert it. [0]: https://www.ethereum.org/dao https://www.ethereum.org/dao
- louprado 10y ago"Simple Contracts are Better Contracts" has always been the mantra of the Ethereum and DAO team. Most times when a security question was raised, "simple contracts" was their defacto answer [1]. This exploit suggests that the most competent developers in this space, who always preached simple contracts, are not yet able to consistently write secure contracts. Also, the OP states the importance of being able to update a contract. As of last year that meant the original contract MUST include a self-modifying code provision. Self-modifying code doesn't align well with keeping your code simple. As an aside, "contracts" are Ethereum's raison d'être and the Ether currency value is largely based on adoption. Even though this exploit did not expose a flaw in the Ethereum block chain, the Ether sell-off is an expected consequence. Lastly does anyone have a link to the original contract code and how it could be rewritten so that it isn't vulnerable to this exploit ? [1] https://www.youtube.com/watch?v=cahj4WJtp20 https://www.youtube.com/watch?v=cahj4WJtp20 Q&A at 42m44s is relevant. Edit: corrected time stamp for above video
- 109129831023 10y ago"Most competent developers"? There are probably thousands of better informed developers/researchers who would not attempt to set up such a company before they have stronger formal guarantees. Of course, if you want to be first-to-market, none of that seems to matter.
- jabgrabdthrow 10y agoMost Competent Marketers
- Avshalom 10y agoStrong formal guarantees are complicated see? and we run around telling ourselves that simple is better, so we keep writing shit code.
- alistproducer2 10y agoBailing out the DAO undermines the core value propositions of Ethereum - contract immutability (stability) and decentralization. I understand that the argument is "this is a special (ie, too big to fail) case; however, who can be sure? IMO the better way to handle this is to acknowledge the mistake and let it fail. It's embarrassing I get it. Honestly, the big bank types who threw millions at this tech without doing due diligence deserve to lose their shirt. It's called speculation for a reason. If the core team cares about the long term credibility of the project with the people who real matter - the tech community - they will not bail it out. Edit: For anyone interested, there's a really great discussion on this subject at the Ethereum reddit https://www.reddit.com/r/ethereum/comments/4oiqj7/critical_update_re_dao_vulnerability/ https://www.reddit.com/r/ethereum/comments/4oiqj7/critical_u...
- jcoffland 10y agoIf simple contracts, where much of the code is off chain, are to be the way of things it begs the question, why do we even need Turing complete contacts in the first place. A blockchain could be created which has a few fixed rules which enable the basics of a DAO with much lower risk.
- brbsix 10y agoThe AI equivalent to a recursive call bug are self-replicating Von Neumann probe paperclip maximixers that consume the entire universe. We're going to be in a world of hurt if we aren't able to sort this out. It's pretty essential that machines are able to discern our intent or the spirit of our contracts one way or another.
- leetbulb 10y agoEasy solution: just hide all of the paper in some other universe :) On a serious note, well said.
- draw_down 10y agoCode is law! Ohh, ummm, err, uhhh, except when we say it's not.
- grellas 10y agoCan code both embody and replace law for the exact function for which it is set up? DAO strives to execute through code an idealized pooled investment system by which contract issues are resolved entirely by code and wholly apart from any external societal legal or enforcement mechanisms. All well and good but, where people are involved, code simply cannot define all the relations needed to capture what the law does (and, indeed, and in spite of its flaws, does very well indeed). Consider the argument that the exploit here is not a flaw at all but just another variation on what the code does, with the result that investors who suddenly are $50M lighter in their wallets have not been harmed at all and should have no recourse to any remedy to restore their funds to them. The idea here is that the code is the contract and, if that is what the code does, well, that is what you bargained for, whether this is good or bad from any particular moral perspective. Right at the entry point of the system is a prominent disclaimer that says this in exact words. So a contract is a contract. If you don't like the result, tough. The participants here are wealthy and presumably sophisticated investors. What if they aren't? What if this were marketed to a lot of gullible small investors who were induced to part with their money through various representations stating that their funds were entirely safe, subject only to normal investment risks relating to the underlying companies they funded? What does society do when people like this lose their life savings when some newly discovered "feature" of the code allows a sharpie to walk away with their funds? Are they to have no legal recourse because a "contract is a contract," especially if it embodied in code? And what happens if a system is set up and the person or persons who find the new "feature" enabling them to walk away with other people's funds are the very people who organized the fund? Does law from the broader world step in to provide a remedy to those who lost their money? Or does the "contract is a contract, especially in code" logic work to deny any remedy to the participants here as well? And, setting aside any of the more extreme examples, what if it is simply the case that those who did participate had reasonable expectations that any code that would define and limit their rights would do all that was expected in terms of defining their investments but would include safeguards that would prevent anyone from simply coming in to remove their funds altogether (dare I say "steal")? What if they were misled into having such expectations by promoters of the venture who said or implied that such safeguards existed? Is it enough to say that none of this matters because of some disclaimer buried in fine print? Is all of this simply irrelevant just because a "contract is a contract, especially in code"? Contracts are part of any system of law that includes private property, and a very important part at that. But contracts can never define the totality of the law that applies to a given situation, even if the parties swear up and down that that is their intent. That is why securities laws exist, to help investors who get swindled by sharpies with well-honed contracts. That is why the laws relating to fraud exist, to help those who are misled by others to their financial detriment. Indeed, that is why a sophisticated body of laws exists relating to contracts themselves, to cover cases where the intent of the parties is sometimes so frustrated by one thing or another as to make it inequitable to enforce a contract. Law is and always has existed in multiple layers. Legislatures pass statutes but courts exist to interpret them to cover specific cases as disputes arise. The same with administrative regulations promulgated by agencies. Even within the courts themselves, common law courts would declare legal "rules" only to have courts of equity intervene to correct things where the "rules" led to harsh or inequitable results. Basically, all of this is another way of saying that human relations are complex and any system of laws and justice needs to be able to handle such complexity if it is to be worthy of being a system of justice. Perhaps in narrow cases, things such as DAO can be set up to create a rich guy's playground of sorts in which, for the overwhelming number of cases, outside laws play no part within the self-contained system. Perhaps there is even an ideal of some type to be realized here (get rid of lawyers, etc.). But no such system can ever be utterly divorced from the rules of the broader society. Ideal or no ideal, this is just not how the law works. Apart perhaps from some survivalist society or other, people simply cannot exempt themselves from the general rules of law no matter how much they desire to do so. They can limit the application of such broader laws to a degree but, when key bounds are transgressed, the law will apply in its full force regardless of their intentions. So, I would say that the curators here probably had no choice. It was either do what they did or watch as lawsuits followed, probably in abundance. This may have violated some ideal in play here but it was a pragmatic necessity given how law in reality works (and always will work).
- jawatson 10y agoI may be stepping outside of my area of expertise, but doesn't this seem like a perfect place to apply formal verification tools? As long as the contract isn't too long, it should be possible to ensure that the implementation exactly matches the specification.
- ybroze 10y agoI really wanted to know about the Data Access Object.
- modarts 10y agoThought this was a commentary on the poor API contracts exposed by data access objects
- simpleblend 10y agoI ended up writing an article explaining my position on the whole thing: https://blog.simpleblend.net/dao-attack-whos-blame/ https://blog.simpleblend.net/dao-attack-whos-blame/