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.
Submitted by WatchPug, also found by cmichel, hyh, pauliax, TomFrenchBlockchain, and UncleGrandpa925
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.
Great find, slippage should be configurable and not hardcoded to 0.
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.