Core Contracts

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

Fund loss vulnerability in `veRAACToken`

Summary

The function lock in the veRAACToken contract allows users to create a new lock position without checking if they have an existing unexpired lock. This overwrites the previous lock position, causing any previously locked tokens to become permanently lost.

Vulnerability Details

The vulnerability in lock exits because there is no check to see if the user has an already existing lock, even though the function directly overwrites the existing lock.

function lock(uint256 amount, uint256 duration) external nonReentrant whenNotPaused {
if (amount == 0) revert InvalidAmount();
if (amount > MAX_LOCK_AMOUNT) revert AmountExceedsLimit();
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);

Here's an example of how this can go wrong:

  • User locks 1M tokens for 1 year

  • User locks another 1M tokens before his last lock expires

  • The amount from the first lock is lost because the struct gets overwritten

Impact

As a result, the tokens a user locks become permanently locked in the contract, with no way of recovery, which undermines the user's trust in the protocol.

Recommendations

Consider adding a check in lock checking if there's currently an existing lock. The new lock should be possible after the previous tokens are withdrawn either through withdraw or emergencyWithdraw.

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!