Dexible DEX Aggregator SelfSwap Exploit

From Quadriga Initiative Cryptocurrency Hacks, Scams, and Frauds Repository
Jump to navigation Jump to search

Notice: This page is a freshly imported case study from the original repository. The original content was in a different format, and may not have relevant information for all sections. Please help restructure the content by moving information from the 'About' section to other sections, and add any missing information or sources you can find. If you are new here, please read General Tutorial on Wikis or Anatomy of a Case Study for help getting started.

Dexible DEX Aggregator

Dexible is a decentralized exchange (DEX) aggregator and execution management system (EMS) that optimizes full trade lifecycle support in DeFi. The platform offers pro traders and portfolio managers core atomic functionality out-of-the-box that vastly improves overall performance. With Dexible, traders can enter and exit large positions in DeFi without fearing market manipulation or MEV. However, Dexible suffered a hack on February 17th, 2022, losing a total of $2 million on Ethereum and Arbitrum. Although contracts were quickly paused, an official announcement came more than nine hours after the hack, and over five hours after Peckshield raised the alarm. Approximately $1.5 million was lost on Ethereum, and a further $450k was lost on Arbitrum, which was bridged to BSC before also being washed via Tornado Cash. 17 traders were affected in total, and the exploiter transferred stolen funds of ~930.6 $ETH ($1.53M) into Tornado Cash. Dexible has not undergone a formal audit, and one was not performed on the latest set of contracts.

About Dexible DEX

Dexible is a decentralized exchange (DEX) aggregator and execution management system (EMS) for professional traders and portfolio managers across six major EVM chains and 60+ DEXes. The platform offers atomic functionality that improves overall performance, and minimizes price impact by splitting large orders into market-impact-minimizing rounds. Dexible offers full trade lifecycle support with detailed pre-trade and post-trade analysis, smart order routing, and post-order analytics. The platform scans all available sources of liquidity on a particular blockchain to optimize outcomes for swaps and checks DEXes for their current pricing and available liquidity. Traders can enter and exit large positions in DeFi without fearing market manipulation or MEV[1][2].

"Dexible is a trading engine for pro traders to maximize profitability. Fully noncustodial set-and-forget orders on 6 major EVM chains across 60+ dexes."

"Dexible is a decentralized exchange (dex) aggregator and execution management system (EMS) optimizing full trade life-cycle support in DeFi. The platform offers pro traders and portfolio managers core atomic functionality out-of-the-box that vastly improves overall performance." "Dexible is more than a DEX aggregator. It's an Algo Execution Suite for maximizing profitability designed for the pros."

"Minimizes Price-Impact: Splits large orders into market impact minimizing rounds. Full Trade Lifecycle Support: Detailed pre-trade and post-trade analysis. Post-Order Analytics: View and export detailed trade history reports for reporting and analysis. Smart Order Routing: Taps into 60+ liquidity sources for optimal price discovery."

"Think of Dexible as a highly flexible dex aggregator with an execution layer modeled to resemble OEMS in CeFi & Traditional Finance. The platform scans all the available sources of liquidity on a particular blockchain to optimize outcomes for swaps. Dexible also checks dexes for their current pricing and available liquidity, among other on and off-chain conditions. When market conditions match the trader's criteria, orders get submitted through Dexible's Settlement Smart Contract, then calling out to one or more dex contracts to execute the actual trades."

"With Dexible, traders can enter and exit large positions in DeFi without fearing market manipulation or MEV. With radical financial innovation and growth comes radical investment returns and opportunity, leading to more institutional capital flooding into the ecosystem."

The Reality

There was an unfortunate vulnerability the "selfSwap" function of the Dexible smart contract, which allows users to define their own routing, but did not check if the router address was a DEX. While the intent was to allow users to specify a router, because there was no filter it would allow an attacker to specify a malicious transaction routing contract.

[3].

The issue was obvious in hindsight, and would have likely been caught with a proper audit of the smart contract code. However, Dexible did not perform a formal audit on this set of contracts. Instead, they report that several community members and engineers reviewed the code and did not find the vulnerability.

What Happened

The SelfSwap exploit was exploited.

Key Event Timeline - Dexible DEX Aggregator SelfSwap Exploit
Date Event Description
February 16th, 2023 7:26:00 AM MST Dexible Posts about Dexible V2 The Dexible app advertises "fully on chain" and "more complex logic" in a video on Twitter[4]. "Dexible will revolutionize on-chain capital deployment and shake up how aggregators work. Our team will combine 2 years of user testing with a new model for token incentives with $DXBL." They have a goal to "bring all that CeFi liquidity and volume into DeFi"[5].
February 16th, 2023 8:23:22 PM MST FixedFloat Exchange Completed The exploiter completes an exchange with the FixedFloat decentralized swap service, and receives 0.423796 BNB into their wallet[6].
February 16th, 2023 8:39:47 PM MST Unwrapping Wrapped Ethereum The exploiter unwraps their wrapped Ethereum tokens (stored on the BNB blockchain)[7].
February 16th, 2023 9:16:35 PM MST First Exploit of Wrapped Ethereum The very first exploit transaction for 11.34634284419918137 Wrapped Ethereum[8].
February 16th, 2023 9:20:35 PM MST Exploit Transaction The second exploit transactions for 17,960,937.5 TrueFI tokens[9]. This transaction is the most widely referenced attack transaction example[10][11].
February 16th, 2023 10:00:00 PM MST Smart Contract Paused According to a later Tweet by Dexible App, the smart contract was paused at 5 AM UTC[12].
February 17th, 2023 12:51:35 AM MST Attacker Starts Cashing Out ETH To TornadoCash The attacker starts to move the ETH funds from their wallet and deposit them into TornadoCash[13].
February 17th, 2023 12:53:34 AM MST Attacker Starts Cashing Out BNB To TornadoCash The attacker starts to move the BNB funds from their wallet into TornadoCash[14].
February 17th, 2023 1:03:23 AM MST Attacker Done ETH TornadoCash Cash Out Process The last ETH transaction from the attacker into TornadoCash is completed[15].
February 17th, 2023 1:05:00 AM MST Peckshield Twitter Report Peckshield reports that Dexible "may need to ask users to revoke allowance" and provides one of the exploit transactions for analysis[10].
February 17th, 2023 1:08:00 AM MST PechShield Reports Contract Paused PeckShield reports on Twitter that the protocol should now be paused[16].
February 17th, 2023 1:10:00 AM MST PeckShield Reports TornadoCash ETH Movement PeckShield reports on the TornadoCash movement of Ethereum (which happened before their first Tweet)[17].
February 17th, 2023 1:39:39 AM MST Attacker Done BNB TornadoCash Cash Out Process The final BNB transaction from the exploiter into TornadoCash is completed[18].
February 17th, 2023 2:08:00 AM MST PeckShield Reports TornadoCash BNB Movement PeckShield reports on the TornadoCash movement of BNB (which happened before their first Tweet)[17].
February 17th, 2023 6:35:00 AM MST Dexible App Announces The Hack Publicly Dexible makes public Tweet to announce the hack on Twitter[19].
February 17th, 2023 6:47:00 AM MST Dexible App Reports Contract Paused According to Dexible App, the smart contract was paused at 5:00 AM UTC[12].
February 17th, 2023 7:42:00 AM MST Dexible App Reports on Losses Dexible App posts a Tweet reporting on the total amount lost in the protocol[20].
February 17th, 2023 2:10:00 PM MST CoinTelegraph Article Published CoinTelegraph publishes an article on the Dexible vulnerability. The article reports that there is a pop-up on the Dexible website. "he selfSwap function allowed users to provide the address of a router and calldata associated with it to make a swap of one token for another. However, there was no list of preapproved routers written into the code. So, the attacker used this function to route a transaction from Dexible to each token contract, moving users’ tokens from their wallets into the attacker’s own smart contract. Because these malicious transactions were coming from Dexible, which users had already authorized to spend their tokens, the token contracts did not block the transactions."[21]
February 21st, 2023 6:56:00 AM MST RektHQ Report on Situation RektHQ posts about the exploit[11]. Decentralized exchange aggregator, Dexible, lost $2m on Ethereum and Arbitrum after the contracts were exploited, but an official announcement was made over five hours after the alarm was raised. Dexible's tech lead discovered the attack early on, but the Twitter channel was unable to respond in time. When they did respond, Dexible's message came across as tone-deaf and indifferent. Dexible's recently introduced v2 contracts allows users to define their own routing via the selfSwap function, but it doesn't check whether the router address is a DEX by using an on-chain allowlist. The Dexible team released unaudited code based on the experience of their team[3].
February 21st, 2023 12:40:00 PM MST Another DexibleApp Update DexibleApp posts another update to their community[22].
March 22nd, 2023 3:56:17 AM MDT Hacken Smart Contract Guide Includes Exploit Hacken updates their guide on "Smart Contract Vulnerabilities & How to Prevent Them" to also include a section with an "[e]xample of the Dexible exploit"[23]. As they report, "[d]evelopers must implement the necessary security mechanisms to guarantee that external calls are made only to trusted and intended addresses."

