DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: low
Invalid

unauthorized token burning

Summary

unauthorized token burning

Vulnerability Details

The vulnerability is located in lines 84 to 87. In these lines, the contract burns tokens from the liquidator's wallet without checking if the liquidator has approved the contract to do so. This could potentially lead to unauthorized token burning. The contract should first check if the liquidator has given the contract an allowance to burn their tokens. If not, the contract should revert or ask the liquidator to approve the contract to burn their tokens. This is a critical vulnerability as it could lead to loss of tokens for the liquidator.

Tools Used

vscode

Recommendations

To resolve this issue, you should add a check to ensure that the liquidator has approved the contract to burn their tokens. If not, the contract should revert with an appropriate error message. Here is a sample code snippet:

if (isWallet) {
IAsset tokenContract = IAsset(asset);
uint256 walletBalance = tokenContract.balanceOf(msg.sender);
uint256 allowance = tokenContract.allowance(msg.sender, address(this));
if (walletBalance < m.short.ercDebt || allowance < m.short.ercDebt) {
revert Errors.InsufficientAllowanceOrBalance();
}
tokenContract.burnFrom(msg.sender, m.short.ercDebt);
assert(tokenContract.balanceOf(msg.sender) < walletBalance);
}

In the above code, we first check if the liquidator's wallet balance and allowance for the contract are both greater than or equal to the debt to be liquidated. If not, we revert with an error. Only then do we proceed to burn the tokens from the liquidator's wallet.

Also, make sure to define the InsufficientAllowanceOrBalance error in your Errors library.

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.