Update to Recent Vulnerability Report : Part 2

On Sunday, July 31st, the Integral team was alerted to a potential vulnerability within the protocol. We released an update on this last week. There remains no reports of fund loss or harm to liquidity providers. While the team works on implementing a solution, we offer a more detailed description of the vulnerability and a simple way to conceptualize it.

Walkthrough

We present several protocol design facts and an illustrative example, to further illustrate a low-level description of the vulnerability, and how it poses potential risk.

Protocol Facts:
  • Fact 1 | Liquidity Imbalance & No Zero Case: Given the dynamic ratio, two-asset design of SIZE and FIVE pools, it is possible for nearly all the liquidity in the pool to be swapped to one side, while leaving very little on the other, but it is impossible for there to be zero liquidity on either side.
  • Fact 2 | Reversion: On trades, if at settlement time, the amount to be swapped out of the pool totals greater than or equal to the given amount of liquidity for that side of the pool, the protocol will revert the order and the trader’s input funds will return to the trader. This upholds Fact 1.
  • Fact 3 | Delayed Execution: The time delay (5, 30 min) of our system serves to protect LPs from arbitrage, as traders cannot predict/guarantee profit that far in the future at settlement time.

As described in our previous blog, a malicious trader, Alice, could take advantage by setting her order submission to purposefully cancel, unless the TWAP settlement price is in her favor. With this information, we can describe what a cancellation would look like.

Example Cancellation/Reversion:

For this example, consider the ETH<>USDC pool on SIZE. For simplicity, imagine the pair has 1 ETH and 0.1 USDC of liquidity available. Alice wants to swap her USDC into the pool for 1 ETH. The starting spot price of ETH is $1,000 USDC. Alice then submits the trade, and after 29 minutes the external oracle’s TWAP price turns out to be $995, with the market spot price at $990. In this case Alice knows that imminent SIZE settlement price will likely be around $995, compared to $990 for market spot. In this case, it’s in Alice’s interest to intentionally let this order cancel, as she would rather buy 1 ETH at $990 outside SIZE, rather than at $995 inside SIZE settlement.

This happens due to Fact #2 on Reversion (see Protocol Facts). At settlement time, Alice’s trade by default does not pass the pair liquidity check (since there would be exactly 0 ETH left if the trade were processed). Hence her funds will be returned to her.

Example Acceptance:

Alice can repeat this process, allowing her order to “cancel” and revert funds at settlement, until she sees an imminent favorable TWAP price, which she would want to accept. For example if ETH starts at $1,000 (as in the case above), but rather ETH-USDC external oracle TWAP rises to $1,005 after 29 minutes, and market spot price rises to $1,010; then it’s in Alice’s interest to now accept the settlement to buy 1 ETH at $1,005 inside SIZE, rather than let the SIZE swap fall into reversion and buy at $1,010 on the open spot market.

Acceptance: Alice sends a trivial amount of ETH to the underlying SIZE trading pair contract, so that the pool is now a trivial amount larger than the size of her 1 ETH order. If Alice is able to submit this action in time to the Ethereum network, Alice allows her original swap to settle successfully (rather than fade into reversion) as the liquidity check between the swap and the pair is now valid. Hence, in this case, the swap executes with a price in Alice’s favor.

Taking advantage of the pair liquidity requirement and letting the order cancel at last minute gives the trader a systemic arbitrage advantage, because they can with high certainty guarantee themselves profit because they pick only the trade settlements that favor them.

Until the dev team can come up with a solution for this loophole, currently SIZE and FIVE are in withdraw-only mode, as trading and deposits have been paused. We have also paused farming rewards until this issue is fixed. We appreciate the patience of the community through all of this.

Alice’s Game

Another way to think of this: the trader is playing a coinflip betting game of heads or tails, that costs $1 million worth of crypto to play.

The outcomes are naturally dependent on how market prices naturally move.

The sketch of the game outcomes are as follows for the trader’s POV:

Heads: I get between [$1 million, $1 million + Y] crypto (In my favor)

Tails: I get between [$1 million – maximum slippage, $1 million – Y] crypto (In the LPs’ favor)

Y here is a random variable: representing the distribution of difference between (a) the traders TWAP settlement cost and (b) open market spot settlement cost. (In our example walkthrough above Y would be 5 USDC).

The $1 million cost to play is similar to how a trader would commit their capital upfront on SIZE or FIVE.

Bob, the honest trader, playing this game, in the long run should make $0 profit from this game – parallel to the design of our system. In expectation he should buy/sell at a TWAP price that is reached fairly. The coinflips in this game correspond to the bull/bear — the market’s up/down, for which they happens at some unknowable probability p and (1-p) respectively.

Alice, however, by manipulating the amountOut for the order to fail the liquidity check (Protocol Fact #2) can now be dishonest about her commitments, as it gives her ability to cancel and redo all Tails conflips, so that she eventually is guaranteed to reach the profitable Heads scenario if she plays enough flips, losing minimal transaction costs to back-out and “cancel” each Tail outcome.

If Alice is able to repeat this, it forces the LPs to take the opposite side of advantaged trades and exposes them to potential IL over sustained time. Alice would have to continue to play this game by rotating thru swap directions after each success case (ETH → USDC → ETH → …).

There are a few factors that affect Alice’s ability to accomplish this in-the-wild:

First, the amount that Alice can earn in Y each time is heavily dependent on the market. For example in order for Alice to be profitable there needs to be enough volatility in the market swinging in her favor during settlement TWAP windows.

Second, the cheaper it is to transact on the network (a combination of Ethereum gas prices, Integral Fees, etc), the less costly it would be for Alice and the less volatility she would need.
Lastly, this exploit also requires a malicious trader to commit a significant amount of capital upfront. For example, if there is $1mm worth of USDC and $2mm worth of ETH in the pool, the required funds for this exploit would be $1mm worth of WETH and $2mm worth of USDC. It is also important to note that these funds cannot be sourced from a flash loan due to Integral’s asynchronous design.

In the abundance of caution, as mentioned above, both FIVE and SIZE remain in withdraw-only function to ensure all users funds remain safe while the team works to resolve this issue.

We believe in building products that provide value for traders and uphold fairness to LPs. The team has always taken bug bounty submission seriously and we are working very hard to come up with a correct solution to this vulnerability and improve the product with usability in mind. At the moment, all the developers are working towards a fix, and we will update you soon on the progress.

Tags

Integral Insights

Updates

May 9th, 2024

Integral Insights April ‘24

The combined average daily volume across Ethereum and Arbitrum is now at 8.8 million USD, a remarkable 22% increase compared to last month.

Product

April 25th, 2024

Introducing New Pool Analytics: Elevate Your Liquidity Provision Experience

A standout feature in our latest update is the "LP vs Hold" tab, which provides a comparative analysis of various holding strategies against Integral's LP positions.

Business

April 1st, 2024

Integral Insights March ‘24

We achieved several important milestones, including a new all-time-high daily volume for Arbitrum and the addition of four new pools on the Ethereum mainnet.

Updates

March 4th, 2024

Integral Insights February ‘24

Another milestone was reached on February 21st when Integral processed over $2 billion in cumulative volume.

Updates

February 1st, 2024

Integral Insights: January ‘24

Our initial launch with the ETH-RPL pool was a success, quickly elevating us to the second most utilized liquidity pool for this pair’s trading.

Research

January 17th, 2024

Is Liquidity Fragmentation Really That Bad?

When the token evolves into a store of value, it attracts outside traders, focusing on trading costs and slippage. This is when concentrated liquidity truly shines.

Updates

January 2nd, 2024

2023 Review

At Integral, our focus remains on developing a sustainable product for on-chain trading, serving both traders and liquidity providers.

Updates

December 12th, 2023

Integral Now Rewards Liquidity Providers with Trading Fees on Ethereum Mainnet

This enhancement enables liquidity providers (LPs) to directly receive a portion or all trading fees from Integral pools.

Updates

December 6th, 2023

Integral Insights: November ‘23

During November, Integral processed an average of approximately 6 million in volume with around 1.5 million in TVL. The system’s overall capital utilization sits at around 350%. It is the 10th most used DEX on Ethereum.

Updates

November 28th, 2023

Integral Now Rewards Liquidity Providers with Trading Fees

This enhancement enables liquidity providers (LPs) to directly receive a portion or all trading fees from Integral pools.

Research

November 15th, 2023

How Do University Blockchain Societies Gain So Many Votes?

Explore how university blockchain societies like FranklinDAO and Michigan Blockchain have grown into influential players in DAO governance, utilizing delegated votes and strategic partnerships to shape the future of DeFi protocols like Uniswap, Compound, and Aave.

Updates

November 6th, 2023

Integral Insight: October ‘23

We give an update for our work in October and highlight a profitable LP position from a long-term user.

Research

October 26th, 2023

Understanding the Stakes in Lido’s Growing Share of Staked ETH

The community is arguing whether a protocol may have too much control over the Ethereum network. Lido controls a large percentage of staked ETH, which could have consequences for the network’s future security and neutrality.

News

October 14th, 2023

Changes to Staking and Farming

Looking back at our progress so far and to the future with new updates to staking and farming.

Updates

October 11th, 2023

Integral Insight: September ‘23

We give an update for our work in September with utilization going up on higher volume for our new pools.

Research

October 11th, 2023

The Hottest Narratives of the Summer

What were the hottest narratives of the summer? Our DeFi research team delves into the growth of trading bots, RFV traders and more in this overview.

Research

October 2nd, 2023

Uniswap Governance: A Deep Dive

Governance is considered a critical component for the decentralization and community-driven development of DeFi protocols. We take a look at one of the largest goverance ecostystems in DeFi, Uniswap. In this blog post, we'll discuss the landscape of Uniswap's governance, pulling data from empirical research to dissect the system's delegates and proposals, revealing some interesting findings.

Research

September 19th, 2023

What is the DAI Savings Rate (DSR)?

Our research team takes a look at the DAI Savings Rate and its influence on various yield dynamics in DeFi.

Updates

September 15th, 2023

Integral Insight: August ‘23

We give an update for our work in August with cheaper gas fees and the launch of the Integral Relayer on Arbitrum!

Product

September 7th, 2023

Integral Relayer Launches on Arbitrum

We are excited to announce the launch of the Atomic Relayer on Arbitrum. This will bring the efficient and tested system for atomic trades to the Arbitrum Layer 2 network!