The NFT Dealers protocol uses a progressive fee structure: 1% for prices ≤1000 USDC, 3% for prices ≤10000 USDC, and 5% for prices >10000 USDC. The calculateFees() function was added to help with testing and debugging.
However, calculateFees() was left public in production. This allows any user to query exact fee amounts before listing, enabling them to game the fee threshold system. Users can find the optimal price points that minimize fees while maximizing proceeds. The function comment even states it "must be removed before production deployment" but was forgotten.
Likelihood:
This occurs whenever users call calculateFees() before listing to optimize their price
The function is publicly accessible with no restrictions - anyone can call it
Impact:
Users can game fee threshold system to minimize protocol fees
Protocol loses revenue as users cluster just below fee boundaries
The following PoC demonstrates that anyone can call calculateFees() to query exact fee amounts before listing. This allows users to find optimal price points that minimize fees.
The comprehensive test suite below validates the vulnerability across three scenarios: (1) Users can calculate exact fees before listing, (2) Fee structure information leak allows threshold detection, (3) Function should be removed before production. All tests pass and confirm the vulnerability.
The fix removes the calculateFees() function entirely or changes it to internal only. This prevents users from querying fee amounts before listing.
Mitigation Explanation: The fix addresses the root cause by: (1) Removing the public calculateFees() function entirely, preventing users from querying exact fee amounts before listing, (2) Keeping _calculateFees() as internal only for use within the contract, (3) This prevents users from gaming the fee threshold system by finding optimal price points, (4) Alternatively, if transparency is desired, the function could be kept but the comment should be updated to reflect intentional design rather than "must be removed", (5) Removing test-only functions before production is a security best practice that reduces attack surface.
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.
The contest is complete and the rewards are being distributed.