The KittyPool::_hasEnoughMeowllateral
function lacks proper checks to ensure that division operations are safe, causing division by zero errors. This leads to unexpected reverts when users attempt to mint KittyCoin without having sufficient collateral, disrupting contract functionality and potentially causing harm.
The KittyPool::_hasEnoughMeowllateral
function does not include proper checks to ensure that the divisor in a division operation is non-zero. As a result, when a user attempts to mint KittyCoin without sufficient collateral, the function reverts with a panic code due to division by zero. This lack of validation allows for uncontrolled reverts, making the contract vulnerable to unexpected behavior and potential exploitation.
Quote from the solidity docs: "Properly functioning code should never create a Panic, not even on invalid external input. If this happens, then there is a bug in your contract which you should fix." (https://docs.soliditylang.org/en/latest/control-structures.html)
Unexpected Reverts: Users experience unexpected transaction failures, leading to a poor user experience and potential loss of trust in the contract.
Disruption of Functionality: The contract's functionality can be disrupted, especially if malicious users intentionally trigger these errors.
While the issue does not directly lead to financial loss, its potential to disrupt contract functionality and the user experience warrants a medium severity rating. If further analysis reveals exploitation paths causing significant harm, the severity could be elevated to high.
Manual code review
Foundry for testing and reproducing the issue
Add the following to KittyFiTest.t.sol
:
Input Validation: Add checks in the _hasEnoughMeowllateral
function to ensure all denominators are non-zero before performing division operations. Revert with meaningful error messages for better control and clarity.
By implementing this recommendation, the contract will handle errors more gracefully, avoid unexpected reverts, and enhance robustness and user experience.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.