The lock function in the veRAACToken contract lacks validation to prevent users from locking funds if they already have an active lock. This allows a user to override their existing lock with a new one, resulting in the previous lock's amount being lost. Consequently, the user cannot withdraw the full amount of tokens they initially locked.
The lock function allows users to create a new lock position. However, it does not check if the user already has an active lock. If a user calls lock multiple times, the existing lock is overwritten with the new lock's details (amount and duration). This means the tokens associated with the previous lock are effectively lost for withdrawal purposes, although the user might still receive veRAAC tokens based on the combined locked amount.
[ https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/tokens/veRAACToken.sol#L212 ]
Loss of Locked Funds: Users can lose a portion of their locked tokens, as the amount from the previous lock is not carried over when a new lock is created.
Withdrawal Issues: Users cannot withdraw the full amount of tokens they initially locked, as the withdraw function only considers the amount of the last lock created.
Incorrect veRAAC Calculation: The user might receive veRAAC tokens based on the cumulative amount locked across multiple calls to lock, even though they can only withdraw the amount from the last lock. This leads to an imbalance between veRAAC holdings and actual withdrawable RAAC.
Alice locks 100 RAAC tokens for 365 days using the lock function.
Alice, calls lock again with another 100 RAAC tokens for 365 days, to increase her lock.
The LockManager.createLock function overwrites Alice's initial lock of 100 tokens with the new lock of 100 tokens. The first 100 RAAC are now lost for withdrawal.
When Alice's lock expires, she calls withdraw. She only receives 100 RAAC tokens (from the second lock), not the 200 RAAC she intended to lock in total. Her 50 veRAAC tokens (calculated based on 200 RAAC) are burned.
Use this guide to intergrate foundry into your project: foundry
Create a new file FortisAudits.t.sol in the test directory.
Add the following gist code to the file: Gist Code
Run the test using forge test --mt test_ForitsAudits_LockOverridesExsitingLock -vvvv.
Manual code review.
Add a check in the lock function to ensure that the user does not already have an active lock. If a user tries to lock tokens while they already have an active lock, revert with an appropriate error message. This prevents users from accidentally overwriting their existing locks and ensures they can withdraw the full amount of their locked tokens.
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.