Nine months ago, in a Denver convention center, a booth sat empty.
Littered with token stickers, the table was supposed to hold the physical representatives of decentralized finance (DeFi) protocol bZx. It remained empty, however, as the team struggled to make sense of the digital forces twisting their young project.
Flash loans remain the common thread through all those recent attacks. These DeFi-native tools enable a savvy investor to take out unbacked loans and amass leverage behind a position. For example, Monday’s Origin Protocol attacker pulled a 70,000 ETH loan from decentralized derivatives platform dYdX. It enabled the attacker to up the amount of loot sucked out of the project.
Yet, while they may be the string connecting these exploits, flash loans are not the cause in and of themselves, industry leaders told CoinDesk.
Oracle manipulation and flash loans
It may not even be fair to characterize the recent DeFi exploits as “flash loan attacks,” Chainlink co-founder Sergery Nazarov told CoinDesk in an email.
Nazarov said flash loans at their core are just lump sums of capital thrown at success trade positions. The real issue lies with poorly constructed DeFi projects.
“While many are trying to frame this trend as the result of flash loans, most of these exploits could have been committed by any well-capitalized actor. All a flash loan does is temporarily make anyone a well-capitalized actor,” Nazarov said.
DeFi’s projects are smart contracts deployed to the Ethereum blockchain. They require outside information, namely pricing data, to execute actions baked into each contract.
That pricing information is liable to distortions simply because of how the Ethereum blockchain packages transactions – that is, every 15 seconds. Prices can move every which way in 15 seconds, which forces smart contracts to act on stale data.
Moreover, many DeFi applications rely on in-house pricing oracles created by token reserves, non-decentralized pricing feeds or other ad hoc solutions. For example, Harvest Finance leaned on another DeFi project, Curve Finance, to price its token pools.
In cases like Harvest Finance, interoperability became a negative dependency. A flash loan worth $50 million deviated asset prices temporarily away from the market value, creating an arbitrage opportunity. A project that had a more robust pricing system wouldn’t have fallen prey to the exploit, the theory goes.
Are audits enough?
Another point developers are coming to grips with is that code audits alone don’t make a DeFi project safe.
Speaking with CoinDesk via Whatsapp, Quantstamp CEO Richard Ma said developers need to understand markets themselves, perhaps more so than the code they deploy to the Ethereum blockchain. Quantstamp has audited or consulted on multiple top DeFi projects such as Curve Finance, MakerDAO and SushiSwap, among others.
“Understanding the products and the business logic is much more time-consuming and important than a straight-up code review,” Ma said.
Indeed, Akropolis was audited twice by two separate firms, but still suffered a re-entrancy attack.
This sort of attack occurs when a smart contract’s backdoor is left ajar. The contract’s state – which records how many tokens the contract has, among other things – fails to update quickly enough when tokens are removed, allowing the attacker to move more coins out than okay. It’s not dissimilar to a lazy bank teller continuing to fork over funds from an overdrawn account.
Combining audit redundancies with insurance is a step at least one major cryptocurrency investment firm is now urging.
“We are recommending our portfolio companies to get multiple audits from more than one provider," Paul Veradittakit, partner at venture capital firm Pantera, said in an email. "We also think that projects and investors may want to buy insurance to protect themselves."
It’s also notable that none of the top DeFi projects have suffered oracle attacks spurred by flash loans, dYdX founder Antonio Juliano told CoinDesk in a message. Many flash loans used in attacks have originated on his platform, which offers the product without a fee.
He said that “there’s a big divide between the well-engineered projects and others;” a divide being fleshed out in real time by flash loans.
“In the same way you wouldn’t blame Ethereum for an implementation detail of the chain being used for an attack, the way flash loans are being used in exploits is the fault of developers building insecure applications, not the flash loans themselves,” Juliano said.
The leader in news and information on cryptocurrency, digital assets and the future of money, CoinDesk is a media outlet that strives for the highest journalistic standards and abides by a strict set of editorial policies. CoinDesk is an independent operating subsidiary of Digital Currency Group, which invests in cryptocurrencies and blockchain startups.