Skip to content
Business logic Audit finding Advanced

Incorrect reward distribution due to feeShares minting order

The vault distributes rewards before minting fee shares, so the fee recipient receives shares but no rewards for the interest period that generated those shares. Existing shareholders receive a larger share of rewards than they should.

t0x1c Follow with Drynooo

Originally disclosed on Code4rena

Submitted by t0x1c, also found by Drynooo

https://github.com/code-423n4/2025-03-silo-finance/blob/main/silo-vaults/contracts/SiloVault.sol#L976-L992

Summary

The current implementation distributes rewards before minting fee shares, resulting in the fee recipient receiving shares but no rewards for the corresponding interest accrual period. This creates an inconsistency where the exisiting share owners receive higher than deserved portion of rewards.

Description

Let’s assume Bob is the sole shareholder. What’s happening right now is:

  • Bob deposits at t and receives 100% shares (for simplicity let’s ignore, for now, the DECIMALS_OFFSET strategy deployed by the protocol to thwart the first-depositor attack).

  • At some time, t2, we see that yield & reward has accrued.

  • Someone calls claimRewards() which first internally calls _updateLastTotalAssets(_accrueFee()) and then _claimRewards():

    File: silo-vaults/contracts/SiloVault.sol
    
    495:              function claimRewards() public virtual {
    496:                  _nonReentrantOn();
    497:
    498:@--->             _updateLastTotalAssets(_accrueFee());
    499:@--->             _claimRewards();
    500:
    501:                  _nonReentrantOff();
    502:              }
    
  • _accrueFee() internally calls _mint() if feeShares != 0.

    942:              function _accrueFee() internal virtual returns (uint256 newTotalAssets) {
    943:                  uint256 feeShares;
    944:                  (feeShares, newTotalAssets) = _accruedFeeShares();
    945:
    946:@--->             if (feeShares != 0) _mint(feeRecipient, feeShares);
    947:
    948:                  emit EventsLib.AccrueInterest(newTotalAssets, feeShares);
    949:              }
    
  • Note that _accruedFeeShares() on L944 is a retrospective way to calculate the feeShares which should correspond to the feeAssets amount applied on the accumulated interest. This is done because the total assets have already grown between t and t2. This is evident from the newTotalAssets - feeAssets term inside _accruedFeeShares() and also the comments on L960-961:

    951:              /// @dev Computes and returns the fee shares (`feeShares`) to mint and the new vault's total assets
    952:              /// (`newTotalAssets`).
    953:              function _accruedFeeShares() internal view virtual returns (uint256 feeShares, uint256 newTotalAssets) {
    954:                  newTotalAssets = totalAssets();
    955:
    956:                  uint256 totalInterest = UtilsLib.zeroFloorSub(newTotalAssets, lastTotalAssets);
    957:                  if (totalInterest != 0 && fee != 0) {
    958:                      // It is acknowledged that `feeAssets` may be rounded down to 0 if `totalInterest * fee < WAD`.
    959:                      uint256 feeAssets = totalInterest.mulDiv(fee, WAD);
    960:@--->                 // The fee assets is subtracted from the total assets in this calculation to compensate for the fact
    961:@--->                 // that total assets is already increased by the total interest (including the fee assets).
    962:                      feeShares = _convertToSharesWithTotals(
    963:                          feeAssets,
    964:                          totalSupply(),
    965:@--->                     newTotalAssets - feeAssets,
    966:                          Math.Rounding.Floor
    967:                      );
    968:                  }
    969:              }
    

What this means is that the fee recipient is going to be minted the feeShares currently because they have a rightful claim to the feeAssets which started to accrue right from timestamp t.

With that in mind, let’s see the remaining steps -

  • On L946 _accrueFee() --> _mint() internally calls the overridden _update() function, which in turn calls _claimRewards() before super._update() actually mints these feeShares and increases totalSupply(). As the inline code comments explain, this is meant to be a safeguard and it is required so that rewards can be claimed before a new deposit/withdraw/transfer:

    976:              function _update(address _from, address _to, uint256 _value) internal virtual override {
    977:                  // on deposit, claim must be first action, new user should not get reward
    978:
    979:                  // on withdraw, claim must be first action, user that is leaving should get rewards
    980:                  // immediate deposit-withdraw operation will not abused it, because before deposit all rewards will be
    981:                  // claimed, so on withdraw on the same block no additional rewards will be generated.
    982:
    983:                  // transfer shares is basically withdraw->deposit, so claiming rewards should be done before any state changes
    984:
    985:@--->             _claimRewards();
    986:
    987:                  super._update(_from, _to, _value);
    988:
    989:                  if (_value == 0) return;
    990:
    991:                  _afterTokenTransfer(_from, _to, _value);
    992:              }
    

In this case however, what it means is that the entire reward is doled out to Bob since he possesses 100% of shares because the feeShares are yet to be minted. By the time the control reaches the second call to _claimRewards() on L499 after minting of these shares, there are no more rewards left to be distributed to the fee recipient.

Impact

  • The shares of the fee recipient will now only receive any future rewards and miss out on the current one even though the shares have been rightly minted to them retrospectively. Conversely put, Bob receives more than his fair share of rewards.
  • Note that this is not just a one-time loss of rewards for the fee recipient. Each time claimRewards() is called and there is a pending yield to be collected, feeShares minted in that cycle lose out on the rewards being distributed. They only get to see a portion of the rewards from the next cycle onwards.

Recommendation

The current logic of calling _claimRewards() from inside _update() is correct and works well for all the other cases, so no issues there. For cases where feeShares are being minted, however, we may need to introduce additional logic inside _claimRewards() which checks for this via a new flag and calculates the reward portion after accounting for these retrospectively minted feeShares.

edd (Silo Finance) acknowledged


The original report as published on Code4rena, by t0x1c. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 reward claim happens inside the share update function before the new fee shares are actually minted, so the reward calculation does not include the fee recipient's retrospectively earned shares.

Impact

The fee recipient loses rewards for each accrual period, and existing shareholders receive more than their fair share; this happens repeatedly, not just once.

What the attacker needed

Vault has accrued interest and rewards; fee recipient has pending fee shares; claimRewards() is called

The fix

The report recommends adding logic inside _claimRewards() to account for retrospectively minted fee shares when calculating the reward portion.

How it was found

  1. Bob deposits and receives all vault shares.
  2. Yield and rewards accrue over time.
  3. Someone calls claimRewards(), which first accrues fees and mints fee shares.
  4. During minting, the overridden _update() calls _claimRewards() before the new shares are added to total supply.
  5. The entire reward is distributed to Bob because he holds all existing shares.
  6. After minting, the second _claimRewards() call finds no rewards left for the fee recipient.

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 pays interest to people who hold its shares. It also takes a fee by creating new shares for a fee recipient. The code gives out rewards before creating those fee shares, so the fee recipient's new shares miss the rewards for the period they were earned. This means existing holders get slightly more rewards 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.

More by t0x1c

View all

19 more disclosed reports, best first.

More from Silo Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.