-
Notifications
You must be signed in to change notification settings - Fork 7
0x52 - Protocol is completely incompatible with USDT due to lack of 0 approval #203
Comments
Escalate for 10 USDC I agree with "approve to 0 first" is one of the most common bugs in the space but I think it is invalid for this protocol. Approval calls to token contracts are made from pool contracts in this protocol, like borrow() and updateReserveByVault() functions. Before calling the approve function, the allowance of the vault is checked and the call is made if
I believe the issue is invalid for this protocol as the approval is not expected to be used by EOAs. A pool can not directly approve to a non-zero value because it doesn't have a function to make that call. That's why I don't see a scenario where the allowance is not zero, and not |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
@osmanozdemir1 isn't the allowance check done wrong in the line 50? |
Oh, I see. You're definitely right about that, and this makes it problematic due to the wrong implementation in line 50. Root cause is wrong allowance check and I totally missed it. Thanks for the comment. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
Fix looks good |
0x52
medium
Protocol is completely incompatible with USDT due to lack of 0 approval
Summary
USDT will revert if the current allowance is greater than 0 and an non-zero approval is made. There are multiple instances throughout the contracts where this causes issues. In some places this can create scenarios where it becomes impossible to liquidate and/or borrow it.
Vulnerability Detail
See summary.
Impact
USDT may become impossible to liquidate or borrow
Code Snippet
D3Funding.sol#L20-L23
D3Funding.sol#L50-L53
D3Funding.sol#L64-L67
D3MMLiquidationRouter.sol#L24
Tool used
Manual Review
Recommendation
Utilize the OZ safeERC20 library and safeApprove
The text was updated successfully, but these errors were encountered: