DcentraLab Diligence Analysis: Rubic DEX Aggregator Hack

Dcentralab Diligence Analysis: Rubic DEX Aggregator Hack

On December 25th, the cross-chain DEX aggregator protocol Rubic announced on Twitter that it suffered an exploit. The hacker managed to capitalize on the vulnerability via a USDC token that was whitelisted/marked as a router. Inside Rubic’s proxy system, all routers are enabled for direct interactions with the proxies.

The hacker used the ability to make custom calls to the whitelisted contracts or routers to exploit user approvals made on Rubic’s proxy contracts. As such, the hacker could withdraw large amounts of USDC from users, which was later swapped to WETH. The WETH was unwrapped to ETH and sent to the (now-illegal) Tornado Cash contract.

This analysis was issued by Dcentralab Diligence, a security consultant and smart contract auditor in the Web3 space.

In-depth Report on the Rubic DEX Hack:


Exploiter address: 0x001b91c794dfeecf00124d3f9525dd32870b6ee9

Exploiter contract: 0x253dD81d642220267ccAc1d8202c0B96a92b299e

Bigger exploit transaction: https://etherscan.io/tx/0x9a97d85642f956ad7a6b852cf7bed6f9669e2c2815f3279855acf7f1328e7d46

Smaller exploit transaction: https://etherscan.io/tx/0x6551b933b984342fd353d4b522aee7db500900e208dc1337b0c1f17647e36e56


Exploiter contract has one function used for an attack that has been iterated over multiple times, in which we may see the following actions:

  • Check the USDC balance of a user.
  • Check USDC allowance from the user to Rubic’s proxy contract.
  • Perform routerCallNative() — which is pretty much a non-sanitized custom call (in the case of whitelisted routers).
  • This custom call interacts with the transferFrom() function over Rubic’s allowance and transfers funds from users to the exploiter contract.

This means that due to Rubic’s routerCallNative() function’s non-sanitized input, the exploiter gets to take advantage of USDC approved by users over Rubic’s proxy contracts and withdraw tokens directly from users to the exploiter contract.

In the meantime, when done with the first, Rubic’s proxy exploiter contract starts attacking the second one.

Rubic’s proxy addresses:



The second, more minor attack does the same.

In the end, the exploiter trades USDC for WETH and withdraws ETH from WETH, and washes funds with Tornado Cash.

Platforms should rarely, if ever, give infinite approvals to any contract.

Other Notable DEX Hacks

While hacks are somewhat familiar in cryptocurrencies, DEX hacks are relatively rare. There have been a handful of notable DEX hacks in the past. Due to their decentralized nature, most DEX hacks were less successful than attacks on centralized exchanges or DeFi (decentralized finance) protocols.

In 2017, the EtherDelta DEX suffered a hack that resulted in the theft of 308 ETH (valued at over $1 million at the time). The hack occurred due to a vulnerability in EtherDelta’s domain name system (DNS) server. The vulnerability allowed the attackers to redirect users to a fake version of the exchange.

IDEX suffered a hack in February 2018, in which the attackers stole around 215,000 ETH (worth around $46 million at the time). The hack occurred due to a vulnerability in a smart contract that enabled the attackers to drain funds from IDEX’s liquidity pool.

Later that year, in July 2018, Bancor DEX suffered a security breach. The breach resulted in the theft of approximately 25,000 ETH (valued at over $12 million at the time) and several other cryptocurrencies. The hack also occurred due to a vulnerability in a smart contract that enabled the attackers to drain funds from Bancor’s liquidity pool.

How to Avoid DEX Hacks?

As we’ve seen with other popular DEX hacks, the root of the attack tends to be some code vulnerability. Redirect attacks, as seen with EtherDelta, are typically simple to avoid with modern tools such as verification bars, which verify the URL address. Other DEX hacks are rooted in human errors in the smart contract.

Multiple independent security consultations and smart contract audits from different sources are highly recommended. A single auditor may miss a bug or vulnerability, having multiple auditors minimizes risk.

About Dcentralab Diligence

Dcentralab Diligence is a blockchain-based security firm proudly based in Belgrade and Tel Aviv. We provide comprehensive smart contract audits and security consultations for the web3 industry. The team behind Dcentralab Diligence has years of experience in blockchain development and cyber security.

Follow us:

Twitter | Website | LinkedIn