Summary
The BuyerAgent contract allows setting royaltyFee to 100%, which means the agent owner could capture 100% of all sale proceeds, leaving nothing for other stakeholders and potentially breaking the economic model of the system.
Vulnerability Details
The royalty fee validation allows fees up to 100%:
function setFeeRoyalty(uint96 _fee) public onlyOwner {
_checkRoundPhase(Phase.Withdraw);
if (_fee < 1 || _fee > 100) {
revert InvalidFee(_fee);
}
royaltyFee = _fee;
}
Similarly in the constructor:
constructor(
string memory _name,
string memory _description,
uint96 _royaltyFee,
uint256 _amountPerRound,
address _operator,
address _owner
) Ownable(_owner) {
if (_royaltyFee < 1 || _royaltyFee > 100) {
revert InvalidFee(_royaltyFee);
}
royaltyFee = _royaltyFee;
}
Impact
Agent owner can capture 100% of proceeds
Tools Used
Manual Review
Recommendations
Implement a reasonable maximum fee limit:
contract BuyerAgent {
uint96 public constant MAX_ROYALTY_FEE = 25;
function setFeeRoyalty(uint96 _fee) public onlyOwner {
_checkRoundPhase(Phase.Withdraw);
if (_fee < 1 || _fee > MAX_ROYALTY_FEE) {
revert InvalidFee(_fee);
}
royaltyFee = _fee;
}
constructor(
string memory _name,
string memory _description,
uint96 _royaltyFee,
uint256 _amountPerRound,
address _operator,
address _owner
) Ownable(_owner) {
if (_royaltyFee < 1 || _royaltyFee > MAX_ROYALTY_FEE) {
revert InvalidFee(_royaltyFee);
}
royaltyFee = _royaltyFee;
}
}