Live data from Hacker News

Missing line in a smart contract leads to $10M hack

rekt.news

171–180 of 333 posts

Re: Missing line in a smart contract leads to $10M hack

#171
It is surprising that people would entrust large amounts of money to Turing complete C-like programming languages in an environment where mistakes are irreversible. Surely you would want to use a language that makes it harder to accidentally introduce common vulnerabilities?

For example, considering contracts are likely to be state machines (and the error in this case is a state machine issue), maybe an explicitly state machine-oriented language design would be good? I'm not familiar with academic research in this area but I have used a real-world one before, Linden Scripting Language, which incidentally is also used for what you could call “smart contracts” involving money, albeit not in a cryptocurrency environment.

Re: Missing line in a smart contract leads to $10M hack

#172

Earlier quoted context omitted.

> so where does one draw the line between theft and just doing what the code allows? This is the heart of the problem with smart contracts. The theory is that the code is the law. There is no theft. There is no need to trust, authority, or arbitration. Of course, this only works when the smart contracts perfectly meet a correctly defined spec and have no bugs.

That's not enough, all parties would have to have 100% awareness and understanding of the smart contract, detail by detail. Real life contracts sometimes turn out to have non-enforceable clauses within our legal framework, or may be entirely invalid if, for example, signed under pressure or false pretense.

And a judge will decide whether the contract was signed under duress. Who will judge smart contracts?

Re: Missing line in a smart contract leads to $10M hack

#173

Earlier quoted context omitted.

Solidity is a DSL. DSLs have their purposes and this happened to be a correct purpose. It just also happens to be that Solidity is a terribly designed language.

In what way is Solidity terribly designed?

Not an expert, but integer overflows getting silently truncated sounds pretty terrible. I understand there are safe arithmetic libraries, but overflow exceptions should have been built right into the VM

Re: Missing line in a smart contract leads to $10M hack

#174

Earlier quoted context omitted.

Yeah, that's my question with all this. I mean, ransomware is obviously illegal. Finding vulnerabilities in smart contracts - well, "the code is the contract", so the hacker is just executing the code as it was published. I mean, the whole reason Ethereum Classic exists is because a subset of Ether folks felt that restoring the funds in the original DAO hack was contrary to the whole "the code is the contract" ethos.

Ignoring contract law (which would not blindly accept "the code is the contract", and people's ethos does not allow them to arbitrarily decide how contracts shall work in the country where they live), the fact that some action was explicitly written in a contract that was properly signed by everyone does not necessarily mean that the action was lawful. For example, if you intentionally misrepresent what the contract…

I mean, at its heart then you are really arguing than smart contracts shouldn't exist in the first place (I don't really disagree).

The entire reason that smart contracts exist is to get rid of the need for any trusted third party intermediary because (as proponents argue) all of the logic for the contract is completely embedded in the code.

If it then becomes necessary to say "The code is the contract, unless there's a bug, in which case we'll have some single or set of arbiters decide what the code was really supposed to do" then why have smart contracts at all, why not just go through a normal escrow process where there is an independent arbiter trusted to determine who "lawfully" deserves the funds.

Re: Missing line in a smart contract leads to $10M hack

#175
post #169

Earlier quoted context omitted.

Yes, a smart contract is not a legally-binding agreement, although it could be a component of a legally-binding agreement. That’s my point. The smart contract in my hypothetical scenario might be something like a transaction with 3 parties: you (the customer), the construction company, and a third-party verification service, that executes your payment to the construction company when any 2 of the parties agree to exe…

But for this arrangement to work the customer, the construction party and the third-party need to enter into an agreement, i.e. a traditional contract. A traditional contract is legally binding, so of course the courts would treat it as legally binding. The smart contract may be part of the agreement but a smart contract by itself is not an agreement and something cannot be a legally-binding agreement if it isn't an…

I suspect a court would tend to take the existence of the smart contract as a pretty clear indication of the intent of the involved parties. But of course if you’re entering a significant commercial agreement like this you had better make an explicit traditional contract as well.

Re: Missing line in a smart contract leads to $10M hack

#176
I never understood the point of smart contracts. Why not just launch a new blockchain or decentralized application by forking code and launching nodes? That way you don't need to pay Ethereum fees and you get a lot more flexibility - Also, your project will not be constrained by Ethereum's scalability limits and you won't have to pay fees to subsidize the popularity of other projects which are running on the same platform... Ethereum seems to facilitate mostly short term scams.

