Project

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

Reentrancy Risk in claimProfit of MembershipERC1155

Issue:

The claimProfit function in MembershipERC1155 involves an external call to transfer ERC20 tokens after updating state, exposing it to potential reentrancy.

Location:

  • File: MembershipERC1155.sol

  • Function: claimProfit

function claimProfit() external returns (uint256 profit) {
profit = saveProfit(msg.sender);
require(profit > 0, "No profit available");
savedProfit[msg.sender] = 0;
IERC20(currency).safeTransfer(msg.sender, profit);
emit Claim(msg.sender, profit);
}

Exploit :

An attacker could use a custom ERC20 token that re-enters claimProfit, allowing multiple claims for a single savedProfit value.

Impact:

This could lead to unauthorized profit claims and depletion of the profit pool.

Tools Used

Manual review.

Recommendation:

Add a reentrancy guard to claimProfit to prevent reentrant calls:

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
function claimProfit() external nonReentrant returns (uint256 profit) {
profit = saveProfit(msg.sender);
require(profit > 0, "No profit available");
savedProfit[msg.sender] = 0;
IERC20(currency).safeTransfer(msg.sender, profit);
emit Claim(msg.sender, profit);
}
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.