Did Not Approve To Zero First Causing Certain Token Transfer To Fail #36
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
invalid
This doesn't seem right
withdrawn by warden
Special case: warden has withdrawn this submission and it can be ignored
Lines of code
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/ActivePool.sol#L171
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/ActivePool.sol#L180
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/ActivePool.sol#L183
Vulnerability details
Impact
Some tokens (like USDT) do not work when changing the allowance from an existing non-zero allowance value. For example Tether (USDT)'s approve() function will revert if the current approval is not zero, to protect against front-running changes of approvals.
Proof of Concept
Allowance was not set to zero first before changing the allowance.
Some tokens (like USDT) do not work when changing the allowance from an existing non-zero allowance value. For example Tether (USDT)'s approve() function will revert if the current approval is not zero, to protect against front-running changes of approvals.
in ActivePool.sendCollateral, in lines 180 and 183, before calling safeIncreaseAllowance, must be approved by zero first, and then the safeIncreaseAllowance function can be called. Otherwise, the ActivePool.sendCollateral function will revert every time it handles such kinds of tokens.
The same problem can be seen in the line below:
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/ActivePool.sol#L279
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/BorrowerOperations.sol#L506
Tools Used
Manually
Sample report approved by the C4 judges team:
code-423n4/2022-06-connext-findings#154
Recommended Mitigation Steps
It is recommended to set the allowance to zero before increasing the allowance
The text was updated successfully, but these errors were encountered: