Decentralized Liquidity Is the Backbone of DeFi and Flash loans are exciting and powerful which can provide instant and sizable liquidity to anyone in the world, at any point in time, they have increasingly been used to fund attacks on DeFi protocols. Decentralized finance (DeFi) ecosystem has recently emerged with new liquidity mechanisms. Cryptocurrency and by extension DeFi is a highly experimental field. When so much money is at stake, it’s only a matter of time before vulnerabilities are discovered.
In this article we briefly explained the attacks occurred in Flash loan and prevention of it.
How to Prevent Flash Loan Attacks
Use Decentralized Oracles for Price Data
Force Critical Transactions to Go Through Two Blocks
Dragonfly Research has proposed forcing flash loans to go through two blocks instead of one. However, this isn’t a complete solution either since if it is designed incorrectly, the exploiter could simply flash loan attack both blocks. Furthermore, this can drastically affect the UI of DeFi protocols since transactions will no longer be synchronous.
Avoid Front Running Attacks
The best way to prevent against these is with a commit-reveal scheme. This is when a project sends a transaction that goes through and is accepted, but is hashed or encrypted. Only after the transaction has concluded that they send a “reveal” phrase that decodes the transaction. This method prevents both miners and users from frontrunning transactions as they cannot determine the contents of the transaction. Transactional value however, cannot be commit-revealed, making this far less effective in the defi world. This is another very difficult type of attack to prevent.
Using Flash Loan Attack Detection Tools
Open Zeppelin has recently launched a program called Open Zeppelin Defender that enables project managers to detect smart contract exploits and other unusual activity, which would allow them to respond swiftly and neutralize attacks. According to their blog post, this tool has already been integrated by the Synthetix, Yearn and Opyn teams.
Conclusion
Ultimately, the result of a flash loan attack is out of your hands. By limiting concentrations of singular protocols or altcoins, you can hedge against these attacks to a degree. However, this is the inherent risk involved in cryptocurrency. Balancing your portfolio with more established coins is also a smart move.
As cryptocurrencies shift protocols away from proof-of-work, additional questions will be raised about the security of alternatives.