Lack of maturity check for non-founder users allowing immediate withdrawals
The withdraw function only enforces a maturity lockup for the founder staker, so non-founder users can stake and immediately withdraw without waiting. This removes the intended lockup incentive for those users.
Submitted by Pelz, also found by aiota, gregom, and Ishenxx
Finding description and impact
In the AgentVeToken::withdraw() function, the contract contains a check for the maturity of stakes, but this check only applies to the founding staker (founder). The condition is:
if ((sender == founder) && ((balanceOf(sender) - amount) < initialLock)) {
require(block.timestamp >= matureAt, "Not mature yet");
}
This ensures that the founding staker must wait for a lockup period before withdrawing if their balance falls below initialLock.
However, there is no such lockup or maturity check for non-founder users. If canStake is enabled for all users, any user who stakes tokens can withdraw immediately, bypassing any intended lockup or maturity period. This flaw effectively removes any staking or lockup incentive for users who stake their tokens, as they can withdraw at will without any restriction.
Recommended mitigation steps
To address this issue, a maturity check should be applied to all users who stake tokens. This would ensure that all users are subject to the same withdrawal restrictions, and their stakes are locked for a specified period before they can withdraw. Recommended approach:
Implement the lockup for non-founder users: Ensure that all users, not just the founder, are locked in for a set period before being allowed to withdraw. You could add logic to set a different lockup period for different classes of users if needed.
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
The maturity check in withdraw is conditioned on the sender being the founder, so the lockup is not applied to other stakers.
Impact
Non-founder users can withdraw immediately after staking, bypassing any intended lockup or maturity period.
What the attacker needed
CanStake enabled for all users
The fix
The maturity check should be applied to all users who stake tokens, not just the founder.
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 lets people lock tokens for a period. The code only makes the original founder wait before taking tokens out; everyone else can take them out straight away. That means the locking rule does not apply to most users.
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.