Protocol Fee Multiple Accrual in Oracle.submitReports
The Oracle.submitReports function processes multiple asset reports in one transaction, but the fee calculation uses the last stored timestamp which is only updated for the base asset. When non-base assets are processed before the base asset, each report accrues protocol fees based on the same old timestamp, leading to excessive fees being charged.
Source: https://github.com/sherlock-audit/2025-07-mellow-flexible-vaults-judging/issues/167
Found by
0x23r0, 0xc0ffEE, 7, Etherking, ZanyBonzy, blockace, evta, lodelux, silver_eth
Summary
The Oracle.submitReports function processes multiple asset reports in a single transaction, but the ShareModule.handleReport function calculates and accrues protocol fees for each report individually without considering that the timestamp should only be updated once per batch. This leads to multiple fee accruals when non-base assets are processed before the base asset, resulting in excessive protocol fees being charged.
Root Cause
The issue stems from the interaction between Oracle.submitReports and ShareModule.handleReport. In ShareModule.handleReport, the fee calculation uses the current timestamp and the last stored timestamp to calculate protocol fees:
// In ShareModule.handleReport (lines 281-283)
uint256 fees = feeManager_.calculateFee(address(this), asset, priceD18, shareManager_.totalShares());
if (fees != 0) {
shareManager_.mint(feeManager_.feeRecipient(), fees);
}
The FeeManager.calculateFee function calculates protocol fees based on the time difference:
// In FeeManager.calculateFee (lines 81-83)
uint256 timestamp = $.timestamps[vault];
if (timestamp != 0 && block.timestamp > timestamp) {
shares += Math.mulDiv(totalShares, $.protocolFeeD6 * (block.timestamp - timestamp), 365e6 days);
}
However, FeeManager.updateState only updates the timestamp when the asset is the base asset:
// In FeeManager.updateState (lines 116-128)
function updateState(address asset, uint256 priceD18) external {
FeeManagerStorage storage $ = _feeManagerStorage();
address vault = _msgSender();
if ($.baseAsset[vault] != asset) {
return; // Early return for non-base assets
}
// ... update minPriceD18 and timestamp
$.timestamps[vault] = block.timestamp;
}
When multiple reports are submitted in Oracle.submitReports, if the first reports are for non-base assets, the timestamp remains unchanged, causing each subsequent report to calculate fees based on the same old timestamp, leading to multiple fee accruals.
Internal Pre-conditions
- The vault must support multiple assets with one designated as the base asset
- The
Oracle.submitReportsfunction must be called with multiple reports in a single transaction - The first reports in the batch must be for non-base assets
- The base asset report must appear later in the batch
- Protocol fees must be configured (protocolFeeD6 > 0)
- Time must have passed since the last timestamp update (block.timestamp > lastTimestamp)
External Pre-conditions
.
Attack Path
- Setup: Configure a vault with multiple assets where one is designated as the base asset
- Initial State: Set protocol fees and ensure time has passed since the last timestamp update
- Submit Reports: Call
Oracle.submitReportswith multiple reports where non-base assets appear first - First Report Processing:
ShareModule.handleReportis called for the first non-base assetFeeManager.calculateFeecalculates protocol fees based on old timestamp- Fees are minted to the fee recipient
FeeManager.updateStateis called but returns early (not base asset)
- Subsequent Reports: For each additional report before the base asset:
FeeManager.calculateFeeuses the same old timestamp- Additional fees are calculated and minted
FeeManager.updateStatecontinues to return early
- Base Asset Report: When the base asset report is processed:
- Fees are calculated again using the old timestamp
FeeManager.updateStatefinally updates the timestamp
- Result: Multiple fee accruals have occurred, with fees being charged multiple times for the same time period
Impact
This vulnerability allows excessive protocol fees to be charged when multiple asset reports are submitted in a single transaction.
PoC
function testMultipleTimesFee() external {
Deployment memory deployment = createVault(vaultAdmin, vaultProxyAdmin, assetsDefault);
Oracle oracle = deployment.oracle;
address asset = assetsDefault[0];
vm.startPrank(vaultAdmin);
deployment.feeManager.setFeeRecipient(vaultAdmin);
deployment.feeManager.setFees(0,0,0, 1e5); // 10% protocol fee
deployment.feeManager.setBaseAsset(address(deployment.vault), asset);
vm.stopPrank();
IOracle.Report[] memory reports = new IOracle.Report[](3);
for (uint256 i = 0; i < 3; i++) {
reports[i].asset = assetsDefault[2 - i];
reports[i].priceD18 = 1e18;
}
vm.startPrank(vaultAdmin);
oracle.submitReports(reports);
for (uint256 i = 0; i < 3; i++) {
oracle.acceptReport(reports[i].asset, reports[i].priceD18, uint32(block.timestamp));
}
vm.stopPrank();
// Set initial shares to 1000
vm.prank(address(deployment.vault));
deployment.shareManager.mint(address(0x100), 1000 ether);
// Move time forward by 1 year
skip(365 days);
// Submit reports for 3 assets
vm.prank(vaultAdmin);
oracle.submitReports(reports);
// Check the fee recipient's shares
uint256 feeRecipientShares = deployment.shareManager.sharesOf(vaultAdmin);
console.log("Fee recipient shares:", feeRecipientShares);
assertGt(feeRecipientShares, 300 ether, "Fee recipient shares mismatch");
}
Mitigation
The issue can be mitigated by updating the implementation related to the timestamp update. I think the timestamp should be updated even though the asset is not the base asset.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/mellow-finance/flexible-vaults/pull/6/files
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
The timestamp used for fee calculation is only updated when the base asset is processed, so multiple reports in a batch each calculate fees from the same old timestamp.
Impact
This vulnerability allows excessive protocol fees to be charged when multiple asset reports are submitted in a single transaction.
What the attacker needed
Vault with multiple assets and a base asset; protocol fees configured (protocolFeeD6 > 0); time passed since last timestamp update; submitReports called with non-base assets first
The fix
The timestamp should be updated even for non-base assets, so that fees are not calculated multiple times from the same old timestamp.
How it was found
- Configure a vault with multiple assets and set a base asset.
- Set protocol fees and ensure time has passed since the last timestamp update.
- Call Oracle.submitReports with multiple reports where non-base assets appear first.
- For each non-base asset report, fees are calculated using the old timestamp and minted, but the timestamp is not updated.
- When the base asset report is processed, fees are calculated again using the old timestamp, and the timestamp is finally updated.
- As a result, multiple fee accruals occur for the same time period.
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 vault charges a fee over time based on how long it has been since the last update. When several price reports are submitted together, the code charges the fee for each report using the same old time, so the fee is charged multiple times for the same period. This means users pay more fees than they should.
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.