Project

One World
NFTDeFi
15,000 USDC
View results
Submission Details
Severity: medium
Invalid

Reentrancy Vulnerability in MembershipFactory Contract with Arbitrary External Calls

Summary

https://github.com/Cyfrin/2024-11-one-world/blob/1e872c7ab393c380010a507398d4b4caca1ae32b/contracts/dao/MembershipFactory.sol#L176
When a contract call is made via callExternalContract, the external contract's code is executed with the same gas allowance, which can result in reentrancy — a condition where the external contract calls back into the MembershipFactory contract, potentially before the initial call finishes executing.

Vulnerability Details

function callExternalContract(address contractAddress, bytes memory data) external payable onlyRole(EXTERNAL_CALLER) returns (bytes memory ) {
(bool success, bytes memory returndata) = contractAddress.call{value: msg.value}(data);
require(success, "External call failed");
return returndata;
}

In this code, the function callExternalContract makes a low-level call to the specified contractAddress using the call method. The call method forwards all available gas to the target contract, meaning that the target contract can potentially reenter the MembershipFactory contract if it calls any functions within it during its execution.

This leaves the MembershipFactory contract vulnerable to reentrancy attacks. Since there is no mechanism to restrict the flow or manage gas usage, an attacker could manipulate the contract by invoking it recursively, causing unintended consequences.

Impact

If the attacker is able to manipulate state variables like membership tiers or role assignments during a reentrant call, they could bypass logic that governs permissions causing significant disruptions to the system

Tools Used

Manual review

Recommendations

Implement a reentrancy guard (e.g., OpenZeppelin’s ReentrancyGuard) in all functions that interact with external contracts.

Updates

Lead Judging Commences

0xbrivan2 Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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