Closed 0xRizwan closed 9 months ago
same, all transfers are safe by globally enabling the imported interface https://github.com/ubiquity/ubiquity-dollar/blob/38c3656539ae19fe9be162f566b36ec62a3e6e41/packages/contracts/src/dollar/libraries/LibDirectGovernanceFarmer.sol#L17
# Issue was not closed as completed. Skipping.
Title
USDT approvals does not check return value violating EIP20 in
LibDirectGovernanceFarmer.depositSingle()
Severity
Medium
Vulnerability Detail
The ERC20.approve() function return a boolean value indicating success. This parameter needs to be checked for success. Some tokens do not revert if the transfer failed but return false instead. Per EIP20, approve() function should be as below,
It means, for ERC20 approvals the return value must be checked to be incompliance with EIP20 tokens.
The protcol uses USDT as one of the token in LibDirectGovernanceFarmer.depositSingle(). The issue here is that tokens like USDT don't correctly implement the EIP20 standard and their approve() function return void instead of a success boolean. This can be checked from below USDT approve() function.
It is confirmed that, USDT token approval does not check return value for approvals and this is violating the EIP20. Therefore, calling USDT approve function with the correct EIP20 function signatures will always revert. Tokens that don't actually perform the approval and return false are still counted as a correct approval and tokens that don't correctly implement the latest EIP20 spec, like USDT, will be unusable in the protocol as they revert the transaction because of the missing return value.
Therefore, In the protocol, all functions using approve() must be check the return value.
In
LibDirectGovernanceFarmer.depositSingle()
,Here, one of the deposited token is USDT and USDT does not check return value for approve() as discussed above. Therefore, return value must be checked for USDT approvals.
Recommendation
Use safeApprove() from openZeppelin’s SafeERC20. This checks the return value and makes it compliant with EIP20.
cc- @pavlovcik @molecula451