$1 100 000 USD

JULY 2021

GLOBAL

DEFI PLAZA

DESCRIPTION OF EVENTS

"DeFi Plaza is a low cost exchange which offers best in class swapping costs for 120 pairs of the most traded DeFi tokens. A highly integrated design enables the lowest gas costs in the industry combined with low swapping fees of 0.1% for all 120 trading pairs. Fundamentally improved capital efficiency enables high trading volume per unit of liquidity resulting in a competitive offering to liquidity providers despite the low transaction fees."

 

"Governance decisions on which tokens to list, which exchanges to launch, which fee structures to apply and so forth are made by the DAO. The token governing the DAO voting rights is distributed via a liquidity rewards program running over one year on the main exchange. The distribution follows a quadratic function to favor early adopters who take on more risk."

 

"Since the meteoric rise of DeFi last year we have many options to exchange tokens using several decentralised exchanges built straight onto the block chain. They work great and have been a massive boon to the fledgling DeFi industry. UniSwap could even be called the spider in the DeFi web. All is not well however, and the issue I wish to address here is that DeFi is basically becoming too expensive to use for the general public. The native Ethereum token ETH has risen tremendously in price and on top of that the gas price on the network has risen due to congestion. Moreover, the fees that most DEXs charge is in the order of 0.3% of the trade value which is just quite expensive. These high trading costs have become such a problem it’s starting to damage the growth of the DeFi ecosystem. Thus, I believe there is space in the market for an Ethereum based exchange that competes on cost. That is to say, an exchange which allows users to swap tokens at lower gas fees and lower exchange fees. To put it simply: I believe the DeFi community wants and deserves a lean, mean swapping machine."

 

"So why don’t we just build a DEX that has low fees? Sure, the customers who do swaps and the arbitrageurs would welcome such an exchange, but how can we convince the liquidity providers (LPs) to commit their capital to provide liquidity if the fees (which provide their revenue) are drastically reduced? There is only one answer that makes sense: by having the exchange turn over significantly higher volume per unit of liquidity. This is the objective of DeFi Plaza; To provide an exchange which offers such favourable conditions to its user base that it will generate more than enough volume to compensate the LPs for the lower level of fees."

 

"DeFi Plaza is our very best effort to build a low cost exchange. However, with Solidity there are many pitfalls and it is easy to make a mistake. It is entirely possible that there are mistakes in the code which could require migration to a new version or in more severe cases cause partial or complete loss of funds. The code has not been audited. The use of DeFi Plaza is at your own risk."

 

"DeFi Plaza, nor its team members, assume any responsibility for errors or omissions in the contents of the application. In no event shall DeFi Plaza or its team members be liable for any special, direct, indirect, consequential, or incidental damages or any damages whatsoever, whether in an action of contract, negligence or other tort, arising out of or in connection with the use of the smart contracts or the contents of the website."

 

"On July 11, 2021 DeFi Plaza suffered from an integer overflow vulnerability which was exploited to steal $1.1M worth of liquidity." "At block number 12804721 (Sun Jul-11-2021 07:41:36), a withdrawal transaction is included that extracts the entire balance of eXRD from the exchange." "This missing token put the exchange in a bad state, with a severe imbalance which could be exploited through further arbitrage. Twenty-two minutes later (Jul-11-2021 08:03:16) the first imbalanced swap transaction happens, followed by many more (as well as 14 more explicit abuses of the withdrawal bug) until all liquidity is removed from the DEX."

 

"Defi Plaza was subject of a code exploit. We are suspending operations until further notice. Remaining liquidity can still be withdrawn. Further announcements to follow."

 

"The removeLiquidity function suffers an uncaught numeric overflow at line 305 if the input parameter LPamount is equal to zero. The zero input edge case was missed in testing. F_ is assumed to be a 0.64 bit number but for input zero it becomes a 1.64 bit number causing the overflow."

 

"The initial zero-liquidity withdrawal was made by accident. This was not an attack. The first person to actually exploit the imbalanced DEX was a community member who had a stake of $1295 in the exchange. They didn’t flag the issue with the team, extracted $450k and then shared the issue with other exploiters. Another 13 wallets from outside of the community joined in shortly after to collectively extract another $719k. In the meantime the community had detected something was wrong and scrambled to recover as much liquidity as possible, collectively recovering $247k. To date (7/18/21) $605k in exploited funds have been returned to the community voluntarily. A total of $646k remains in the hands of exploit profiteers."

 

"An audit was scheduled, which would have certainly uncovered this item. Unfortunately, this issue manifested in reality before the audit could flag it. In a sense, we still got lucky. The trigger was accidental. Most funds were taken by opportunists, which gives a much better chance of identifying the actors and recovering the funds. Had a sophisticated attacker found this leak, they could’ve taken all DEX liquidity before we could’ve done anything at all. An emergency exchange lock was included which stops liquidity add/swaps, but not withdrawals. This is on purpose since any contract which can freeze user funds is not truly trustless. But in this case, the lock failed to fully protect funds as there was a weakness in the withdraw function itself."

 

"“We test in prod” sounds fun and exciting until it kicks you in the nuts. I will never launch code aimed at handling significant funds without an audit again. The exchange lock could only be triggered from a hardware wallet, which introduced a 25 min delay to activate it as by pure coincidence I was away from home at the time the issue was flagged. In v2 we’ll include mobile wallets for protective locking such that it can be locked from anywhere, by multiple people. Having an automatic exchange lock based on certain trigger conditions also another thing I’m considering doing, to be discussed with the community. The risk of periodic ‘nuisance locking’ should be well balanced with the risk of liquidity drain."

 

"The key USP for DefiPlaza is efficiency. A significant part of that is gas efficiency. However, maybe I’ve gone too far with that in v1. Overflow checks could be put in place for all computations which would have prevented this edge case from causing any damage even if uncaught during testing. I’ll be engaging the community shortly to get your input on several key design elements for v2 as well as gather general suggestions from the community. Overall, the community has shown great resilience in dealing with this challenge. It’s been a very painful incident for all of us, but I believe we’re growing stronger as a result of having to go through this. You have my deepest gratitude for your continued support."

 

The Twitter and webite were updated after the breach. "I'm gutted. Someone found an exploit in the code and drained a lot of liquidity from the exchange." "Defi Plaza was subject of a code exploit. We are suspending operations until further notice. Remaining liquidity can still be withdrawn. Further announcements to follow." There have been no further announcements.

Defi Plaza was a complex exchange platform focused on optimization to reduce gas fees. To facilitate faster exchanges, all the funds were stored in a smart contract hot wallet.

 

The hot wallet was breached due to an integer overflow which was possible when a balance was 0. This was used multiple times to extract funds.

 

The team has not made an announcement in over a month, but there is some indication that an announcement is forthcoming.

HOW COULD THIS HAVE BEEN PREVENTED?

Placing the majority of funds in a cold multi-sig wallet would have prevented their theft. Funds could be removed from cold storage as needed for additional liquidity.

 

The smart contract hot wallet risk can be reduced by a security audit, and white hat hackers may assist in securing the protocol with a bug bounty program, however it is not possible to prove that a complex smart contract is completely secure.

 

Check Our Framework For Safe Secure Exchange Platforms

Sources And Further Reading

 For questions or enquiries, email info@quadrigainitiative.com.

Get Social

  • email
  • reddit
  • telegram
  • Twitter

© 2021 Quadriga Initiative. Your use of this site/service accepts the Terms of Use and Privacy Policy. This site is not associated with Ernst & Young, Miller Thompson, or the Official Committee of Affected Users. Hosted in Canada by HosterBox.