In the current implementation, _joinTokenSingle() requires balanceOf outputToken strictly equal to outputAmount in calldata.
However, since anyone can transfer outputToken to the contract, if there are existing outputToken in the balanceOf the contract, joinTokenSingle() will always fail with "FAILED_OUTPUT_AMOUNT".
An attacker can send 1 wei of outputToken and break joinTokenSingle().
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-amun/blob/98f6e2ff91f5fcebc0489f5871183566feaec307/contracts/basket/contracts/singleJoinExit/SingleTokenJoin.sol#L133-L137
In the current implementation,
_joinTokenSingle()
requires balanceOfoutputToken
strictly equal tooutputAmount
in calldata.However, since anyone can transfer
outputToken
to the contract, if there are existingoutputToken
in the balanceOf the contract,joinTokenSingle()
will always fail with "FAILED_OUTPUT_AMOUNT".An attacker can send
1 wei
ofoutputToken
and breakjoinTokenSingle()
.The same problem also applies to:
https://github.com/code-423n4/2021-12-amun/blob/98f6e2ff91f5fcebc0489f5871183566feaec307/contracts/basket/contracts/singleJoinExit/SingleTokenJoinV2.sol#L128-L132
Recomandation
Change to: