Strategists can take more rewards than they should using the function strategistBootyClaim().
The strategist reward claim function could be called with the same asset passed as both the asset and quote parameters, causing the reward accounting to be applied twice for one asset. A malicious strategist could therefore claim more rewards than they were owed, and a reentrancy path was also possible because state was updated after the transfer.
Originally disclosed on Code4rena
Submitted by hansfriese, also found by oyc109, xiaoming90, kenzo, Kumpa, unforgiven, MiloTruck, and pauliax_
Strategists can take more rewards than they should using the function strategistBootyClaim(). Even though the owner trusts strategists fully I think it’s recommended to remove such flaws.
I think there would be 2 methods to claim more rewards.
Proof of Concept
Method 1.
A strategist can call the function using same asset/quote parameters.
Then both of fillCountA and fillCountQ will be same positive values.
The first code block for fillCountA(L597-L610) will work same as expected but the second block for fillCountQ(L611-L624) will be executed for the same asset again.
Two mappings(totalFillsPerAsset, strategist2Fills) that save rewards will be updated for asset already after the first block but totalFillsPerAsset and balance of this contract for quote would be still positive as there would be remaining rewards for other strategiets.
So the strategist can get paid once more for the same asset.
Method 2.
I think a reentrancy attack is possible also because two mappings are updated after transfer funds.
Tools Used
Solidity Visual Developer of VSCode
Recommended Mitigation Steps
Method 1.
You can add this require() at the beginning of function.(L595) require(asset != quote, “asset = quote”);
Method 2.
You can update the state of 2 mappings before transfer. Move L608-L609 to L601 Move L622-L623 to L615
So final code will look like this.(pseudocode)
function strategistBootyClaim(address asset, address quote) external onlyApprovedStrategist(msg.sender) { require(asset != quote, “asset = quote”);
uint256 fillCountA = strategist2Fills[msg.sender][asset];
uint256 fillCountQ = strategist2Fills[msg.sender][quote];
if (fillCountA > 0) {
uint256 booty = (
fillCountA.mul(IERC20(asset).balanceOf(address(this)))
).div(totalFillsPerAsset[asset]);
totalFillsPerAsset[asset] -= fillCountA;
strategist2Fills[msg.sender][asset] -= fillCountA;
IERC20(asset).transfer(msg.sender, booty);
emit LogStrategistRewardClaim(
msg.sender,
asset,
booty,
block.timestamp
);
}
if (fillCountQ > 0) {
uint256 booty = (
fillCountQ.mul(IERC20(quote).balanceOf(address(this)))
).div(totalFillsPerAsset[quote]);
totalFillsPerAsset[quote] -= fillCountQ;
strategist2Fills[msg.sender][quote] -= fillCountQ;
IERC20(quote).transfer(msg.sender, booty);
emit LogStrategistRewardClaim(
msg.sender,
quote,
booty,
block.timestamp
);
}
}
KenzoAgada (warden) commented:
Mentions 2 different attack paths, should probably be split: Method1 is duplicate of #238. Method2 is duplicate of #451.
I’m making this the primary issue for centralisation risks involving strategists.
The rationale for lumping them together is that centralisation risk has been acknowledged by the sponsor, and is mentioned in their whitepaper. While this issue (and those that are grouped) mention various attack paths, they are all reliant on the strategist being malicious. The justification for the medium severity is that strategists are a larger group than the admin, so the likelihood and risk of an attack is greater.
That being said, the recommended fixes for the issues highlighted should be adopted to make the system more trust-less and secure.
As per my reasoning in #344, this will be made the grouped primary issues for the 2 attack vectors (see rulebook’s grouping of similar issues).
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 function did not require the asset and quote arguments to differ, and it updated the reward mappings only after transferring funds.
Impact
A malicious strategist could drain more of the contract's reward balance than they are entitled to, and the reentrancy path could allow repeated claims; the report notes the owner already trusts strategists, and the judge rated it medium because strategists are a larger group than the admin.
What the attacker needed
Approved strategist role; contract holds reward balance
The fix
The report recommends requiring that asset and quote differ, and moving the mapping updates before the token transfers; the sponsor confirmed the issue.
How it was found
- Call the reward claim function as an approved strategist, passing the same token as both the asset and the quote.
- Observe that the first reward block runs and updates the accounting for that token.
- Observe that the second reward block then runs again for the same token because the contract still holds a positive balance and total fills.
- Receive a second payout for the same asset.
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 strategist is a trusted role that earns a share of fees for the trades they route. The claim function was meant to pay out rewards for two different tokens, but nothing stopped the same token being given for both slots, so the payout logic ran twice. A second issue was that the contract sent the money before recording that the reward had been claimed, which lets a recipient call back in and claim again.
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.