The purchase()
function in Swan.sol is vulnerable to reentrancy attacks through multiple external calls, enabling asset theft and payment manipulation.
State changes occur before external calls, violating CEI pattern
Multiple external calls to potentially untrusted contracts (ERC20/ERC721)
No reentrancy guard protection
An attacker could:
Create malicious token contracts that reenter on transfer
Manipulate listing states during reentrant calls
Execute multiple purchases of the same asset
Drain funds through double spending
Manipulate asset ownership through reentrancy during transfers
It is particularly severe since Swan handles both asset transfers and payments, making it an attractive target for reentrancy attacks targeting either token transfers or payments.
Proof of Concept:
Attacker creates malicious ERC20/ERC721 contract that reenters on transfer
Calls purchase()
which triggers the malicious reentrant call
State can be manipulated before it's finalized
Double purchases of same asset
Token payment manipulation
Asset ownership manipulation
Fund drainage through repeated calls
Manual Review
Alternatively:
Implement pull-over-push pattern for payments
Add timelock mechanism for large transactions
Implement strict asset validation checks
Add transaction value caps
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.