Skip to content
Business logic Audit finding Intermediate

Interest is not accrued before parameters are updated in SavingsVest

The SavingsVest contract did not accrue interest before updating the protocol safety fee and vesting period, so depositors could lose earned yield or have it locked longer. An attacker could sandwich the parameter update to profit from a jump in locked profit.

Jeiwan Follow

Originally disclosed on Code4rena

Submitted by Jeiwan

Stablecoin holders can receive wrongly calculated yield in the SavingsVest contract. Also, wrong vesting profit can be slashed when the protocol is under-collateralized.

Proof of Concept

The SavingsVest contract lets users deposit their stablecoins and earn vested yield when the stablecoin in the Transmuter protocol is over-collateralized. The interest is accrued via calls to the SavingsVest.accrue function.

There are two parameters that affect the profit of depositors:

  1. protocolSafetyFee is the fees paid to the protocol;
  2. vestingPeriod is the period when the yield remains locked.

The two parameters can be changed via the setParams function. However, before they’re changed, the current interest is not accrued. E.g. this may lead to:

  1. If protocolSafetyFee is increased without accruing interest, the next accrual will happen at the increased fees, which will reduce the rewards for the depositors.
  2. If vestingPeriod is increased without accruing interest, the yield will be locked for a longer period and the next accrual may slash more vested yield.

Thus, users can lose a portion of the yield that was earned at a lower protocol fee after the fee was increased. Likewise, increasing the vesting period may result in slashing yield that was earned before the period was increased.

Recommended Mitigation Steps

In the SavingsVest.setParams function, consider accruing interest with the current parameters before setting new protocolSafetyFee and vestingPeriod.

Picodes (Angle) confirmed and commented:

Confirmed. The worst scenario is that when modifying the vestingPeriod it can lead to a jump in lockedProfit, so to a jump in totalAssets(). So eventually someone could sandwich attack the update for a profit.

Angle mitigated:

PR: https://github.com/AngleProtocol/angle-transmuter/commit/94c4e51ae3400a63532e85f04f4081152adc97db Calls `accrues before updating sensible parameters.

Status: Mitigation confirmed. Full details in report from Jeiwan.


The original report as published on Code4rena, by Jeiwan. 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

Likely the setParams function updates protocolSafetyFee and vestingPeriod without first calling accrue to record interest under the old parameters.

Impact

Depositors could lose a portion of yield earned at a lower fee, and increasing the vesting period could slash yield earned before the change; the protocol team noted someone could sandwich the update for a profit.

What the attacker needed

Protocol owner changes parameters; attacker can sandwich the update

The fix

The setParams function was changed to call accrue before updating the parameters.

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 savings contract lets people deposit stablecoins and earn interest over time. The contract has settings for the fee taken by the protocol and how long earned interest stays locked. If those settings are changed without first recording the interest earned under the old settings, users can lose some of their earned interest or have it locked for longer than expected.

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 Jeiwan

View all

69 more disclosed reports, best first.

More from Angle Protocol - Invitational

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.