Skip to content

Code4rena

Sushi Trident contest phase 1

Every publicly disclosed report for Sushi Trident contest phase 1 and what kind of bugs they were.

disclosed reports
26
most reported class
Business logic
bug classes found
3
first disclosure
2021
Find Sushi Trident contest phase 1 on bugbounty.fyi Current scope, rewards and status, if it runs a public program.

Disclosed reports

Newest first. Only what Sushi Trident contest phase 1 chose to make public.

DoS

IndexPool pow overflows when weightRatio > 10.

The IndexPool contract's price calculation uses a pow function that overflows when the weight ratio between tokens is large (e.g., 10). This causes all swap transactions to revert, making the pool unusable for trading even though liquidity can still be provided.

Sushi Trident contest phase 1

High
Business logic

Flash swap call back prior to transferring tokens in indexPool

The flashSwap function in the IndexPool contract calls the callback before transferring tokens, so the sender does not receive tokens during the callback. This breaks the expected flash swap behaviour and could require redeploying all index pools if found after mainnet launch.

Sushi Trident contest phase 1

High
Smart contracts

Index Pool always swap to Zero

The _pow function in IndexPool.sol has a missing bracket for the for loop, causing the exponentiation by squaring to be incorrect. As a result, when a pool is initialised with a weight ratio of 1:2, no user can buy token A with token B because the swap always returns zero.

Sushi Trident contest phase 1

High
Business logic

HybridPool ’s reserve is converted to “amount” twice

The HybridPool contract stored reserves as Bento 'amounts' but then converted them again when reading, causing incorrect reserve values. This led to wrong swap outputs, allowing attackers to receive more tokens than they should and causing losses for liquidity providers.

Sushi Trident contest phase 1

High
Smart contracts

absolute difference is not calculated properly when a > b in MathUtils

The difference function in MathUtils.sol incorrectly computes the absolute difference when a > b, causing within1 to return wrong results. An attacker could manipulate pool calculations to make within1 fail, potentially affecting the HybridPool.

Sushi Trident contest phase 1

High
Smart contracts

Incorrect usage of _pow in _computeSingleOutGivenPoolIn of IndexPool

The IndexPool contract's _computeSingleOutGivenPoolIn function passes an exponent in WAD (18-decimal fixed point) to the _pow function, which expects a plain integer exponent. This causes an integer overflow that prevents the function from being called, blocking the associated pool operation.

Sushi Trident contest phase 1

High
Smart contracts

Unsafe cast in IndexPool mint leads to attack

The IndexPool.mint function casts a user-controlled ratio to uint120 without checking for overflow, so an attacker can choose a ratio that truncates to zero and mint LP tokens for free. The attacker can then burn these inflated LP tokens to withdraw the entire pool reserves.

Sushi Trident contest phase 1

High
Business logic

No bar fees for IndexPools ?

The IndexPool contract does not collect fees for the barFeeTo address, despite having an updateBarFee method. This could cause liquidity providers to favour IndexPool over ConstantProductPool, harming the ecosystem.

Sushi Trident contest phase 1

Medium
Business logic

Router would fail when adding liquidity to index Pool

The TridentRouter does not calculate optimal liquidity parameters for index pools, so users may transfer extra tokens or have transactions fail if the pool price changes before confirmation. An attacker could exploit this by front-running to cause failures or force users to deposit at unfavourable rates.

Sushi Trident contest phase 1

Medium
Business logic

withdrawFromWETH always reverts

The withdrawFromWETH function incorrectly checks that the return data length is at least 32 bytes, but WETH.withdraw returns nothing, so the check always fails and the function reverts. This breaks unwrapWETH, causing all transactions that try to unwrap WETH through the router to revert.

Sushi Trident contest phase 1

Medium
Business logic

HybridPool ’s flashSwap sends entire fee to barFeeTo

The flashSwap function in HybridPool sends the entire trade fee to the barFeeTo address instead of only the barFee portion. This means liquidity providers receive no fees when flashSwap is used, removing the incentive to provide liquidity.

Sushi Trident contest phase 1

Medium
Audit finding

Approximations may finish with inaccurate values

The HybridPool contract's approximation functions may stop before converging due to a loop limit, and the inaccurate result is still used as correct. This could lead to incorrect liquidity calculations, potentially causing financial loss.

Sushi Trident contest phase 1

Medium
Business logic

Users are susceptible to back-running when depositing ETH to TridenRouter

The router's deposit functions accept ETH but do not use the actual amount deposited, so users must pre-calculate and send extra ETH. If the exchange rate changes before execution, leftover ETH remains in the router and anyone can back-run to claim it via refundETH.

Sushi Trident contest phase 1

Medium
Business logic

IndexPool.mint The first liquidity provider is forced to supply assets in the same amount, which may cause a significant amount of fund loss

When an IndexPool has no reserves yet, the mint function forces the first liquidity provider to deposit the same raw amount of every token, ignoring each token's weight, decimals and price. An attacker could then swap cheap tokens for the valuable ones and take most of the first provider's value.

Sushi Trident contest phase 1

High
Business logic

IndexPool initial LP supply computation is wrong

The IndexPool contract mints initial LP tokens to the zero address, causing the first mint to require an amount of each token that is independent of its decimals and value. This makes initial liquidity provision economically unjustifiable for pools with tokens of different values or decimals, and allows a second LP to pay less for the same LP tokens.

Sushi Trident contest phase 1

High
Smart contracts

Overflow in the mint function of IndexPool causes LPs’ funds to be stolen

The mint function in IndexPool allowed an attacker to overflow the balance check by supplying a very large amountIn, letting them mint a huge number of LP tokens without providing liquidity. The attacker could then burn those tokens to steal other liquidity providers' funds.

Sushi Trident contest phase 1

High
Smart contracts

Incorrect multiplication in _computeSingleOutGivenPoolIn of IndexPool

The `_computeSingleOutGivenPoolIn` function in `IndexPool` used raw multiplication instead of the `_mul` helper for fixed-point arithmetic, causing `zaz` to be 10^18 times too large and leading to an integer underflow when computing `amountOut`. This prevented anyone from successfully calling the function.

Sushi Trident contest phase 1

High
Business logic

IndexPool’s INIT_POOL_SUPPLY is not fair.

The IndexPool contract mints a fixed initial supply of LP tokens to the zero address in its constructor, and the amount of value effectively burned depends on the size of the first liquidity provider's deposit. A first depositor choosing a non-optimal initial amount causes a large number of tokens to be burned, reducing the profit available to all liquidity providers in the pool.

Sushi Trident contest phase 1

High
Business logic

Router’s complexPath percentagePaths don’t work as expected

The complexPath function recalculates the token balance after each swap iteration, so percentages are applied to the remaining balance rather than the original total. This can cause users to lose funds if they specify percentages that sum to 100%.

Sushi Trident contest phase 1

Medium
Business logic

_depositToBentoBox sometimes uses both ETH and WETH

The TridentRouter contract's deposit function only uses the contract's ETH balance if it is at least the required underlying amount; otherwise it ignores the ETH and pulls WETH from the user. If the required amount increases between transaction submission and inclusion, the user's ETH is ignored and WETH is also taken, causing loss of the ETH deposit.

Sushi Trident contest phase 1

Medium
Business logic

hybrid pool uses wrong non_optimal_mint_fee

The HybridPool contract uses the same non-optimal mint fee calculation as the constant product pool, but because the two pools use different AMM curves, the ideal balance differs. This could lead to incorrect fees being charged when liquidity providers deposit imbalanced amounts.

Sushi Trident contest phase 1

High
Business logic

Funds in the pool could be stolen by exploiting flashSwap in HybridPool

The HybridPool contract used the BentoBox toAmount function to track reserves, which can change when anyone calls harvest to realise strategy profits. An attacker could call harvest during a flash swap callback to reduce the amount of tokens they owed, thereby stealing unrealised yield from the pool.

Sushi Trident contest phase 1

High
Smart contracts

IndexPool : Poor conversion from Balancer V1’s corresponding functions

Several mathematical functions in the IndexPool contract were incorrectly converted from Balancer V1, leading to wrong calculations. This could cause incorrect pool token pricing and potentially allow attackers to exploit the pool for profit.

Sushi Trident contest phase 1

High
Audit finding

Rounding errors will occur for tokens without decimals

The constant product pool's output calculation rounds down, causing significant precision loss for tokens with zero decimals. An attacker swapping small amounts of such tokens could lose a large percentage of their trade to rounding.

Sushi Trident contest phase 1

Medium