Critical value conservation violation in Swan's purchase mechanism where sellers receive excess funds due to unaccounted royalty fees.
Looking at the purchase()
function in Swan.sol
, there is a value leakage issue: https://github.com/Cyfrin/2024-10-swan-dria/blob/c3f6f027ed51dd31f60b224506de2bc847243eb7/contracts/swan/Swan.sol#L276-L302
The bug is when transferring funds:
The full listing price is transferred from the buyer to the Swan contract
The same full amount is transferred to the seller
However, the royalty fees that were collected earlier in transferRoyalties()
are not accounted for
This means the seller receives the full price even though royalty fees were already deducted, creating a value conservation violation where:
This vulnerability creates a value conservation violation in the protocol's economic model:
During listing, sellers pay royalty fees through transferRoyalties()
During purchase, they receive the full listing price without fee deduction
This leads to overpayment where sellers effectively get refunded their royalty fees
The impact is significant because:
It breaks the protocol's fee collection mechanism
Creates unfair economic advantage for sellers
Violates the core value conservation invariant proven by Certora
Scales with listing price and number of transactions
PoC
This vulnerability is particularly dangerous because:
It systematically drains protocol fees
Scales proportionally with listing prices
Affects every purchase transaction
Creates unfair economic advantage for sellers
Violates core protocol invariants
The issue connects directly to Swan's core marketplace functions and fee collection mechanism, making it a critical vulnerability requiring immediate attention.
The contract fails to account for previously collected royalty fees during the purchase flow. This connects to two key functions:
transferRoyalties()
- Collects fees during listing
purchase()
- Transfers full amount without fee adjustment
Sellers receive more than intended (listing price + refunded royalties)
Protocol loses fee revenue
Value Conservation Invariant Testing
Alternatively:
Implement royalty tracking per listing
Add fee accounting system
Consider implementing escrow mechanism for fees
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.