Add members to the not yet created community #298
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
old-submission-method
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
valid
Lines of code
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Community.sol#L187
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Community.sol#L179
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/Community.sol#L878
https://github.com/code-423n4/2022-08-rigor/blob/main/contracts/libraries/SignatureDecoder.sol#L39
Vulnerability details
Impact
There is a
addMember
function in theCommunity
. The function accepts_data
that should be signed by the_community.owner
and_newMemberAddr
.The code above shows exactly what the contract logic looks like.
_communityID
is taken from the data provided by user, so it can arbitrarily. Specifically, community with selected_communityID
can be not yet created. For instance, it can be equal to thecommunityCount + 1
, thus the next created community will have this_communityID
._communities[_communityID]
will store null values for all fields, for a selected_communityID
. That means,_community.owner == address(0)
checkSignatureValidity
with a parametersaddress(0), _hash, _signature, 0
will not revert a call if an attacker provide incorrect_signature
.let's see the implementation of
checkSignatureValidity
:No restrictions on
_recoveredSignature
or_address
. Moreover, ifSignatureDecoder.recoverKey
can return zero value, then there will be no revert.As we can see bellow,
recoverKey
function can return zero value, if anecrecover
return zero value or ifv != 27 || v != 28
. Both cases are completely dependent on the input parameters to the function, namely fromsignature
that is provided by attacker.checkSignatureValidity(_newMemberAddr, _hash, _signature, 1)
will not revert the call if an attacker provide correct signature in the function. It is obviously possible.All in all, an attacker can add as many members as they want, BEFORE the
community
will be created.Tools Used
Recommended Mitigation Steps
checkSignatureValidity
/recoverKey
should revert the call if anaddress == 0
.addMember
should have arequire(_communityId <= communityCount)
The text was updated successfully, but these errors were encountered: