Skip to content
Race condition Audit finding Intermediate

sNOTE.sol#_mintFromAssets() Lack of slippage control

The minting functions pass a hardcoded minimum output of zero when joining a Balancer pool, so there is no slippage protection. An attacker could front-run the transaction and manipulate the pool so the caller receives fewer pool tokens than expected.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug, also found by cmichel, hyh, pauliax, TomFrenchBlockchain, and UncleGrandpa925

https://github.com/code-423n4/2022-01-notional/blob/d171cad9e86e0d02e0909eb66d4c24ab6ea6b982/contracts/sNOTE.sol#L195-L209

BALANCER_VAULT.joinPool{value: msgValue}(
    NOTE_ETH_POOL_ID,
    address(this),
    address(this), // sNOTE will receive the BPT
    IVault.JoinPoolRequest(
        assets,
        maxAmountsIn,
        abi.encode(
            IVault.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT,
            maxAmountsIn,
            0 // Accept however much BPT the pool will give us
        ),
        false // Don't use internal balances
    )
);

The current implementation of mintFromNOTE() and mintFromETH() and mintFromWETH() (all are using _mintFromAssets() with minimumBPT hardcoded to 0) provides no parameter for slippage control, making it vulnerable to front-run attacks.

Recommendation

Consider adding a minAmountOut parameter for these functions.

jeffywu (Notional) confirmed

pauliax (judge) commented:

Great find, slippage should be configurable and not hardcoded to 0.


The original report as published on Code4rena, by WatchPug. 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 minimum pool-token output is hardcoded to zero instead of being a caller-supplied parameter.

Impact

A depositor could receive fewer pool tokens than expected because a front-runner can shift the pool before the transaction lands.

What the attacker needed

Attacker can front-run the deposit transaction

The fix

The minting functions should accept a minimum output amount and revert if the pool returns less.

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 deposit tokens into a pool, the amount of pool tokens you get back can change between when you send the transaction and when it is processed. This code accepts whatever amount the pool decides to give, with no minimum. Someone watching the pending transaction could move the pool price first so the depositor gets a worse deal.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by WatchPug

View all

197 more disclosed reports, best first.

More from Notional contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.