Project

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

Reentrancy Vulnerability in joinDAO and upgradeTier Functions

Summary

The joinDAO and upgradeTier functions in the MembershipFactory contract are vulnerable to reentrancy attacks. This flaw occurs because the contract performs external calls to IERC20.transferFrom and IMembershipERC1155.mint or burn before updating its internal state. This allows malicious actors to exploit the contract by calling back into the contract during the execution of these external calls, leading to unauthorized token transfers, excessive minting, or even contract fund drainage.

Vulnerability

Details Location:

joinDAO(address daoMembershipAddress, uint256 tierIndex)

upgradeTier(address daoMembershipAddress, uint256 fromTierIndex)

Issue:

In both of these functions, external calls are made to transfer tokens and mint/burn membership NFTs before updating the state variables. This can lead to a reentrancy attack, where an attacker could:

1. Drain the contract’s funds by calling back into the contract during the transfer of platform fees or DAO fees.

2. Mint extra tokens by exploiting the minting logic in the joinDAO function, gaining more DAO memberships than intended.

3. Bypass tier upgrade restrictions by reentering the contract during the minting process, resulting in unauthorized tier changes.

Technical Breakdown:

1. In the joinDAO function:

External calls to IERC20.transferFrom are made before updating the state (minted for the tier).

This opens the possibility for a reentrancy attack where an attacker could call back into the contract and alter the state (e.g., increase the minted count) before the contract proceeds to the next logic.

2. In the upgradeTier function:

External calls to IMembershipERC1155.burn and IMembershipERC1155.mint are made before updating the internal state.

A reentrancy attack could manipulate the burning/minting sequence, potentially leading to minting tokens in a tier that should not be available or manipulating balances.

Impact

An attacker could exploit this vulnerability to:

1. Steal Funds: By triggering reentrancy in the IERC20.transferFrom calls, an attacker could drain the contract’s fees, including platform fees or DAO contributions.

2. Create Fake DAO Memberships: By reentering during the minting process, attackers could mint additional DAO membership tokens beyond the limits, altering DAO governance and ownership.

3. Disrupt DAO Operations: Attacks on tier upgrades could undermine the integrity of DAO memberships and voting systems, causing financial and governance disruption.

Exploitation Scenario:

Exploit Attack Flow:

1. An attacker calls joinDAO with a valid membership DAO address.

2. The contract performs the IERC20.transferFrom operation, transferring tokens to the platform wallet.

3. The attacker then re-enters the contract before the state variable (like minted counter) is updated, allowing them to mint additional tokens beyond the allowed tier amount.

4. The attacker effectively bypasses the membership and tier limits, gaining an unfair advantage.

Tools Used Manual Code Review: The vulnerability was identified through a detailed inspection of the MembershipFactory.sol contract and its associated functions.

Solidity Static Analysis: Tools like Slither or Mythril can help identify reentrancy vulnerabilities and unsafe external call patterns.

Recommendations

1. Implement Reentrancy Guards: Use the nonReentrant modifier from OpenZeppelin or re-order the logic to follow the "Checks-Effects-Interactions" pattern.

First, update the internal state (e.g., minted counters).

Then, perform external calls like transferring tokens or minting.

2. Audit External Calls: Avoid making external calls (such as IERC20.transferFrom) before updating state variables. This mitigates the risk of reentrancy.

3. Increase Token Validity Checks: Ensure that all tokens are verified as ERC20-compliant before any transaction to prevent invalid contract interactions.

4. Role-based Access Control: Ensure that only trusted addresses with appropriate roles (like EXTERNAL_CALLER) can initiate external contract calls.

5. State Updates Before External Calls: For any operation involving external transfers or interactions, the internal state should be updated before any external call or token transfer to ensure data integrity.

Recommendation for Submission:

Severity: High

Impact: Serious, with potential financial loss and governance disruption.

Fix Priority: Urgent, as it directly affects the financial integrity of the project and user trust.

Updates

Lead Judging Commences

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

Support

FAQs

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