The lack of validation for zero tier prices in the joinDAO
function creates a critical vulnerability where a division by zero could occur during the platform fees calculation. This could lead to transaction reverts and denial of service for legitimate membership purchases. More significantly, if the tier price is zero and the platform fee calculation doesn't revert (due to compiler optimizations or future solidity versions handling division by zero differently), users could potentially join tiers without paying the required fees, leading to financial losses for the protocol and disruption of the DAO's economic model.
The issue stems from the direct usage of the tier price in fee calculations without prior validation. The function retrieves the tier price from storage and immediately uses it in arithmetic operations without ensuring its value is greater than zero. In Solidity, division operations with zero can lead to unexpected behavior and transaction reverts, making certain tiers completely inaccessible even if they were meant to be free. This becomes particularly problematic in scenarios where tier prices are managed through external admin functions or could be set to zero due to contract upgrades or initialization issues.
https://github.com/Cyfrin/2024-11-one-world/blob/main/contracts/dao/MembershipFactory.sol#L140
Implement a proper validation check for the tier price before performing any calculations. If free tiers are intended to be supported, handle them with a specific condition:
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.