The BuyerAgent contract's oracle integration system allows unauthorized state manipulation through improper access control in oracle request processing. The vulnerability stems from missing validation between oracle task requests and their processing, allowing potential manipulation of purchase decisions and state updates.
function oracleResult: https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L158-L165
function purchase: https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L222-L234
The core issue lies in how oracle requests are processed and validated.
The onlyAuthorized modifier implementation in BuyerAgent.sol: https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/BuyerAgent.sol#L105-L111
The onlyAuthorized modifier checks:
If sender is an operator via swan.isOperator()
If sender is the owner
The bug occurs because Swan's address is checked through isOperator() rather than having a dedicated check for the Swan contract address itself
This creates a scenario where Swan could lose operator status but still need direct access to these critical functions
The access control logic that governs critical functions, purchase() and updateState(). The current implementation creates a dependency between Swan's access rights and its operator status, which violates the protocol's core security assumptions.
Key risks:
Protocol functionality can break if Swan loses operator status
Core market operations could be interrupted
Violates principle of least privilege by coupling different access control mechanisms
Consider this POC
Unauthorized parties can influence purchase decisions
State manipulation across trading rounds
This ensures Swan maintains direct access regardless of operator status, properly separating protocol-level and administrative access controls.
These changes ensure proper validation of oracle task ownership and request origins, maintaining the integrity of the autonomous buying system.
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.