Skip to content
Audit finding Advanced

Tokens without UniV3 pairs with `tokenToBeneficiary` can be stolen by an attacker

Tokens sent to a Swapper that lack a Uniswap V3 pool with the beneficiary token can be stolen because an attacker can create a new pool with extremely low liquidity and manipulate its TWAP price to near zero, then swap the tokens out cheaply. The oracle only uses direct Uniswap V3 pairs and does not check liquidity or pool age.

ctf_sec Follow with mstpr-brainbot, obront and 1 other

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-04-splits-judging/issues/26

Found by

ctf_sec, mstpr-brainbot, obront, theOwl

Summary

Tokens sent to a Swapper that don't share a UniV3 pool with tokenToBeneficiary can be stolen, because an attacker can create such a pool with ultra-low liquidity and maintain it for the length of the TWAP, pricing the tokens at ~0 and swapping to steal them.

Vulnerability Detail

The oracle uses the TWAP price from Uniswap V3 to determine the price of each asset.

If a pair is not listed on Uniswap V3, the oracle will not work, so swapping the asset will not be permitted. In this case, the user should be able to withdraw the asset themselves using the execCalls() function.

This will be a relatively common occurrence that doesn't require obscure tokens. Many combinations of tokens on Uniswap are able to be traded because of multi-step hops (ie they don't have a pool directly, but they share a poolmate). However, these multi-step hops are not provided by the oracle. A quick review of Uniswap Pairs List shows that this would impact token pairs as common as MATIC/WBTC or MAKER/FRAX.

In these situations, an attacker could steal all of the tokens in question by performing the following:

  • Create a Uniswap V3 pool with the Swapper's tokenToBeneficiary and the token in question
  • Seed it with an incredibly low amount of liquidity at a ratio that values that token in question at ~0
  • Maintain this price for the length of the TWAP, which shouldn't be hard with a new, unused pool and low liquidity (ie if the liquidity amount of lower than the gas needed to perform a swap, arbitrage bots will leave it alone)
  • Perform a "swap" from this asset to the tokenToBeneficiary, stealing the asset and paying ~0 for it

Impact

Any tokens sent to a Swapper that do not have a pair with tokenToBeneficiary in Uniswap V3 can be stolen.

Code Snippet

https://github.com/sherlock-audit/2023-04-splits/blob/main/splits-oracle/src/UniV3OracleImpl.sol#L274-L282

Tool used

Manual Review

Recommendation

UniV3OracleImpl.sol should require the pool being used as an oracle to meet certain liquidity thresholds or have existed for a predefined period of time before returning the price to the Swapper.

Discussion

zobront

Fixed by https://github.com/0xSplits/splits-oracle/pull/3/ by only allowing whitelisted pools.

jacksanford1

Confirming that Splits meant for this fix (3) to be linked to this issue (26): https://github.com/0xSplits/splits-oracle/pull/3#issue-1701222164

hrishibhat

Considering this issue as a valid medium given that this attack is possible only in case of non-existent token pair and is common with the issue of low liquidity underlying pool. Combining this issue and #28 with all their duplicates.

hrishibhat

Sherlock's previous rule that held valid for this contest: External Oracle Price Manipulation: Issues related to price manipulation in an external oracle used by the contracts are not considered valid high/medium. Based on the above rule Issue #28 and direct duplicates of the price manipulation of the issue are considered to be low as they are about direct pool manipulation,

However, #26 and its dupes mention non-existent pools which can be created by anyone the obtain the desired price which clearly does not fall under the above rule. Allowing tokens to be used which does not yet have a pool to obtain price from cannot be considered directly under the price manipulation rule and is a separate issue. Hence considering the above issue and its duplicates as valid medium.

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

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

Likely the oracle does not verify that the Uniswap V3 pool used for pricing has sufficient liquidity or has existed long enough, allowing an attacker to create and manipulate a new pool.

Impact

Any tokens sent to a Swapper that do not have a direct Uniswap V3 pair with tokenToBeneficiary can be stolen.

What the attacker needed

Token lacks direct UniV3 pair with beneficiary; attacker can create a new UniV3 pool; attacker can maintain price for TWAP duration

The fix

The oracle was fixed by only allowing whitelisted pools.

How it was found

  1. Create a Uniswap V3 pool between the Swapper's tokenToBeneficiary and the token in question.
  2. Seed the pool with very low liquidity at a ratio that values the token near zero.
  3. Maintain that price for the duration of the TWAP.
  4. Perform a swap from the asset to tokenToBeneficiary to steal the asset at almost no cost.

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 Swapper contract uses a price oracle to decide how many tokens you get when swapping. If a token has no direct trading pair with the beneficiary token on Uniswap V3, the oracle cannot get a price. An attacker can create that missing pair themselves with almost no liquidity, keep the price near zero for the required time, and then swap to take the tokens for almost nothing.

More by ctf_sec

View all

25 more disclosed reports, best first.

More from Splits

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.