#41885 [SC-Insight] Bypass token whitelist
Description
Brief/Intro
Vulnerability Details
function _swap(swapTokenInfo memory tokenInfo, bytes calldata pathDefinition, address executor, uint32 referralCode)
internal
returns (uint256 amountOut)
{
// Check for valid output specifications
require(
tokenInfo.outputMin <= tokenInfo.outputQuote,
MinimumOutputGreaterThanQuote(tokenInfo.outputMin, tokenInfo.outputQuote)
);
require(tokenInfo.outputMin > 0, MinimumOutputIsZero());
require(tokenInfo.inputToken != tokenInfo.outputToken, SameTokenInAndOut(tokenInfo.inputToken));
uint256 balanceBefore = tokenInfo.outputToken.universalBalance();
// Delegate the execution of the path to the specified OBExecutor
uint256[] memory amountsIn = new uint256[](1);
amountsIn[0] = tokenInfo.inputAmount;
@> external call to executor with arbitrary path >> IOBExecutor(executor).executePath{value: msg.value}(pathDefinition);
amountOut = tokenInfo.outputToken.universalBalance() - balanceBefore;
if (referralCode > REFERRAL_WITH_FEE_THRESHOLD) {
referralInfo memory thisReferralInfo = referralLookup[referralCode];
if (thisReferralInfo.beneficiary != address(this)) {
tokenInfo.outputToken.universalTransfer(
thisReferralInfo.beneficiary, amountOut * thisReferralInfo.referralFee * 8 / (FEE_DENOM * 10)
);
}
// Takes the fees and keeps them in this contract
amountOut = amountOut * (FEE_DENOM - thisReferralInfo.referralFee) / FEE_DENOM;
}
int256 slippage = int256(amountOut) - int256(tokenInfo.outputQuote);
if (slippage > 0) {
amountOut = tokenInfo.outputQuote;
}
require(amountOut >= tokenInfo.outputMin, SlippageExceeded(amountOut, tokenInfo.outputMin));
// Transfer out the final output to the end user
tokenInfo.outputToken.universalTransfer(tokenInfo.outputReceiver, amountOut);
emit Swap(
msg.sender,
tokenInfo.inputAmount,
tokenInfo.inputToken,
amountOut,
tokenInfo.outputToken,
slippage,
referralCode
);
}Impact Details
References
Proof of Concept
Proof of Concept
Previous#41876 [SC-Insight] User may receive boosted values which are non-concaveNext#41890 [SC-Insight] MoneyBrinter vault does not consider Farm's staking cap
Was this helpful?