The BuyerAgent's purchase mechanism allows temporary violation of spending limits during batch purchases. The spending validation occurs after state changes, enabling the total round spending to exceed amountPerRound before the transaction reverts, potentially compromising the protocol's economic guarantees.
The purchase function processes multiple assets in a loop, incrementing the round's total spending before validating limits. This "check-after-act" pattern creates a window where spending can exceed defined limits: https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L222-L256
Where the total spending for a round can temporarily exceed the amountPerRound limit during batch purchases. The spending check occurs after incrementing the round's total spending, allowing the contract state to temporarily violate its core invariant.
It violates the core spending limit invariant that protects the protocol's economic model
The spending check occurring after increment creates a race condition where multiple assets can be processed before the limit check triggers
While the transaction ultimately reverts, the temporary violation of spending limits could be exploited in cross-contract interactions
The oracle-driven nature means malicious oracle responses could deliberately trigger this condition
Future protocol upgrades or integrations might rely on the spending limit invariant being maintained at all times, not just at transaction boundaries
Assume this POC test.
Violates core protocol invariant of spending limits
Creates potential attack vectors in cross-contract interactions
Consider this remediation
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.