Project

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

Unchecked Token Transfer in MembershipFactory Contract Allows Silent Transaction Failures

Summary

The MembershipFactory contract relies on unchecked calls to transferFrom for ERC-20 token transfers, which may fail silently if a token does not revert on failure but instead returns false. This vulnerability allows transactions to appear successful even if no tokens are transferred, leading to potential loss or misallocation of funds. This oversight could create exploitable scenarios where required funds are not transferred as expected, compromising the contract’s intended operation and increasing risk for users.

Vulnerability Details

The MembershipFactory contract calls the transferFrom function directly on an IERC20 token, assuming that a failed transfer will throw an error. However, certain tokens do not revert when transfer or transferFrom operations fail, and instead, they return a false value. If these return values are not checked, the contract may believe the transfer was successful, even though no tokens were actually moved.

In this case, a malicious user could attempt to call functions that rely on these unchecked transfers, potentially gaining benefits without actually transferring any tokens. This can lead to operational inconsistencies and undermine the security of the token handling within the smart contract.

Affected Line of Code

Impact

Transaction failures without notification, leading to mismanaged user funds and disrupted functionality. This vulnerability is likely to be encountered, especially if users interact with tokens that do not revert on failed transfers. While some ERC-20 tokens follow a non-standard approach and return false on failure, it is impossible to ensure that all tokens used with the contract adhere to a revert-on-failure approach. This makes the unchecked transfer vulnerability a significant and likely threat.

Unchecked transfers introduce the following risks:

  1. Silent Transaction Failures: If the token transfer fails and returns false, the contract will not revert, and the transaction will appear successful to the user and the contract. This results in incomplete or invalid transfers without any notification, potentially affecting contract integrity and user trust.

  2. Misallocation of Funds: Certain functions may rely on these transfers to ensure funds are collected or redistributed as expected. If a transfer fails without detection, the contract logic could proceed based on the incorrect assumption that funds have been moved as required, leading to a breakdown in fund management.

  3. Exploitable Loophole: A malicious user could exploit this vulnerability to bypass payment requirements or obtain benefits from the contract without making the required token transfers, affecting the overall integrity and security of the platform.

Proof of Concept

If a user or attacker interacts with the contract using a token that does not revert on failed transfers, they could simulate a transfer call to bypass payments or required transfers:

  • A user calls a function in MembershipFactory that executes:

IERC20(daos[daoMembershipAddress].currency).transferFrom(_msgSender(), owpWallet, platformFees);
  • Suppose this transfer fails due to insufficient balance, but the token does not revert and instead returns false.

  • Without checking the return value, the contract considers the transfer successful, and the function proceeds, even though no funds have been transferred.

Tools Used

Manual Review

Recommendations

  • Implement Safe Transfers: Use OpenZeppelin’s SafeERC20 library, which includes safeTransfer and safeTransferFrom functions that check for success and revert on failure, ensuring funds are only considered transferred if successful.

Updated code:

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
using SafeERC20 for IERC20;
// Safe transfer function
IERC20(daos[daoMembershipAddress].currency).safeTransferFrom(_msgSender(), owpWallet, platformFees);
  • Ensure Robust Token Interaction: To prevent similar issues, ensure all external token interactions use SafeERC20’s safe methods, mitigating silent failures and improving the contract's security and reliability.

Implementing these changes will safeguard the contract against silent failures, ensuring all token transfers are securely handled and improving the contract’s overall resilience to user and token variability.

Updates

Lead Judging Commences

0xbrivan2 Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
0xbrivan2 Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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