For some ERC20 tokens, the transferFrom function will return false on failure instead of reverting the transaction. In MembershipFactory contract, the joinDAO method transfers tokens from the user by using transferFrom without any additional checks after the transfer is completed. Due to this, despite the failure transfer, attackers can still join the DAO without transferring any tokens to the owpWallet and daoMembershipAddress.
The joinDAO method in MembershipFactory invokes transferFrom function to transfer tokens from the user to owpWallet and daoMembershipAddress, without any further checking to ensure that the transfer is successful
https://github.com/Cyfrin/2024-11-one-world/blob/main/contracts/dao/MembershipFactory.sol#L146-L147
In case the transferFrom return false on failure instead of reverting for certain tokens, the remaining logic (mint & event emitting) continues to be executed, and the user will still have the Membership NFT without supplying any amount of tokens.
Currently, the One World Project supports 3 tokens: USDC, WETH and WBTC. Although the 3 tokens will all revert on failure, USDC is a token that can be upgradable, so it's logic can be changed at any point of time, and therefore there's a chance that it may break the token transfer flow in joinDAO. This is also a problem to consider if the protocol intends to support more tokens in the future.
A brief PoC is shown below:
Create a new WeirdToken.sol file under contracts/shared folder and add the following code
Also, create a new JoinDAOTest.test.ts file under test folder and add the following code
Run npx hardhat test
Attackers can join the DAO without transferring any tokens to the owpWallet and daoMembershipAddress.
Manual Review
Consider using SafeERC20 library from OpenZeppelin for IERC20, as you did with MembershipERC1155.sol, then using safeTransferFrom instead of transferFrom.
Alternatively, you could check the boolean return value of the transfer operation. However, it is worth noting that some tokens do not return a boolean, so using the SafeERC20 library may still be a more robust approach.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.