The list
function in Swan.sol
uses an incorrect comparison operator when checking the asset count limit, allowing more assets to be listed than the current market parameters allow.
In the list function, the check for maximum asset count uses ==
instead of <=
:
If the owner updates market parameters with a lower maxAssetCount
than previously set, new listings can still be created even when the current count exceeds the new limit.
Example:
Initial market parameters set maxAssetCount = 3
Buyer is listed with 2 assets successfully (assetsPerBuyerRound[_buyer][round].length = 2
)
Owner updates market parameters with maxAssetCount = 1
Buyer can still be listed with another asset since 2 == 1
is false, even though 2 >= 1
would be true
Result: Buyer is listed with 3 assets when the current limit is 1
Unlimited listing of buyer per round
Manual Review
Recommendations Replace the equality check with a greater-than-or-equal comparison:
This ensures the asset count never exceeds the current market parameter limit, even after parameter updates.
SwanManager::setMarketParameters pushes the new parameters `marketParameters.push(_marketParameters);` After that, when user calls list the protocol computes the round and the phase `(uint256 round, BuyerAgent.Phase phase,) = buyer.getRoundPhase();` Inside the getRoundPhase function you have this if statement on top: `if (marketParams.length == marketParameterIdx + 1) {`. The setMarketParameters call changed the `marketParams` length, thing which will case the first case to be false and run the else statement. At the end of that statement we see there is a new round. So the second element of this check `(getCurrentMarketParameters().maxAssetCount == assetsPerBuyerRound[_buyer][round].length` is zero, because the [round] is fresh.
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.