Researchers find 3,686 dangerously broken Ethereum contracts
3,686 of a million scanned. Only a 0.36% fail rate, but each might cost hundreds of millions of dollars.
Humans ruin everything. And unfortunately, they're still the ones who program the much less fallible machines.
This human error is on full show in a new report. Researchers took an automated walk through almost a million live Ethereum contracts to search for vulnerabilities. They successfully identified and tracked down 3,686 errors, with ties to millions of dollars worth of Ethereum, suggesting that about 0.36% of all Ethereum contracts might be flawed.
The system they used to uncover these errors was also able to uncover the famous Parity bug which recently locked away about $160 million at-the-time-worth of Ether forever, in one of history's more expensive programming errors.
Blockchain architecture is uniquely tamper-proof, but sometimes there are very legitimate reasons to go tampering.
The different types of broken
The researchers divided the flawed contracts into three rough categories and gave each one a vaguely poetic name.
- Prodigal contracts – A contract which can be robbed and manipulated to carelessly release Ether to another address, such as in the DAO attack.
- Suicidal contracts – A contract which can be killed by an outside attacker.
- Greedy contracts – A contract which can be manipulated to lock away the Ether held.
Systems will frequently depend on multiple contracts, so incidents will often involve more than one of these. For example, the Parity library contract was suicidal, while the its wallet contracts were greedy.
The Parity incident
The Parity wallet project had raised a couple hundred million dollars worth of Ether when someone supposedly accidentally, potentially deliberately, killed the Parity library contract (suicidal).
Unfortunately, the Parity wallets were also greedy, so this ended up permanently freezing all the Ether in its wallets, forever out of reach. Oops.
There are many situations in which a contract will need to release funds. For example, Ethereum games will often have some mechanism for players to win Ether, and there's often a mechanism for contracts to send all funds back to the owner's wallet in the event of an attack, or as a kind of fail-safe.
But prodigal flawed contracts are ones which have a method by which an unrelated address, without any connection to the contract, has a way of withdrawing funds from the contract without a valid reason.
One example the researchers found was a bounty contract that let anyone with the right know-how claim all the bounty funds.
Kill switches are also relatively common, to be used when a contract is malfunctioning, under attack or otherwise needs to be gone. Or accidentally in some cases.
One of the suicidal contracts the researchers discovered, other than Parity, was a system that didn't properly set permissions for invoking the kill switch. Kind of like a self destruct button that any passerby could push.
These are contracts which risk freezing all their Ether. The most common example found in this study was contracts that were able to receive Ether, but simply lacked any possible way to send Ether out. Any Ether sent to these would be lost forever.
How are these problems being solved?
Ethereum contracts use their own programming language called Solidity. The downside of this is that programmers need to learn a new language to create Ethereum contracts, and mistakes can be very expensive and literally impossible to resolve if they're not caught in time. This is often regarded as one of Ethereum's main flaws.
When these errors or attacks do occur, they can sometimes be resolved by forking the entire Ethereum ecosystem. Whether this should ever be done is an ongoing debate. At the moment, core Ethereum developers maintain that it should not ever be an option, and that introducing it as an option will only make the system more centralised and subject to corruption.
It's only ever been done once before, and that was following the DAO attack. The funds were recovered and the damage was undone, but the ideological schism had the side-effect of creating the Ethereum Classic fork.
While people are still putting forward their opinions, it's looking fairly unlikely that there will ever be a built-in mechanism for recovering funds lost to programming errors.
But there are still other ways the problem might be resolved.
- Studies like the one discussed here, and corresponding security audits. The main focus of this study was to test a new program for sniffing out bugs and errors in programs before it's too late. It certainly helped the researchers find and categorise a lot of errors, so it can definitely do something. Existing smart contract auditing systems like Quanstamp are designed to do this.
- A growing library of reliable contracts. A growing library of tried and tested contracts, and general familiarity, can reduce the risks over time and ease the burden on Ethereum programmers.
- More user-friendly alternatives. Whenever someone describes a cryptocurrency as an "Ethereum killer" they're probably referring to a project like Cardano or EOS that brings more user friendliness to Ethereum, or allows smart contracts to be programmed in an existing language that developers are more familiar with.
But despite these issues, Ethereum's price and market cap are obviously still very much alive and well.
- Bitcoin’s price continues to rise despite transaction fees hitting an all-time high
- Ethereum price rallies once again after recent flash crash
- Can Dogecoin’s price continue to soar despite a marketwide correction?
- Bitcoin’s price plunges 10% before rebounding – market witnesses massive liquidations
- Ethereum price surges to all time high before Berlin hardfork
Disclosure: At the time of writing the author holds ETH, IOTA, ICX, VEN, XLM, NANO, SALT, BTC