Skip to content
Smart contracts Audit finding Intermediate

Stakers Could Not Withdraw Their Assets

The LT.sol contract allows the staked token supply to become as low as 1, which prevents multiple stakers from withdrawing their assets because they cannot withdraw partial amounts. Stakers may also experience precision loss when the staked supply is small.

KupiaSec Follow with ge6a

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-08-yield-basis-judging/issues/342

Found by

KupiaSec, ge6a

Summary

In the LT.sol contract, the protocol allows the staked tokens to become 1. This situation leads to the staked supply not being attributed to a single staker but rather to multiple stakers, resulting in the inability for stakers to withdraw their assets.

Root Cause

https://github.com/sherlock-audit/2025-08-yield-basis/blob/main/yb-core/contracts/LT.vy#L359-L361

VYPER
359:     # let's leave at least 1 LP token for staked and for total
360:     if staked > 0:
361:         token_reduction = min(token_reduction, staked - 1)

Internal pre-conditions

N/A

External pre-conditions

N/A

Attack Path

N/A

Impact

Stakers could not withdraw their assets. Stakers could experience precision loss due to the small value of staked_tokens.

PoC

When stakers attempt to unstake, if the staked_tokens is 1, the staker can only withdraw the entire amount and cannot withdraw a partial amount. This means that if there are several stakers, they would be unable to withdraw their assets. Even if the staked_tokens is not 1, if it is less than 10,000, they still experience a precision loss of more than 0.01%.

Mitigation

VYPER
359:     # let's leave at least 1 LP token for staked and for total
360:     if staked > 0:
-361:         token_reduction = min(token_reduction, staked - 1)
+361:         token_reduction = min(token_reduction, staked - min(staked, MIN_SHARE_REMAINDER))


359:     # let's leave at least 1 LP token for staked and for total
360:     if staked > 0:
-361:         token_reduction = min(token_reduction, staked - 1)
+361:         token_reduction = min(token_reduction, staked - min(staked, MIN_SHARE_REMAINDER))
362:     if supply > 0:
-363:         token_reduction = min(token_reduction, supply - 1)
+363:         token_reduction = min(token_reduction, supply - min(supply, MIN_SHARE_REMAINDER))

The original report as published on Sherlock, by KupiaSec. 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 contract enforces a minimum remaining staked amount of only 1, which is too low to support fair proportional withdrawals when multiple stakers exist.

Impact

Stakers could not withdraw their assets, and they could experience precision loss due to the small value of staked_tokens.

What the attacker needed

Multiple stakers; staked supply becomes very small

The fix

The code should be changed to leave a larger minimum remainder (MIN_SHARE_REMAINDER) instead of 1, as shown in the mitigation.

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.

In a staking contract, users deposit tokens and receive shares representing their portion. If the total number of shares becomes extremely small (like 1), the system cannot fairly divide withdrawals among multiple users, so some users cannot take out their funds. This is a precision problem where small numbers cause rounding errors.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by KupiaSec

View all

28 more disclosed reports, best first.

More from Yield Basis

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.