Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

A “Hat Trick” of DeFi Hacks Underscores the Importance of DeFi Security- 981

HalbornPosted 3 Years Ago
  • Three major hacks took place in a single day, resulting in millions of dollars being stolen.
  • The first vulnerability was in Rabby Swap. The contracts router function had the function functionCallWithValue with arbitrary parameters passed to it. This allowed for a user to pass in an arbitrary set of arguments and an arbitrary function as the router.
  • Using this vulnerability, they were able to call swap from the context of the router contract. Using this, previous approvals from other users could be abused to steal all of the money from their wallets. Apparently an audit took place but completely missed this issue.
  • The Template DAO hack was really simple. The function migrateStake had no access controls. Additionally, the previous function did not verify the source address or stake value of the old address. As a result, an attacker could call the contract with a fake old address and stake value, mint their tokens and drain the entire contract.
  • Finally, the Mango Market was hacked, which is just a trading platform. A flash loan was used to inflate the price oracle of the Mango token from 30 cents to 91 cents.
  • Since this increased the value of the attackers collateral, they could borrow even more funds from the protocol. Why is this increase in price so bad? By taking out a massive loan, with the inflated collateral, they could drop the price of the token bad down, they just abandoned the collateral and took the loan
  • For Mango Markets, the crazy part is that the hacker came out and said they would keep some of the funds as a bug bounty payment but he was using the protocol as expected. Even though this is obviously not true, how do you define expected vs. unexpected functionality with a finance market? The guy kept $45 million and the person is public knowledge.
  • Overall, three interesting hacks that led to $100 million being stolen. Super interesting!