Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

shogoki - Possible loss of Funds - Liquidation transfers may silently fail #101

Open
sherlock-admin opened this issue Jul 1, 2023 · 12 comments
Labels
Escalation Resolved This issue's escalations have been approved/rejected Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Jul 1, 2023

shogoki

high

Possible loss of Funds - Liquidation transfers may silently fail

Summary

Transfers at Liquidation may silently fail, causing collateral be paid out withoud debt being paid, or liquidator not getting collateral.

Vulnerability Detail

in D3VaultLiquidation.sol:liquidate the caller pays the outstanding debt, and received the collateral tokens with a discount in exchange.
However, the transfer of the tokens to pay the debt, as well as the transfer of the collateral Tokens are using the transferFrom function of the ERC20 interface instead of safeTransferFrom (which is used in other functions).
Moreover, the return value of this function is not checked. As not all ERC20 tokens revert on a failed transfer, this could lead to a silent failure of a transfer. As the function will go on in this case this could lead to the liquidation to finish with either:

  • The debt not being paid, but the collateral still paid to the caller --> Loss of protocol funds!
  • The debt being repaid by the caller, but the collateral is not transferred --> Loss of user funds!

Impact

Possible loss of user or protocol funds.

Code Snippet

https://github.com/sherlock-audit/2023-06-dodo/blob/main/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultLiquidation.sol#L55

https://github.com/sherlock-audit/2023-06-dodo/blob/main/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultLiquidation.sol#L59

Tool used

Manual Review

Recommendation

Usage of safeTransferFrom as in other functions of the same contract is recommended.

@github-actions github-actions bot closed this as completed Jul 5, 2023
@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Jul 5, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Jul 24, 2023
@Shogoki
Copy link

Shogoki commented Jul 25, 2023

Escalate for 10USDC
This is not a duplicate of #203, which talks about USDC and Approval Race Condition protected tokens.
Furthermore this is a separate issue together with duplicates like: #5 #42 #64 & #214

@sherlock-admin2
Copy link

Escalate for 10USDC
This is not a duplicate of #203, which talks about USDC and Approval Race Condition protected tokens.
Furthermore this is a separate issue together with duplicates like: #5 #42 #64 & #214

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.

@sherlock-admin sherlock-admin added the Escalated This issue contains a pending escalation label Jul 25, 2023
@0xffff11
Copy link
Collaborator

0xffff11 commented Aug 1, 2023

Agree with escalation, it was wrongly duped.

@jesusrod15
Copy link

jesusrod15 commented Aug 7, 2023

I agree that all the issues that came about race approvals were wrongly duped. Likewise, the rest of the issues that reported incorrect use of transferfrom instead of safetrasnferfrom were always duplicated in the same way in other contest regardless that whats happens. So I think this is a duplicate x example of #11 #34 #5 #42 #88 and others issue as this, this is not duplicate of #2 #35 and others issue as this that are duplicate of #203

@hrishibhat
Copy link

hrishibhat commented Aug 8, 2023

Result:
Medium
Has duplicates
The duplication has been changed accordingly

@hrishibhat hrishibhat reopened this Aug 8, 2023
@hrishibhat hrishibhat added Has Duplicates A valid issue with 1+ other issues describing the same vulnerability and removed Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Aug 8, 2023
@sherlock-admin2
Copy link

sherlock-admin2 commented Aug 8, 2023

Escalations have been resolved successfully!

Escalation status:

@sherlock-admin sherlock-admin removed the Escalated This issue contains a pending escalation label Aug 8, 2023
@sherlock-admin2 sherlock-admin2 added the Escalation Resolved This issue's escalations have been approved/rejected label Aug 8, 2023
@H4LITUS
Copy link

H4LITUS commented Aug 8, 2023

This is a duplicate of #214. So why was the status of 214 changed from reward to non-reward?

@Proxy1967
Copy link

#151 is a dup of this issue yet the status was changed from reward to non-reward and to low/info. Why ? @hrishibhat

@hrishibhat
Copy link

@kirinfilip I don't think #151 clearly describes any issue. Please add a little more detail in the future from the context of the code in the submissions.

@Proxy1967
Copy link

@hrishibhat understandable, thanks for the explanation.

@Attens1423 Attens1423 added the Will Fix The sponsor confirmed this issue will be fixed label Aug 10, 2023
@Attens1423
Copy link

@IAm0x52
Copy link
Collaborator

IAm0x52 commented Sep 13, 2023

Fix looks good.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Escalation Resolved This issue's escalations have been approved/rejected Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

10 participants