Core Contracts

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

Missing check of existing Lock.exists in the lock function causes loss of funds for user

Summary

In the lock function in veRAACToken.sol, it is not checked if the user already has a position open. so if a user calls the function again, the previous position is overwritten and thus cauing loss of user funds.

Vulnerability Details

The lock Function fails to check if the user already has a position and allows them to create another position. The user will expect that the new position amount to be added to the previous, but the protocol overwrites the old position.(the createLock function overwrites the position).

function lock(uint256 amount, uint256 duration) external nonReentrant whenNotPaused {
if (amount == 0) revert InvalidAmount();
if (amount > MAX_LOCK_AMOUNT) revert AmountExceedsLimit();
// @audit3 amount is not being minted, its newPower, so this check is wrong this check should be done below functions too
if (totalSupply() + amount > MAX_TOTAL_SUPPLY) revert TotalSupplyLimitExceeded();
if (duration < MIN_LOCK_DURATION || duration > MAX_LOCK_DURATION)
revert InvalidLockDuration();
// Do the transfer first - this will revert with ERC20InsufficientBalance if user doesn't have enough tokens
raacToken.safeTransferFrom(msg.sender, address(this), amount);
// Calculate unlock time
uint256 unlockTime = block.timestamp + duration;
// Create lock position
_lockState.createLock(msg.sender, amount, duration);
_updateBoostState(msg.sender, amount);

Impact

user loss of funds

Tools Used

manual review

Recommendations

add the following check in the lock function in veRAACToken.sol
if (_lockState.locks[msg.sender].exists) revert;

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!