Projects launch, raise a ton of money, then when people try to actually use the new project, they realize they have to pay $20 per transaction. This quickly kills the project; now onto the next scam. What kind of brand new project can justify making their users pay $20 per transaction? I struggle to think of any genuine use case.

Re: Missing line in a smart contract leads to $10M hack

#177

Earlier quoted context omitted.

But also, surely the traditional legal system will still handle disputes over smart contracts just like it does with traditional contracts. I can’t imagine that a missing line of code (intentional or not) would be treated any differently by the legal system than a vaguely-worded clause in a traditional contract. The legal system almost certainly will not say “your contract was just code and the code executed properly…

Then what's the point of smart contracts? If you always must have some form of repudiation/reversal mechanism, you might as well go with the traditional contracts. You could argue there will be lowered costs in the happy path where nothing goes wrong, but I'm not sure that's valid since the underlying software still needs to written/supported by someone.

One obvious point would be transactions for which the traditional legal system is not an option, like illegal transactions or highly secretive transactions. But yes, I think advocates would provide other examples of lowering costs.

Re: Missing line in a smart contract leads to $10M hack

#178
post #170

Earlier quoted context omitted.

That premise is clear, proponents of smart contracts would like it to become true, but as of now that premise is simply not true anywhere in the world. There may be obvious practical difficulties in identifying the counterparty and enforcing a judgement in them, but if that becomes possible (and if $10m is at stake, perhaps it might become possible, bounties, etc) then the argument that "code is the only representati…

But code is the only representation, like it or not. The smart contract is code and nothing else.

That's almost true - there often is also some out-of-bounds communication about that code before the smart contract is implemented, which can help establish intent, which matters a lot in resolving disputes about a contract.

But the actual contract terms between the parties and facts like is this contract valid at all, who owns what and who owes what to whom are ultimately determined by contract law, not by the smart contract, like it or not. The smart contract may determine possession of certain things, and in many cases it would be uncontested and there it has a purpose of just doing the contract settlement automatically, but as soon as there's a dispute, then the legal ownership and any claims would be settled according to contract law, not according to what the code says.

Re: Missing line in a smart contract leads to $10M hack

#179

Earlier quoted context omitted.

so where does one draw the line between theft and just doing what the code allows? I wonder in the future crypto courts is the defense, "your honor, the code allowed me to call initialize again, they specifically didn't set it to true." going to fly? Or will you have to prove that the 10 mil you now have was intended to be given to you and your "victim" isn't a victim at all.

> so where does one draw the line between theft and just doing what the code allows? This is the heart of the problem with smart contracts. The theory is that the code is the law. There is no theft. There is no need to trust, authority, or arbitration. Of course, this only works when the smart contracts perfectly meet a correctly defined spec and have no bugs.

> Of course, this only works when the smart contracts perfectly meet a correctly defined spec and have no bugs.

In practice, if using a smart contract as a contract, the way you'd use a paper contract, then two parties would sit down and negotiate; draft the negotiated agreement into the form of a smart contract; and then agree (signatures, handshake, multi-sig deployment, whatever) that "what the smart contract does — as executed by the network-consensus abstract machine — is our explicit mutual intent, and damn any statement by either of us to the contrary."

This is the same thing you're doing with a paper contract: by both signing it, you're agreeing that "what the paper contract says — as interpreted by a judge — is our explicit mutual intent, and damn any statement by either of us to the contrary."

Of course, nobody's actually using smart contracts as contracts. They're just using them as trusts/agents. For now.

But a smart contract used as a contract wouldn't have "bugs." It's a negotiated agreement; negotiated agreements have loopholes. And loopholes are perfectly legal. If you left one in, and your counterparty exploits it? Too bad for you. You should have run your contract through a better (code) lawyer.

Re: Missing line in a smart contract leads to $10M hack

#180
There might be something deeply interesting in that news actually. 'initialised = true' is obviously a bad pattern, now people cant argue about it anymore. Why is it bad? Obviously, if you forgot the line then... BOOM. So instead I check whatever main variable the initialisation initialised before the initialisation starts - even when it looks a bit awkward cause it does sometimes. Also, the whole concept of initialisation is a bad pattern. You dont want to have an initialisation whenever you can avoid it, you want to perform the whole calculation every time. 'initialisation' implies a state machine. You dont want state machines, you want stateless machines, as much as possible. So yeah, 'initialisation' is a good optimisation some of the time and most of it a bad compulsive-caching habit.

'initialised = true' just costed people $10M. I really like those DeFi things cause at first glance.. I think they might actually teach people how to code!

Post reply on HN