The lock() function in veRAACToken.sol allows users to lock their RAAC tokens to receive veTokens. However, the contract lacks proper handling of multiple locks for the same user. Instead of maintaining multiple lock records, each new lock overwrites the previous one, leading to unintended state collisions.
When a user locks their tokens, the contract stores the lock state in _lockState. If the user locks additional tokens with a different duration, the contract does not preserve the previous lock details. Instead, the new lock entry overwrites the previous one, effectively erasing the original lock state.
This issue arises due to the createLock() function:
Since state.locks[user] is a mapping that does not support multiple entries per user, each subsequent lock replaces the previous one.
If user wants to Lock his tokens twice. for example he locked once and now has some duration. and now he wants to lock again with different amount to get a new boost and different duration. Contract lacks proper saving of states for multiple locks it saves only 1 lock if user calls lock once more the second lock rewrtites the first lock and now if user wants to increaselock amount he can call only the second one and not the first one.
Collision of lockstate info which may rewrite the first lockstate with the second resulting in User not being able to manipulate his first lockstate.
Loss of Previous Lock State: Users who lock tokens multiple times will only retain the latest lock, losing prior locked amounts and durations.
Boost Manipulation Issues: Users may be unable to properly manage boosts since previous locks are lost.
Incorrect Lock Management: If a user tries to increase their lock amount later, only the most recent lock will be considered, leading to inconsistencies in locked amounts and durations.
Manual Review
To fix this issue, the contract should allow users to maintain multiple locks by implementing a nonce-based tracking system. A potential solution is:
Modify the lock mapping to track multiple entries:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.