Skip to content
Business logic Audit finding Intermediate

`currentStakeLimit` depletes faster in some adapters, due to actual amount spent less than the input `stakeAmount`

The stake limit is reduced by the requested stake amount before staking, but the actual amount staked can be lower, so the limit depletes faster than intended. An attacker could repeatedly trigger deposits where the actual stake is less than requested, draining the stake limit and preventing legitimate deposits.

Varun_05 Follow with blutorque

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-05-napier-update-judging/issues/8

Found by

Varun_05, blutorque

Summary

Vulnerability Detail

In the BaseLSTAdapterUpgradeable.prefundedDeposit(), the stake amount is capped to the currentStakeLimit.This is to prevent the buffer from being completed drained.

Solidity
      // Update the stake limit state in the storage
      $.packedStakeLimitData.setStorageStakeLimitStruct(data.updatePrevStakeLimit(currentStakeLimit - stakeAmount)); 

Before the staking occur, its checks whether the stakeAmount exceed current stakeLimit, if not modify the new stake limit to currentStakeLimit - stakeAmount. The issue is, the actual amount going to be spent could possibly lower than the stakeAmount

https://github.com/sherlock-audit/2024-05-napier-update/blob/c31af59c6399182fd04b40530d79d98632d2bfa7/napier-uups-adapters/src/adapters/BaseLSTAdapterUpgradeable.sol#L157-L158

Solidity
        // Actual amount of ETH spent may be less than the requested amount.
        stakeAmount = _stake(stakeAmount); // stake amount can be 0

which means the stake limit that was updated previously does not account for the actual amount that we staked. I found one instance of adapters where this could possibly occur,

kelp/RsETHAdapter.sol: Input stakeAmount modified to lower value if its greater than the stakeLimit of RsETHDeposit pool,

Impact

With every prefundedDeposit call where excess WETH is left to stake, the stake limit will deplete faster.

Code Snippet

https://github.com/sherlock-audit/2024-05-napier-update/blob/c31af59c6399182fd04b40530d79d98632d2bfa7/napier-uups-adapters/src/adapters/BaseLSTAdapterUpgradeable.sol#L157

Tool used

Manual Review

Recommendation

The _stake() method do returns the actual spent amount, therefore I suggest to update the staking limit after the staking has been done.

Solidity
        /// INTERACT ///
        // Deposit into the yield source
        // Actual amount of ETH spent may be less than the requested amount.
        stakeAmount = _stake(stakeAmount); // stake amount can be 0

        /// WRITE ///
        // Update the stake limit state in the storage
        $.packedStakeLimitData.setStorageStakeLimitStruct(data.updatePrevStakeLimit(currentStakeLimit - stakeAmount));

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/napierfi/napier-v1/pull/219 https://github.com/napierfi/napier-uups-adapters/pull/9

sherlock-admin2

The Lead Senior Watson signed off on the fix.

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

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 stake limit is updated using the requested stake amount before the actual stake amount is known, and the actual amount may be lower.

Impact

The stake limit depletes faster than intended, which could prevent legitimate deposits once the limit is exhausted.

What the attacker needed

Ability to call prefundedDeposit; adapter where actual stake < requested

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 stake limit is like a daily spending cap to prevent draining a buffer. The code subtracts the requested amount from the cap before actually spending, but sometimes it spends less, so the cap goes down too much. This means the cap can be used up faster than it should be.

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 Varun_05

View all

4 more disclosed reports, best first.

More from Napier Finance - LST/LRT Integrations

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.