The BuyerAgent contract allows withdrawal operations outside of designated phases, breaking the core market cycle guarantees and enabling potential market manipulation.
withdraw() succeeds outside Withdraw phase: https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L262-L273
BuyerAgent.sol#function _checkRoundPhase: https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L287-L294
Inconsistent phase enforcement creates a vulnerability in the protocol's state machine.
Withdrawal function bypasses strict phase validation
Inconsistent usage of _checkRoundPhase across functions
Direct token transfers without complete phase checks
Consider this example
Users can withdraw funds during critical trading phases
Disrupts the intended Buy-Sell-Withdraw cycle
Creates timing advantages for sophisticated actors
Vs
Implement strict phase validation across all state-changing operations, explicit phase transition checks and events to track phase changes.
Consider implementing a time-delay mechanism for withdrawals to prevent flash loan attacks and market manipulation.
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.