code-423n4 / 2023-07-tapioca-findings

15 stars 10 forks source link

Unwrap function in TapiocaOFT contract does not check if the amount to unwrap is greater than zero. #1154

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/Tapioca-DAO/tapiocaz-audit/blob/master/contracts/tOFT/TapiocaOFT.sol#L85

Vulnerability details

Descrition

The unwrap function in the TapiocaOFT contract does not check if the amount to unwrap is greater than zero. This means that it is possible to call the function with an amount of zero, which will result in the caller losing their tokens.

Impact

It could result in users losing their tokens. This could have a significant financial impact on the users, and could also damage the reputation of the TapiocaOFT contract.

Proof of Concept

pragma solidity ^0.8.18;

import "./TapiocaOFT.sol";

contract Test { function main() public { address toAddress = address(0); uint256 amount = 0;

    TapiocaOFT tOFT = new TapiocaOFT();
    tOFT.unwrap(toAddress, amount);
}

}

This will deploy a new TapiocaOFT contract and call the unwrap function with an amount of zero. The tokens will be lost.

Tools Used

Recommended Mitigation Steps

The unwrap function should be updated to check if the amount to unwrap is greater than zero. This can be done by adding the following line of code:

if (_amount <= 0) { revert("Amount must be greater than zero"); }

Assessed type

Other

minhquanym commented 1 year ago

Spam

c4-pre-sort commented 1 year ago

minhquanym marked the issue as low quality report

c4-judge commented 1 year ago

dmvt marked the issue as unsatisfactory: Insufficient quality