Closed code423n4 closed 2 years ago
The contract would not have any WETH sitting it in from normal use. The only way this would happen is if a user randomly transferred WETH to the contract. And if they want to do that, it's better for it to go to a random user, than to be stuck permanently.
Disputed as router contract, send funds at your own peril
Lines of code
FeeBurner.sol#L43-L88
Vulnerability details
Impact
In the
burnToTarget
function, if thetokens_
array has only a zero address token andmsg.value
is 0 thenFeeBurner.sol
would still call theswapAll
function and use all WETH held in the contract. If the contract has any WETH, the caller would get LP tokens of the target pool without using any of their funds.Proof of Concept
An attacker calls the
burnToTarget
function withtokens_
array containing only a zero address token andmsg.value
as 0.The for loop would end before any actual transfer from the caller to the contract takes place and the require condition on line 75 would pass since msg.value is 0.
FeeBurner.sol
approves the swapper router to use an infinite amount of its WETH and then calls the swapper router'sswapAll
function to swap all of its WETH for the underlying token of the target pool.The underlying tokens are then deposited into the target pool and the contract receives the target pool's LP tokens which it sends to the caller.
Recommended Mitigation Steps
Check the WETH balance before and after the for loop and revert if the balance has not increased.