Tokens that don't allow to change allowance if it is not set to 0 beforewill not work correcntly with Trading contract #128
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-104
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L643-L659
Vulnerability details
Impact
Because function Trading._handleDeposit every time approves _stableVault contract for max allowance it will work only once for such tokens as usdt.
Proof of Concept
Trading._handleDeposit function is used in Trading contract to get funds from trader.
https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L643-L659
The line that we need to check is
IERC20(_marginAsset).approve(_stableVault, type(uint).max);
. In this line Trading contract set max allowance for vault contract in marginAsset token.In case if such token is USDT or similar(that doesn't allow to provide allowance if current allowance was not 0) will be used that means that this function will succeed only one time. On all next calls it will revert.
Because there is no function that allows to set allowance for USDT token to 0 it means that it will not be possible to use USDT anymore.
I believe this is high severity issue as it will fully block ability to use USDT token with Trading contract.
Tools Used
VsCode
Recommended Mitigation Steps
Set allowance to 0 after transfer, or set allowance equal to the value you want to be transferred.
The text was updated successfully, but these errors were encountered: