Assessment reports>TruFin Injective Staker>Medium findings>Unstake could be blocked for certain users
Category: Coding Mistakes

Unstake could be blocked for certain users

Medium Severity
Medium Impact
Medium Likelihood

Description

When a user unstakes some amount of tokens, the tokens are unstaked from either the default validator or the validator provided by the user. If the validator does not have enough tokens available to unstake, the remaining tokens are transferred out of the CONTRACT_REWARDS. In certain cases, it might be possible that the entire unstake amount comes out of the contract rewards.

For example, consider a case where there is one validator and 10 users delegate 100 tokens each and after some time the rewards plus stakes become 120 for each user. For the last user to unstake, the entire amount should come from the rewards as the contract first removes from the validators and then from the rewards.

However, in that case, the actual_amount_to_unstake would be zero and the undelegate message will fail here: https://github.com/InjectiveLabs/cosmos-sdk/blob/master/x/staking/keeper/msg_server.go#L408.

if !msg.Amount.IsValid() || !msg.Amount.Amount.IsPositive() {
	return nil, errorsmod.Wrap(
		sdkerrors.ErrInvalidRequest,
		"invalid shares amount",
	)
}

Impact

Certain users might not be able to unstake.

Recommendations

We recommend only adding the unstake message if actual_amount_to_unstake is greater than zero.

Remediation

This issue has been acknowledged by TruFin, and a fix was implemented in commit 78e5d925.

Zellic © 2025Back to top ↑