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
Remix IDE
Solhint linter
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");
}
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;
}
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