MorpheusAI

MorpheusAI
Foundry
22,500 USDC
View results
Submission Details
Severity: low
Valid

By calling `SwapRouterMock::exactInputSingle` function anyone can exchange his non value ERC20 tokens to any valuable ERC20 token due to no check implemented.

By calling SwapRouterMock::exactInputSingle function anyone can exchange his non value ERC20 tokens to any valuable ERC20 token due to no check implemented.

Vulnerability Details

Since SwapRouterMock doesn't have any pool pairs or whitelisted tokens list nor it is using any priceFeed to know the relative other token price in terms of first token before exchanging. It is just taking Any type of ERC20 token in tokenIn and giving same amount of tokenOut ERC20 tokens. So anyone can call this exactInputSingle function and get the desired ERC20 token whatever this SwapRouterMock holds by passing his non-valuable erc20 tokens just created by himself also.

contracts/mock/SwapRouterMock.sol#L8-L12

8: function exactInputSingle(ISwapRouter.ExactInputSingleParams calldata params_) external returns (uint256) {
@> 9: IERC20(params_.tokenIn).transferFrom(msg.sender, address(this), params_.amountIn);
@> 10: IERC20(params_.tokenOut).transfer(params_.recipient, params_.amountIn);
return params_.amountIn;
}

Impact

Attacker can drain all type of ERC20 tokens from SwapRouterMock whichever it has by giving it non-value ERC20 tokens which worths nothing.

Tools Used

Manual Review

Recommended Mitigation

Add some type of whitelist of tokens pairs which can be exchanged and their pairs priceFeed is available on chainlink/Uniswap or any other oracle. Also use the priceFeed to calculate the amounts of tokenOut what will be given out to the user in exchange of tokenIn.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

SwapRouterMock/NonfungiblePositionManagerMock doesn't take into account prices or token pairs or any traditional protection mechanisms of Uniswap

nmirchev8 Auditor
over 1 year ago
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

SwapRouterMock/NonfungiblePositionManagerMock doesn't take into account prices or token pairs or any traditional protection mechanisms of Uniswap

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.