The KittyPool::burnKittyCoin
function lacks proper input validation, causing arithmetic overflow/underflow errors. This leads to unexpected reverts when users attempt to burn more tokens than their balance, disrupting contract functionality and potentially causing significant harm.
The KittyPool::burnKittyCoin
function does not include proper checks to ensure that the burn amount does not exceed the user's balance. As a result, when a user attempts to burn more tokens than they possess, the function reverts with a panic code due to arithmetic underflow. 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 KittyPool::burnKittyCoin
function to ensure the burn amount is valid and does not exceed the user's balance. 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.