Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Attacker can become owner of the contract

Vulnerability Details

Attacker can become owner of the contract by calling inherit function when deadline has passed and there was only one beneficiary.

Impact

After becoming the owner of the contract, attacker can call sendETH and sendERC20 and transfer all eth and other ERC20 tokens to himself.

Tools Used

Manual Review

Recommendations

Add this check in inherit to make sure msg.sender is the beneficiary.

function inherit() external {
if (block.timestamp < getDeadline()) {
revert InactivityPeriodNotLongEnough();
}
if (beneficiaries.length == 1) {
+++ require(beneficiaires[0] == msg.sender, "Naughty boi");
owner = msg.sender;
_setDeadline();
} else if (beneficiaries.length > 1) {
isInherited = true;
} else {
revert InvalidBeneficiaries();
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 5 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Inherit depends on msg.sender so anyone can claim the contract

Support

FAQs

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