Improper implementation of slippage check
The redeem function in the Zap contract did not apply the caller's minimum-output limit to the branch that withdraws from the byvWbtc pool. An attacker or unlucky user could therefore receive far less than the requested minimum when redeeming through that pool.
Submitted by WatchPug, also found by gzeon
function redeem(IERC20 token, uint amount, uint poolId, int128 idx, uint minOut)
external
defend
blockLocked
whenNotPaused
returns(uint out)
{
ibbtc.safeTransferFrom(msg.sender, address(this), amount);
Pool memory pool = pools[poolId];
if (poolId < 3) { // setts
settPeak.redeem(poolId, amount);
pool.sett.withdrawAll();
pool.deposit.remove_liquidity_one_coin(pool.lpToken.balanceOf(address(this)), idx, minOut);
} else if (poolId == 3) { // byvwbtc
byvWbtcPeak.redeem(amount);
IbyvWbtc(address(pool.sett)).withdraw(); // withdraws all available
} else {
revert("INVALID_POOL_ID");
}
out = token.balanceOf(address(this));
token.safeTransfer(msg.sender, out);
}
In the current implementation of. Zap.sol#redeem(), the outAmount of IbyvWbtc.withdraw() is not controlled by minOut.
Recommendation
Consider implementing the minOut check in between L236 and L237.
...
out = token.balanceOf(address(this));
require(out >= _minOut, "Slippage Check");
token.safeTransfer(msg.sender, out);
}
GalloDaSballo (BadgerDAO) confirmed:
Agree with the finding, not having slippage check at end means people can get rekt, we’ll add as suggested
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-output parameter was only passed to the Curve removal call for the first three pools and was never checked against the final token balance for the byvWbtc pool.
Impact
Users redeeming through the byvWbtc pool could receive less than their stated minimum, exposing them to slippage losses.
What the attacker needed
Redeem through the byvWbtc pool
The fix
The project said it would add a check that the received amount is at least the minimum before transferring to the user.
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 swap or redeem tokens, you usually set a minimum amount you are willing to accept, so a sudden price change cannot leave you with much less. Here one code path ignored that minimum, so the protection was missing for that pool. The project agreed and said it would add the check.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.