Technical Details

The hacker exploited this vulnerability by calling a token contract with a request to "transferFrom" any account that had spend approval on the Dexible contract. The core engineer who created the contracts did not see the vulnerability initially, but after reviewing the hacker's transaction, he immediately understood how it was executed. Dexible has published a post-mortem report explaining the issue

CoinTelegraph Description

CoinTelegraph published a description of the exploit[21].

The selfSwap function allowed users to provide the address of a router and calldata associated with it to make a swap of one token for another. However, there was no list of preapproved routers written into the code. So, the attacker used this function to route a transaction from Dexible to each token contract, moving users’ tokens from their wallets into the attacker’s own smart contract. Because these malicious transactions were coming from Dexible, which users had already authorized to spend their tokens, the token contracts did not block the transactions.

Total Amount Lost

Attack transactions and amounts lost:

TX#
1[8]
2[9]
3


The total amount lost has been estimated at $1,530,000 USD.

Dexible reported the affected accounts on Twitter[20].

Update: 17 traders were affected total, 4 on Mainnet, 13 on Arbitrum.

Out of 36 on Arbitrum, only 13 were exploited.

Out of 14 unique on Ethereum, 4 were exploited.

A few big whales were exploited accounted for ~85%

According to a statement from Dexible, after analysis "knew “$2,047,635.17 was exploited from 17 trader addresses. 4 on mainnet, 13 on arbitrum.”[21]

How much was lost and how was it calculated? If there are conflicting reports, which are accurate and where does the discrepancy lie?

Immediate Reactions

Tweet By PeckShield

Blockchain analytics company PeckShield was one of the first to notice and report on the issue[10]. They reported on one of the exploit transactions[9].

Hi @DexibleApp, you may need to ask users to revoke allowance! (The loss is already >$1.5M). Here is one hack [transaction]



"The decentralised exchange aggregator, Dexible lost a total of $2M on Friday, on Ethereum and Arbitrum.

Although contracts were quickly paused, an official announcement came more than 9 hours after the hack, and over five hours after Peckshield raised the alarm.

The thread states that their tech lead “discovered the attack early on” but that the “Twitter channel was not able to respond in time”, despite various promotional tweets being published in the intervening hours."

"Relatively few addresses were affected, with the majority of losses reportedly coming from an address belonging to BlockTower Capital which lost 18M TRU tokens, valued at ~$1.4M at the time.

In total, approximately $1.5M was lost on Ethereum, and sent to Tornado Cash. A further $450k was lost on Arbitrum, which was bridged to BSC before also being washed via Tornado Cash."

"Dear Dexible community, we regret to inform you that in the early hours of February 17th, a hacker exploited a vulnerability in our newest smart contract. This allowed the hacker to steal funds from any wallet that had an unspent spend approval on the contract."

"We are taking this very seriously, and our team immediately paused all Dexible contracts on all chains upon detecting the issue. Our users were affected, but the exploit is over."

"We are grateful to our tech lead, who discovered the attack early on. Unfortunately, our Twitter channel was not able to respond in time. Statements were made on Discord and Telegram."

"Several team members were up overnight to contain the exploit.

As we write this statement, the team is in a war room to develop the next steps, create a triage plan, and gather the data."

"The Exploiter has transferred stolen funds ~930.6 $ETH (~1.53M) into Tornado Cash"

Ultimate Outcome

What was the end result? Was any investigation done? Were any individuals prosecuted? Was there a lawsuit? Was any tracing done?

[22]

Total Amount Recovered

There do not appear to have been any funds recovered in this case so far[22].

What funds were recovered? What funds were reimbursed for those affected users?

Ongoing Developments

The DexibleApp team appears to be looking for a backer to assist in a recovery[22].

Individual Prevention Policies

Avoid the use of smart contracts unless necessary. Minimize the level of exposure by removing or withdrawing assets whenever possible. Aim to choose smart contracts which have obtained third party security audits, preferably having been audited by at least three separate reputable firms. Pay attention to the audit reports, which smart contracts are covered, and whether the smart contract has been upgraded or modified since the report. Ensure that any administrative functions with the ability to remove funds from the smart contract are under the authority of a multi-signature wallet which is controlled by at least three separate and reputable entities.

For the full list of how to protect your funds as an individual, check our Prevention Policies for Individuals guide.

Platform Prevention Policies

