First Flight #21: KittyFi

First Flight #21
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

Reentrancy Vulnerability in `KittyVault::executeWhiskdrawal`

Description: The KittyVault::executeWhiskdrawal function calls an external contract to transfer tokens before updating the state, which could lead to a reentrancy attack.

Impact: An attacker could drain funds or cause other unexpected behavior by reentering the contract.

Proof of Concept: An attacker could create a malicious contract that reenters the KittyVault contract:

contract Malicious {
KittyVault public vault;
constructor(address _vault) {
vault = KittyVault(_vault);
}
function attack() public {
vault.executeWhiskdrawal(address(this), 1);
}
function receive() external payable {
vault.executeWhiskdrawal(address(this), 1);
}
}

Recommended Mitigation: Use the Checks-Effects-Interactions pattern to update the state before calling external contracts.

function executeWhiskdrawal(address _user, uint256 _cattyNipToWithdraw) external onlyKittyPool {
collateral[_user] -= _cattyNipToWithdraw;
IERC20(token).transfer(_user, _cattyNipToWithdraw);
}
Updates

Lead Judging Commences

shikhar229169 Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.