The BuyerAgent contract's withdrawal mechanism allows complete drainage of funds during the Withdraw phase by bypassing minimum fund requirements. This creates a vulnerability where the contract can be left with insufficient funds for oracle operations and purchases in subsequent rounds.
The withdraw function only enforces minimum fund requirements during non-Withdraw phases:
The minFundAmount is critical as it covers:
Required funds for next round purchases (amountPerRound)
Oracle fees for LLM operations
Operational costs for the buying cycle
The withdraw function conditionally checks the minimum fund requirement only for non-Withdraw phases. This creates a loophole where users can drain the contract below the required minimum during Withdraw phase: #L267-L271: https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L267-L271
Withdraw#L262-L271: https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L262-L271
During Withdraw phase, the function allows withdrawing funds below minFundAmount
minFundAmount is critical as it covers:
amountPerRound for purchases
oracle fees for next round operations
When next Buy phase starts, the contract will be unable to:
Pay for oracle requests
Execute purchases
Maintain normal buying cycle
This breaks the core autonomous buying functionality
The vulnerability creates a systemic risk where a single withdrawal during Withdraw phase can disrupt the entire buying cycle for subsequent rounds.
POC
Protocol Operation Failure
Oracle requests fail due to insufficient fees
Purchase transactions revert from lack of funds
Buying cycle breaks in subsequent rounds
Economic Impact
Disrupts market participation
Breaks autonomous buying functionality
Affects protocol reliability
Enforce minimum fund requirements across all phases to maintain protocol functionality and prevent operational disruption. Consider adding additional safety checks:
Maximum withdrawal limits per round
Time-based withdrawal restrictions
Emergency pause mechanism for large withdrawals
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.