All aspects of any platform should undergo a regular validation/inspection by experts. This validation should include a security audit of any smart contracts, reporting any risks to the backing (of any customer assets, ensuring treasuries or minting functions are properly secured under the control of a multi-signature wallet, and finding any inadequacies in the level of training or integrity of the team. The recommended interval is twice prior to launch or significant system upgrade, once after 3 months, and every 6 months thereafter. It is recommended that the third party performing the inspection not be repeated within a 14 month period.

For the full list of how to protect your funds as a financial service, check our Prevention Policies for Platforms guide.

Regulatory Prevention Policies

All platforms should undergo published security and risk assessments by independent third parties. Two assessments are required at founding or major upgrade, one after 3 months, and one every 6 months thereafter. The third parties must not repeat within the past 14 months. A risk assessment needs to include what assets back customer deposits and the risk of default from any third parties being lent to. The security assessment must include ensuring a proper multi-signature wallet, and that all signatories are properly trained. Assessments must be performed on social media, databases, and DNS security.

For the full list of regulatory policies that can prevent loss, check our Prevention Policies for Regulators guide.

References

  1. Introducing Dexible - Algo Trading Dex Aggregator for DeFi Portfolio Managers - YouTube (May 3, 2023)
  2. Start Here - Dexible (May 3, 2023)
  3. 3.0 3.1 Rekt - Dexible - REKT (May 3, 2023)
  4. Dexible - Introducing Dexible v2.0, the slumbering giant of #DeFi wakes. Dexible will revolutionize on-chain capital deployment and shake up how aggregators work." - Twitter (May 19, 2023)
  5. DexibleApp - "What would bring all that CeFi liquidity and volume into DeFi?" - Twitter (May 19, 2023)
  6. Attacker Receives 0.423796 BNB From FixedFloat - BscScan (May 5, 2023)
  7. https://etherscan.io/tx/0xe44dcea98ad8019bae5b6b83e266ff873c3aa7cdca9a60a3239a7b19a9237636 (May 5, 2023)
  8. 8.0 8.1 Exploit Transaction For 11.34634284419918137 Wrapped Ethereum - Etherscan (May 5, 2023)
  9. 9.0 9.1 9.2 Transaction Exploiting Dexible DEX For 17,960,937.5 TrueFi - Etherscan (May 3, 2023)
  10. 10.0 10.1 10.2 peckshield - "Hi @DexibleApp, you may need to ask users to revoke allowance! (The loss is already >$1.5M). Here is one hack [transaction]" - Twitter (May 3, 2023)
  11. 11.0 11.1 RektHQ - "@DexibleApp lost a total of $2M on Friday, on Ethereum and Arbitrum." - Twitter (May 3, 2023)
  12. 12.0 12.1 DexibleApp - "Protocol was paused at 5:00 AM UTC this morning." - Twitter (May 3, 2023)
  13. Exploiter Depositing First 100 ETH Into TornadoCash - EtherScan (May 5, 2023)
  14. Attacker Transfers First 100 BNB Into TornadoCash - BscScan (May 5, 2023)
  15. Last Transaction For 0.1 ETH into TornadoCash - EtherScan (May 5, 2023)
  16. PeckShield - "The protocol should be now paused." - Twitter (May 3, 2023)
  17. 17.0 17.1 PeckShield Alert - "The Exploiter has transferred stolen funds ~930.6 $ETH (~1.53M) into Tornado Cash" - Twitter (May 5, 2023)
  18. Attacker Transfers Final 0.1 BNB Into TornadoCash - BscScan (May 5, 2023)
  19. DexibleApp - "Dear Dexible community, we regret to inform you that in the early hours of February 17th, a hacker exploited a vulnerability in our newest smart contract. This allowed the hacker to steal funds from any wallet that had an unspent spend approval on the contract." - Twitter (May 3, 2023)
  20. 20.0 20.1 DexibleApp - "Update: 17 traders were affected total, 4 on Mainnet, 13 on Arbitrum." - Twitter (May 3, 2023)
  21. 21.0 21.1 21.2 Dexible aggregator hacked for $2M via ‘selfSwap’ function - CoinTelegraph (May 19, 2023)
  22. 22.0 22.1 22.2 22.3 DexibleApp - "We want to express our sincerest apologies for the events that occurred last Friday. We understand that the exploit caused immense frustration, inconvenience, and loss to our users." - Twitter (May 19, 2023)
  23. Smart Contract Vulnerabilities & How to Prevent Them - Hacken (May 19, 2023)