The meowintKittyCoin
function updates the internal state and calls the external i_kittyCoin
contract to mint tokens before verifying if the caller has sufficient collateral. This sequence can lead to an inconsistent state if the collateral check fails, as tokens may be minted even when the caller does not have enough collateral.
In the meowintKittyCoin
function, the balance of kittyCoinMeownted
is updated, and tokens are minted before the function checks if the caller (msg.sender
) has enough collateral. If the collateral check fails, the transaction reverts, but the tokens might have already been minted, leading to an incorrect state.
An attacker can exploit this vulnerability to mint tokens without having sufficient collateral, resulting in:
Unauthorized token minting, potentially leading to inflation of the token supply.
Financial loss and instability within the contract due to incorrect state updates.
Manual
To mitigate this vulnerability, reorder the operations to ensure the collateral check occurs before any state changes or external calls. Here is the revised function:
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.