Skip to content
Smart contracts Audit finding Intermediate

formPOL lacks slippage and deadline protection

The formPOL function lacked slippage and deadline protection when depositing liquidity, allowing an attacker to sandwich the deposit and cause the protocol to lose funds. The issue was acknowledged but the protocol removed POL entirely as a mitigation.

Banditx0x Follow with Hajime, oakcobalt and 8 others

Originally disclosed on Code4rena

Submitted by Banditx0x, also found by Hajime, oakcobalt, 0xGreyWolf, Tripathi, PENGUN, Krace, 00xSEV (1, 2), 0xmuxyz, b0g0 (1, 2), Jorgect, Kaysoft, and djxploit

https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/dao/DAO.sol#L316

https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/dao/DAO.sol#L360

formPOL can be vulnerable to a well known liquidity deposit sandwich attack causing loss of funds for the protocol.

Proof of Concept

In formPOL, there are no slippage parameters when calling depositLiquidityAndIncreaseShare

All liquidity deposits in a Uniswap v2 style pool can be frontrun by this sequence of steps:

  1. attacker pushes pool away from correct ratio
  2. victims liquidity deposit goes through at wrong ratio
  3. attacker sells tokens into the new liquidity for a profit

Liquidity withdrawals in a x * y = k pool are actually rarely profitable to frontrun attack (it requires certain edge cases), as the same sequence actually loses money if it is a liquidity withdrawals, which is why withdrawPOL wasn’t explicitly mentioned. However, this issue also applies to withdrawPOL and adding slippage protection in that function could be an extra safety measure.

Recommended Mitigation Steps

formPOL should have some form of slippage protection. This could be based off a maximum deviation off some other price feed such a Uniswap v3 TWAP or Chainlink pricefeed. If the pool reserves deviates too much from the expected ratio from the price feed, formPOL should revert.

othernet-global (Salty.IO) acknowledged and commented:

The automatic arbitrage on the DEX provides some built in protection against front running as the attacker is not able to move in and out without experiencing friction from the arbitrage itself.

Simulations (see Sandwich.t.sol) show that when sandwich attacks are used on Salty, the arbitrage earned by the protocol sometimes exceeds any amount lost due to the sandwich attack itself. The actual swap loss (taking arbitrage profits generated by the sandwich swaps into account) is dependent on the multiple pool reserves involved in the arbitrage (which are encouraged by rewards distribution to create more reasonable arbitrage opportunities).

Picodes (Judge) decreased severity to Medium and commented:

Regrouping issues about missing slippage checks here as the root cause is the same - the assumption that AAA is enough to prevent MEV bots from sandwiching maintenance transactions doesn’t always hold.

othernet-global (Salty.IO) commented:

POL has been removed from the protocol:

eaf40ef0fa27314c6e674db6830990df68e5d70e https://github.com/othernet-global/salty-io/commit/8e3231d3f444e9851881d642d6dd03021fade5ed

Status: Mitigation confirmed. Full details in reports from 0xpiken, zzebra83, and t0x1c.


The original report as published on Code4rena, by Banditx0x. 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

Likely the absence of slippage parameters in the depositLiquidityAndIncreaseShare call within formPOL, allowing the pool ratio to be manipulated before the deposit.

Impact

The protocol could lose funds due to the sandwich attack, though the automatic arbitrage on the DEX may provide some protection and the actual loss depends on pool reserves.

What the attacker needed

Attacker can front-run transactions; victim calls formPOL

The fix

The protocol removed POL entirely as a mitigation, as confirmed by the status 'Mitigation confirmed'.

How it was found

  1. Attacker pushes the pool away from the correct ratio.
  2. Victim's liquidity deposit goes through at the wrong ratio.
  3. Attacker sells tokens into the new liquidity 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.

When you add money to a trading pool, the amount of tokens you get depends on the current ratio of the pool. An attacker can change that ratio just before your deposit and then trade back after, making your deposit less valuable. This is called a sandwich attack, and it happens because the deposit function did not check for a minimum acceptable ratio.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by Banditx0x

View all

6 more disclosed reports, best first.

More from Salty.IO

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.