Skip to content
Business logic Audit finding Intermediate

Incorrect Assumption of Stablecoin Market Stability

The StableVault contract allowed users to deposit any supported stablecoin and withdraw an equal amount of any other stablecoin at a 1:1 ratio, ignoring real price differences. An attacker could deposit a slightly cheaper stablecoin and withdraw a more valuable one, profiting from the price gap.

0xsomeone Follow with Critical, __141345__ and 8 others

Originally disclosed on Code4rena

Submitted by 0xsomeone, also found by Critical, 141345, Tointer, Secureverse, SamGMK, rotcivegaf, 0xhacksmithh, 8olidity, Ruhum, and aviggiano

https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/StableVault.sol#L39-L51

https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/StableVault.sol#L60-L72

Impact

The StableVault contract attempts to group all types of stablecoins under a single token which can be minted for any of the stablecoins supported by the system as well as burned for any of them.

This is at minimum a medium-severity vulnerability as the balance sheet of the StableVault will consist of multiple assets which do not have a one-to-one exchange ratio between them as can be observed by trading pools such as Curve as well as the Chainlink oracle reported prices themselves.

Given that the contract exposes a 0% slippage 1-to-1 exchange between assets that in reality have varying prices, the balance sheet of the contract can be arbitraged (especially by flash-loans) to swap an undesirable asset (i.e. USDC which at the time of submission was valued at 0.99994853 USD) for a more desirable asset (i.e. USDT which at the time of submission was valued at 1.00000000 USD) acquiring an arbitrage in the price by selling the traded asset.

Proof of Concept

To illustrate the issue, simply view the exchange output you would get for swapping your USDC to USDT in a stablecoin pool (i.e. CurveFi) and then proceed to invoke deposit with your USDC asset and retrieve your incorrectly calculated USDT equivalent via withdraw.

The arbitrage can be observed by assessing the difference in the trade outputs and can be capitalized by selling our newly acquired USDT for USDC on the stablecoin pair we assessed earlier, ultimately ending up with a greater amount of USDC than we started with. This type of attack can be extrapolated by utilizing a flash-loan rather than our personal funds.

Tools Used

Chainlink oracle resources

Curve Finance pools

Recommended Mitigation Steps

We advise the StableVault to utilize Chainlink oracles for evaluating the inflow of assets instead, ensuring that all inflows and outflows of stablecoins are fairly evaluated based on their “neutral” USD price rather than their subjective on-chain price or equality assumption.

Alex the Entreprenerd (judge) increased severity to High and commented:

The warden has shown how, due to an incorrect assumption, the system offers infinite leverage.

This can be trivially exploited by arbitraging with any already available exchange.

Depositors will incur a loss equal to the size of the arbitrage as the contract is always taking the losing side.

I believe this should be High because of it’s consistently losing nature.

TriHaz (Tigris Trade) acknowledged and commented:

We are aware of this issue, we will keep the vault with one token for now.


The original report as published on Code4rena, by 0xsomeone. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The contract assumed all supported stablecoins have an equal value and allowed 1:1 exchanges without checking actual market prices.

Impact

An attacker could repeatedly arbitrage the vault, causing losses to depositors equal to the price differences, and the judge raised severity to High.

What the attacker needed

Access to a supported stablecoin; an external exchange for arbitrage

The fix

The vault should use a price oracle such as Chainlink to value deposits and withdrawals fairly instead of assuming a 1:1 ratio.

How it was found

  1. Deposit a less valuable stablecoin into the vault.
  2. Withdraw an equal amount of a more valuable stablecoin.
  3. Sell the withdrawn stablecoin on an external exchange for a profit.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A vault let people swap between different stablecoins as if they were all worth exactly the same. In reality, their prices differ slightly, so someone could put in the cheaper coin and take out the more expensive one, making a profit at the vault's expense.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0xsomeone

View all

7 more disclosed reports, best first.

More from Tigris Trade contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.