The quitTheGang
function is problematic because it allows any user with the gangmember
role to revoke the role from any account, not just themselves. This can lead to unauthorized role revocation, potentially disrupting the intended access control.
The quitTheGang
function can be called with any account as an argument instead of limiting the action to msg.sender. The function allows specifying an arbitrary account for role revocation, rather than restricting the revocation to the caller msg.sender
.
Copy the following code into Laundrette.t.sol
and then run the test:
This vulnerability permits any user with the "gangmember" role to revoke the "gangmember" role from any other account. This undermines the access control mechanism, allowing malicious users to disrupt the system by removing other users' roles without authorization.
forge test
There are two possible solutions to solve this issue I'd prefer number one, because the godfather has still control in this case:
Remove the onlyRole("gangmember")
modifier and add the isAuthorizedOrRevert(account)
modifier.
The modifier isAuthorizedOrRevert
checks if the address is equal to msg.sender or if the msg.sender is the executor (godfather). We don't need the onlyRole("gangmember")
anymore because the Kernel::grantRole
function checks this anyways.
Restrict the quitTheGang
function to only allow msg.sender
to revoke their own role, but then the godfather can't call this function anymore.
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.