The `Swan` contract lacks proper validation of `royaltyFee` when creating buyer agents and calculating fees in `transferRoyalties`. This oversight allows setting arbitrarily high royalty fees that could exceed 100% of the asset price, potentially leading to excessive fee collection and incorrect fund distribution. ## Vulnerability Details The vulnerability exists in two key areas: 1. **Missing Royalty Fee Validation in Buyer Creation**: ```solidity:Swan.sol function createBuyer( string calldata _name, string calldata _description, uint96 _feeRoyalty, uint256 _amountPerRound ) external returns (BuyerAgent) { // No validation of _feeRoyalty BuyerAgent agent = buyerAgentFactory.deploy(_name, _description, _feeRoyalty, _amountPerRound, msg.sender); emit BuyerCreated(msg.sender, address(agent)); return agent; }
Unsafe Fee Calculations in transferRoyalties
:
Attacker creates a buyer agent with royaltyFee = 200
(200%)
For an asset listed at 100 tokens:
buyerFee = (100 * 200) / 100 = 200 tokens
This already exceeds the original price
Platform fee calculation is then applied to the inflated amount:
If platformFee = 10
, then driaFee = (200 * 10) / 100 = 20 tokens
Result: Seller pays more in fees than the asset's price
Severity: High
Financial Impact:
Sellers could pay excessive fees exceeding asset prices
Incorrect distribution of funds between buyers and platform
Potential for economic manipulation of the marketplace
Trust & Usability:
Undermines the fairness of the fee system
Could deter legitimate sellers from using the platform
Reputation damage to the protocol
Manual code review
Static analysis
Mathematical validation of fee calculations
Add Fee Validation in Buyer Creation:
Add Safety Checks in Fee Calculations:
Consider Using Fixed-Point Arithmetic:
Implement a fixed-point math library for fee calculations
This would provide more precise fee calculations and prevent rounding errors
Add Events for Fee Transfers:
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.