Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

Insecure Implementation of quitTheGang Function in The Laundrette Contract

Summary

The quitTheGang function in The Laundrette contract is intended to allow gang members to exit the mafia. However, it is vulnerable to abuse by malicious gang members who can use it to forcibly remove other members from the mafia. This is due to the lack of a proper validation check to ensure that the account being removed is the same as the msg.sender.

Vulnerability Details

Function: quitTheGang

Issue: The function allows any gang member to specify an account to be removed without verifying that the specified account is the msg.sender.

Missing Check: The function should include a check to ensure that the account parameter is the same as the msg.sender.

Impact

Unauthorized Removal: Malicious gang members can remove other gang members without their consent, leading to potential disruption and loss of membership.

Trust Issues: The ability for unauthorized removal can lead to trust issues within the gang and compromise the integrity of the mafia's operations.

Proof of Concept

  1. Godfather adds new gang members

  2. gang member call the quitTheGang method and adds another gang member account

Proof of Code

function test_removeGang() public {
address add1 = makeAddr("add1");
address add2 = makeAddr("add2");
vm.prank(godFather);
laundrette.addToTheGang(add1);
vm.prank(godFather);
laundrette.addToTheGang(add2);
vm.prank(add2);
laundrette.quitTheGang(add1);
}

Tools Used

Manual Review

Recommendations

Implement a Sender Check: Modify the quitTheGang function to include a check that ensures only the msg.sender can initiate their own removal.

function quitTheGang(address account) external onlyRole("gangmember") {
+ require(account == msg.sender, "You can only remove yourself from the gang");
kernel.revokeRole(Role.wrap("gangmember"), account);
}
Updates

Lead Judging Commences

n0kto Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Gang members ban other members

Support

FAQs

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