Expired tranche cannot be extended due to lack of token allowance
The StNXM contract only approves the top-up amount of NXM tokens to the TokenController, but when extending an expired tranche the StakingPool withdraws the full stake and redeposits it together with the top-up, requiring approval for the larger total. As a result, the redeposit fails and the transaction reverts, leaving the extension incomplete.
Source: https://github.com/sherlock-audit/2025-11-stnxm-by-easedefi-judging/issues/305
This issue has been acknowledged by the team but won't be fixed at this time.
Found by
0xYjs, h2134, hy, ni8mare, securityresearcher
Summary
The StNXM contract contains a functional issue in the extendDeposit() flow where deposit extension fails for expired tranches due to missing NXM token allowance.
Root Cause
In extendDeposit(), when handling expired tranches, StakingPool attempts to withdraw and then redeposit funds, but StNXM contract fails to provide sufficient NXM allowance to TokenController for the complete operation.
Code Flow:
- StNXM calls extendDeposit:
IStakingPool(stakingPool).extendDeposit(_tokenId, _initialTrancheId, _newTrancheId, _topUpAmount);
- StakingPool handles expired tranche:
// if the initial tranche is expired, withdraw everything and make a new deposit
// this requires the user to have grante sufficient allowance
if (initialTrancheId < _firstActiveTrancheId) {
uint[] memory trancheIds = new uint[](1);
trancheIds[0] = initialTrancheId;
@> (uint withdrawnStake, /* uint rewardsToWithdraw */) = withdraw(
tokenId,
true, // withdraw the deposit
true, // withdraw the rewards
trancheIds
);
@> depositTo(withdrawnStake + topUpAmount, targetTrancheId, tokenId, msg.sender);
return;
// done! skip the rest of the function.
}
- StNXM only approves top-up amount
if (_topUpAmount > 0) {
wNxm.unwrap(_topUpAmount);
nxm.approve(nxmMaster.getLatestAddress("TC"), _topUpAmount);
}
The issue occurs because StNXM only approves the _topUpAmount for TokenController, but the depositTo() call requires approval for the full amount (withdrawnStake + topUpAmount). When TokenController attempts transfer the assets, it fails due to insufficient allowance.
Internal Pre-conditions
- StNXM contract holds a staking NFT with an expired tranche
- Owner attempts to extend the expired tranche to a future tranche
External Pre-conditions
None required
Attack Path
- Owner calls
extendDeposit()with an expired initial tranche; - Withdrawal from expired tranche completes successfully;
- Redeposit attempt fails due to missing allowance;
- Transaction reverts after partial completion;
- Funds remain in StNXM contract, extension incomplete.
Impact
Deposit extension operations for expired tranches fail completely, leaving funds stranded in the StNXM contract after successful withdrawal. This breaks the core functionality of tranche extension, rendering a fundamental feature of the staking system inoperable for expired positions.
PoC
No response
Mitigation
Approve sufficient NXM allowance to TokenController in the StNXM contract to cover the full deposit amount (withdrawnStake + topUpAmount) when extending an expired tranche.
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 StNXM contract approves only the top-up amount to the TokenController, while the expired-tranche path of StakingPool.extendDeposit withdraws the entire stake and redeposits withdrawnStake + topUpAmount, so the allowance is insufficient.
Impact
Deposit extension for expired tranches fails completely, leaving funds stranded in the StNXM contract and making that feature inoperable for expired positions.
What the attacker needed
StNXM holds a staking NFT with an expired tranche; Owner extends the expired tranche
The fix
The StNXM contract should approve the TokenController for the full deposit amount (withdrawn stake plus top-up) when extending an expired tranche.
How it was found
- The owner calls extendDeposit() with an expired initial tranche.
- The StakingPool withdraws the full stake from the expired tranche.
- The StakingPool attempts to redeposit the withdrawn stake plus the top-up amount.
- The redeposit fails because the allowance is only for the top-up amount.
- The transaction reverts and the extension is incomplete.
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.
When you extend a staking deposit that has already expired, the system first withdraws your old stake and then puts it back together with any extra amount you add. To move tokens on your behalf, the staking contract needs your permission (an allowance) to spend them. Here the contract only gave permission for the extra amount, not the full amount being redeposited, so the second step failed and the whole operation was undone.
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.