Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Valid

Loss of funds due to overwritten lock-positions in lock()

Summary

The lock() function calls createLock() without verifying if the user already has an existing lock. If a user attempts to lock tokens while they already have an active lock, the new lock will overwrite the existing one.

Vulnerability Details

In lock(), a user provides an amount of raacTokens they wish to lock and duration of lock which is then handled as follows:

// Calculate unlock time
uint256 unlockTime = block.timestamp + duration;
// Create lock position
// @audit-issue Does not check if lock already exist thereby overwrite new locks?
>> _lockState.createLock(msg.sender, amount, duration);

In createLock(), the user's lock position is created as follows:

end = block.timestamp + duration;
>> state.locks[user] = Lock({
amount: amount,
end: end,
exists: true
});

However, before proceeding to create this position, the exists field is not checked in lock() . This means that if a user attempts to lock tokens while they already have an active lock, the new lock will replace the existing one.

Impact

This leads to a scenario where the old locked funds are erased resulting is a condition where the user has a lock position that does not accurately reflect his total lock. This therefore translates to loss for the user

Tools Used

Manual Review

Recommendations

Check if the user already has an existing lock before creating a new one in lock():

+ // @audit Check if the user already has an existing lock
+ LockManager.Lock memory userLock = _lockState.locks[msg.sender];
+ if (userLock.exists) revert LockAlreadyExists();
// @audit Proceed with position creation
_lockState.createLock(msg.sender, amount, duration);
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

veRAACToken::lock called multiple times, by the same user, leads to loss of funds

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!