Hasrequestedexit returns true for not just requested exits but also delegations that are already exited
The hasRequestedExit function returns true for delegations that have already exited, not just those with a pending exit request. This can cause users and dApps to misinterpret delegation status, leading to UI confusion or incorrect protocol logic.
- Disclosed after under an hour
60597 sc low hasrequestedexit returns true for not just requested exits but also delegations that are already exited
Submitted on Nov 24th 2025 at 09:01:17 UTC by @Brainiac5 for Audit Comp | Vechain | Stargate Hayabusa
- Report ID: #60597
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/audit-comp-vechain-stargate-hayabusa/tree/main/packages/contracts/contracts/Stargate.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Description:
The hasRequestedExit function is intended to indicate whether a user has requested a delegation exit. However, its current implementation only checks if endPeriod != type(uint32).max, which is also true for delegations that have already exited. This can lead to false positives, where the function returns true even if the delegation is no longer active and has already exited.
The current implementation:
function hasRequestedExit(uint256 _tokenId) external view returns (bool) {
StargateStorage storage $ = _getStargateStorage();
// get end period of the delegation
uint256 delegationId = $.delegationIdByTokenId[_tokenId];
// If no delegation exists, exit was never requested
if (delegationId == 0) {
return false;
}
// Fetch only the period details (single external call)
(, uint32 endPeriod) = $.protocolStakerContract.getDelegationPeriodDetails(delegationId);
// endPeriod is set to type(uint32).max when delegation is created
// It changes to a specific period number when exit is requested
return endPeriod != type(uint32).max;
}
Impact:
- Users and dApps may incorrectly interpret exited delegations as having a pending exit request.
- Can cause UI confusion, incorrect protocol logic, or misreporting of delegation status.
Suggested Fix:
Update the function to check that the endPeriod is not only set, but also in the future relative to the validator's completed periods. This ensures that only active exit requests are reported as true.
function hasRequestedExit(uint256 _tokenId) external view returns (bool) {
StargateStorage storage $ = _getStargateStorage();
uint256 delegationId = $.delegationIdByTokenId[_tokenId];
if (delegationId == 0) {
return false;
}
(, uint32 endPeriod) = $.protocolStakerContract.getDelegationPeriodDetails(delegationId);
(address validator, , , ) = $.protocolStakerContract.getDelegation(delegationId);
(, , , uint32 completedPeriods) = $.protocolStakerContract.getValidationPeriodDetails(validator);
// Only return true if endPeriod is set and is in the future (exit requested, not yet completed)
return endPeriod != type(uint32).max && endPeriod > completedPeriods + 1;
}
Proof of Concept
Proof of Concept
Add the test below to
Stake.test.ts
it.only("should show hasRequestedExit returns true for already exited delegation (endPeriod <= completedPeriod + 1)", async () => {
// Stake and delegate NFT
const levelSpec = await stargateNFTMockContract.getLevel(LEVEL_ID);
await stargateContract.connect(user).stake(LEVEL_ID, {
value: levelSpec.vetAmountRequiredToStake,
});
const tokenId = await stargateNFTMockContract.getCurrentTokenId();
await stargateContract.connect(user).delegate(tokenId, validator.address);
// Set validator to ACTIVE and advance periods
await protocolStakerMockContract.helper__setValidationCompletedPeriods(validator.address, 10);
// Request delegation exit
await stargateContract.connect(user).requestDelegationExit(tokenId);
// Advance periods so delegation is exited
await protocolStakerMockContract.helper__setValidationCompletedPeriods(validator.address, 20);
// Now delegation is exited, and endPeriod is set
// hasRequestedExit will return true, and status is EXITED
const hasRequestedExit = await stargateContract.hasRequestedExit(tokenId);
const status = await stargateContract.getDelegationStatus(tokenId);
expect(hasRequestedExit).to.be.true;
expect(status).to.equal(DELEGATION_STATUS_EXITED);
});
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
Impact
Users and dApps may incorrectly interpret exited delegations as having a pending exit request, causing UI confusion or incorrect protocol logic.
What the attacker needed
A staked NFT delegated to a validator; the delegation has been exited
The fix
The function should be updated to check that the end period is set and in the future relative to the validator's completed periods.
How it was found
- Stake and delegate an NFT to a validator.
- Set the validator's completed periods to 10.
- Request delegation exit.
- Advance completed periods to 20 so the delegation is exited.
- Call hasRequestedExit and observe it returns true while status is EXITED.
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 smart contract function is supposed to tell you if you have asked to leave a delegation (a kind of staking arrangement). It checks a single value that stays set even after you have already left, so it wrongly says you are still waiting to leave. This can confuse apps that show your status.
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.