Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

L-01. Missing validation for address(0) when adding gang member.

Summary

The function Laundrette::addToTheGang allows adding a member with address(0).

Vulnerability Details

The function Laundrette::addToTheGang allows adding a member with address(0).
This means that the user associated with this address won't be able to withdraw funds and the state will hold data of a user with non-existent address - address(0).
However, GodFather can still take or move the funds.

Impact

Keeps track of user which address is non-existent - address(0).

Tools Used

Manual Review

Recommendations

Add check for address(0) inside the function Laundrette::addToTheGang and revert if such address is passed.

function addToTheGang(address account) external onlyRole("gangmember") isGodFather {
+ if (account == address(0)) {
+ revert("Address 0 is not allowed");
+ }
kernel.grantRole(Role.wrap("gangmember"), account);
}

Proof Of Concept

  1. Add the following test case to test/LaundretteTest

function test_canAddAddressZero() public {
vm.deal(godFather, 1000e6);
address user = makeAddr("user");
vm.prank(godFather);
joinGang(user); // Setup gang with godfather and some user.
assertEq(kernel.hasRole(address(0), Role.wrap("gangmember")), false);
vm.prank(godFather);
laundrette.addToTheGang(address(0));
assertEq(kernel.hasRole(address(0), Role.wrap("gangmember")), true);
}
  1. Test by running the command: forge test --mt test_canAddAddressZero

Updates

Lead Judging Commences

n0kto Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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