Boost creator can collect all the fees by setting referralFee to 9_000 and give claimants his address as referrer_ address
The boost creator could set a referral fee that, when added to the base fee, equals the fee denominator, so 100% of claim fees go to the referrer. By directing claimants to use the creator's address as referrer, the creator collects all fees and the protocol receives none.
0rpse Follow with 0xbranded, 0xdeadbeef and 15 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-06-boost-aa-wallet-judging/issues/158
Found by
0rpse, 0xbranded, 0xdeadbeef, 0xlookman, Atharv, Galturok, Pheonix, PranavGarg, Ragnarok, SyncCode2017, Trooper, dimulski, durov, ge6a, iamnmt, ke1caM, oxelmiguel, sakshamguruji
Summary
The boost creator can set the value of referralFee to 9_000 when creating the boost. The BoostCore::referralFee (the base fee) is set to 1000 in line 70,
and added to the boost creator input in line 122,
This will make the BoostCore::referralFee to be 10_000 (equal to the BoostCore::FEE_DENOMINATOR) ensuring that 100% of the fees collected when claimants claim their incentives are sent to the referrer address. To get the fees, the boost creator just need to ensure claimants use his address as referrer_ address. The protocol will never receive any fee for this particular boost.
Root Cause
Maximum value for BoostCore::referralFee was not set, allowing boost creators to allocate unlimited fraction of the fees to the referrer.
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
The protocol will receive no fees as all the fees will continuously be sent to the referrer_ address.
PoC
Please copy the code below into BoostCore.t.sol and run the test.
uint64 public constant boostAdditionalReferralFee = 9_000; // additional 90%
uint256 public constant PRECISION = 10_000;
uint256 public constant BASE_FEE = 1_000; // 10%
bytes invalidCreateCalldata =
LibZip.cdCompress(
abi.encode(
BoostCore.InitPayload({
budget: budget,
action: action,
validator: BoostLib.Target({
isBase: true,
instance: address(0),
parameters: ""
}),
allowList: allowList,
incentives: _makeIncentives(1),
protocolFee: 500, // 5%
referralFee: boostAdditionalReferralFee, // 90%
maxParticipants: 10_000,
owner: address(1)
})
)
);
function testClaimIncentive_ReferralTakesAllFees_audit() public {
uint256 claimFee = 0.000075 ether;
// Create a Boost first
boostCore.createBoost(invalidCreateCalldata);
// Mint an ERC721 token to the claimant (this contract)
uint256 tokenId = 1;
mockERC721.mint{value: 0.1 ether}(address(this));
mockERC721.mint{value: 0.1 ether}(address(this));
mockERC721.mint{value: 0.1 ether}(address(this));
// Prepare the data payload for validation
bytes memory data = abi.encode(address(this), abi.encode(tokenId));
address referralAddress = makeAddr("referral");
address protocolFeeReceiver = boostCore.protocolFeeReceiver();
uint256 initialProtocolFeeReceiverBalance = protocolFeeReceiver.balance;
// Claim the incentive
boostCore.claimIncentive{value: claimFee}(0, 0, referralAddress, data);
uint256 actualReferrerBalance = referralAddress.balance;
uint256 finalProtocolFeeReceiverBalance = protocolFeeReceiver.balance;
// check referral balance
assertEq(actualReferrerBalance, claimFee);
// check protocol fee receiver balance
assertEq(
(finalProtocolFeeReceiverBalance -
initialProtocolFeeReceiverBalance),
0
);
// Check the claims
BoostLib.Boost memory boost = boostCore.getBoost(0);
ERC20Incentive _incentive = ERC20Incentive(
address(boost.incentives[0])
);
assertEq(_incentive.claims(), 1);
}
Mitigation
Set a maximum value for BoostCore::referralFee and refactor BoostCore::createBoost as shown below.
+ uint64 public constant MAX_REFERRER_FEE = 5000; // should be any value below 10_000
function createBoost(bytes calldata data_)
external
canCreateBoost(msg.sender)
nonReentrant
returns (BoostLib.Boost memory)
{
InitPayload memory payload_ = abi.decode(data_.cdDecompress(), (InitPayload));
// Validate the Budget
_checkBudget(payload_.budget);
// Initialize the Boost
BoostLib.Boost storage boost = _boosts.push();
boost.owner = payload_.owner;
boost.budget = payload_.budget;
boost.protocolFee = protocolFee + payload_.protocolFee;
boost.referralFee = referralFee + payload_.referralFee;
+ require(boost.referralFee <= MAX_REFERRER_FEE, "referralFee is too high");
boost.maxParticipants = payload_.maxParticipants;
// Setup the Boost components
boost.action = AAction(_makeTarget(type(AAction).interfaceId, payload_.action, true));
boost.allowList = AAllowList(_makeTarget(type(AAllowList).interfaceId, payload_.allowList, true));
boost.incentives = _makeIncentives(payload_.incentives, payload_.budget);
boost.validator = AValidator(
payload_.validator.instance == address(0)
? boost.action.supportsInterface(type(AValidator).interfaceId) ? address(boost.action) : address(0)
: _makeTarget(type(AValidator).interfaceId, payload_.validator, true)
);
emit BoostCreated(
_boosts.length - 1,
boost.owner,
address(boost.action),
boost.incentives.length,
address(boost.validator),
address(boost.allowList),
address(boost.budget)
);
return boost;
}
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/boostxyz/boost-protocol/pull/197
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the contract did not enforce a maximum value for the referral fee, allowing the sum of the base fee and the creator-supplied referral fee to equal the fee denominator.
Impact
The protocol receives no fees for that boost, as all claim fees go to the referrer address.
What the attacker needed
Attacker is a boost creator; claimants use attacker's address as referrer
The fix
The protocol team fixed this issue by setting a maximum value for the referral fee.
How it was found
- Create a boost with a referral fee of 9,000, which adds to the base fee of 1,000 to reach 10,000.
- Have a claimant claim an incentive using the creator's address as the referrer.
- Observe that the entire claim fee goes to the referrer and the protocol fee receiver gets nothing.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A boost is a campaign where people claim rewards and pay a small fee. The fee is split between the protocol and a referrer, but the creator could set the referrer's share so high that the protocol's share became zero. The creator then told claimants to use the creator's own address as the referrer, so the creator got all the fees.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.