SiloVault will incorrectly accrue rewards during user transfer/transferFrom actions due to unsynced totalSupply()
SiloVault's transfer and transferFrom functions call _claimRewards() without first accruing fees, so the totalSupply used for reward calculation is stale. This leads to incorrect and inconsistent reward accrual.
Submitted by oakcobalt, also found by aldarion and seeques
Finding description and impact
SiloVault’s totalSupply() accrueFees from interests (delta totalAssets). Such fee accrual is updated through _accrueFee() which mints an additional share to the fee reciever.
We see that when claiming rewards directly through claimRewards() the accrued extra share is updated first before _claimRewards().
The vulnerability is when _claimRewards() is invoked atomically through hooks (*update), the *accrueFee() will be missed in the user’s transfer/transferFrom call. In this case, an incorrect totalSupply() will be used for fee accrual, leading to incorrect fee accrual.
Impacts: incorrect and inconsistent reward accrual due to unsynced totalSupply().
Recommended mitigation steps
In *update() hook, consider adding *accrueFee()or*updateLastTotalAssets(*accrueFee())before_claimRewards().
Proof of Concept
We see in direct claimRewards flow. totalSupply() will be updated in _accrueFee().
function claimRewards() public virtual {
_nonReentrantOn();
|> _updateLastTotalAssets(_accrueFee());
_claimRewards();
_nonReentrantOff();
}
function _accrueFee() internal virtual returns (uint256 newTotalAssets) {
uint256 feeShares;
(feeShares, newTotalAssets) = _accruedFeeShares();
//@audit this will increase totalSupply()
|> if (feeShares != 0) _mint(feeRecipient, feeShares);
emit EventsLib.AccrueInterest(newTotalAssets, feeShares);
}
However, the vulnerable flow is transfer/transferFrom -> *update(), where *accrueFee() is missed.
function _update(address _from, address _to, uint256 _value) internal virtual override {
// on deposit, claim must be first action, new user should not get reward
// on withdraw, claim must be first action, user that is leaving should get rewards
// immediate deposit-withdraw operation will not abused it, because before deposit all rewards will be
// claimed, so on withdraw on the same block no additional rewards will be generated.
// transfer shares is basically withdraw->deposit, so claiming rewards should be done before any state changes
|> _claimRewards(); //@audit rewards is claimed without first updating totalSupply(). transfer/transferFrom flow is vulnerable.
super._update(_from, _to, _value);
if (_value == 0) return;
_afterTokenTransfer(_from, _to, _value);
}
We know transfer/transferFrom flow is vulnerable because unlike deposit/withdraw which calls _accrueFee() first, transfer/transferFrom will directly call _update() without updating totalSupply. This causes an incorrect/inconsistent reward accrual.
IhorSF (Silo Finance) disputed
This PR here fixes the accrue on transfer for SiloVault.
Status: Mitigation confirmed. Full details in reports from d3e4, t0x1c, and Drynooo.
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 _update hook calls _claimRewards() without first calling _accrueFee() to sync totalSupply, unlike the direct claimRewards() flow.
Impact
Reward accrual becomes incorrect and inconsistent, potentially giving users wrong reward amounts.
What the attacker needed
Ability to transfer vault shares
How it was found
- Call transfer or transferFrom on SiloVault.
- The _update hook runs and calls _claimRewards() directly.
- Because _accrueFee() was not called first, totalSupply() is stale.
- Rewards are accrued using the incorrect totalSupply.
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 contract gives out rewards based on the total number of shares. When users transfer shares, the contract should first update the total share count to include any new fee shares. Here it skipped that update, so rewards were calculated using an old total, making them wrong.
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.