The MembershipFactory contract allows users to join any available Membership within a specific tier by purchasing a Membership NFT at the tier’s listed price. However, users can exploit an oversight in the protocol to purchase a SPONSORED DAO Membership at a significantly reduced price. They can then upgrade to a higher-tier Membership NFT, which is more expensive, by paying only a small additional amount. This loophole creates a vulnerability in the protocol, enabling users to bypass the intended functionality and potentially disrupt its balance, with cheaper tiers becoming inactive while expensive tiers receive undue activity.
Here’s where the issue resides:
MembershipFactory::joinDAO:
MembershipFactory::upgradeTier:
This oversight allows users to manipulate the protocol and obtain an expensive Membership tier NFT for a fraction of the intended price. Below is a step-by-step example of how this exploit can be executed:
The NFT price for tier index 6 is 200.
The NFT price for tier index 5 is 1000.
Alice purchases the Membership NFT of type SPONSORED at tier index 6 for 200.
Alice identifies the loophole and plans to exploit it to obtain a more expensive NFT.
Alice purchases the Membership NFT for tier index 6 again.
Now, Alice has two NFTs of tier index 6, worth a total of 400.
Alice upgrades from tier index 6 to tier index 5, and for a small additional cost, she now holds a Membership NFT worth 1000.
This scenario demonstrates how users can bypass the intended pricing structure and upgrade to a higher-tier Membership NFT at a significantly lower cost.
The following test case proves the existence of this vulnerability by simulating the behavior in code:
Convert the project to a Foundry-based structure.
Install all necessary dependencies.
Configure remappings as required.
Create a test file MembershipERC1155Test.sol in the test folder.
Add the following code to MembershipERC1155Test.sol:
Create a mock directory within the test folder.
Inside the mock folder, add the files CurrencyMock.sol and OWPWalletMock.sol.
Implement the necessary mock contracts in these files to simulate the protocol’s behavior.
Open a terminal and run the following command to execute the test:
Review the test logs:
As demonstrated by the test case, users can indeed exploit the oversight to upgrade to an expensive Membership NFT without paying the full price, potentially destabilizing the protocol’s pricing structure.
Users can acquire expensive Membership NFTs at a fraction of their intended cost, disrupting the expected functionality of the protocol.
This manipulation undermines the integrity of the tiered Membership system, making cheaper tiers inactive while overburdening more expensive tiers with disproportionate activity.
Users may take advantage of this loophole to artificially inflate their Membership value without making the full financial commitment.
Manual review, Foundry
Implement stricter checks and balances for upgrading between tiers, including tracking the excess or shortfall in payments during upgrades.
Ensure that users are charged or refunded the correct amount for any discrepancies between the price of the NFT and platform fees when upgrading.
Consider adding a mechanism to prevent users from accumulating multiple NFTs in the same tier if they intend to upgrade, or penalize users who attempt to exploit this behavior.
By addressing these vulnerabilities, the protocol can be secured against potential abuses, preserving its intended functionality and the stability of the tiered pricing structure.
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.