Open code423n4 opened 2 years ago
leastwood
The claim function in USDV is intended to be called when unlocking tokens previously locked after minting or burning. The claim function does not check if i is a valid array index, and as a result the call will revert with no relevant error message.
claim
USDV
i
https://github.com/code-423n4/2021-12-vader/blob/main/contracts/tokens/USDV.sol#L122-L142
function claim(uint256 i) external onlyWhenNotLocked returns (uint256) { Lock[] storage userLocks = locks[msg.sender]; Lock memory lock = userLocks[i]; require(lock.release <= block.timestamp, "USDV::claim: Vesting"); uint256 last = userLocks.length - 1; if (i != last) { userLocks[i] = userLocks[last]; } userLocks.pop(); if (lock.token == LockTypes.USDV) _transfer(address(this), msg.sender, lock.amount); else vader.transfer(msg.sender, lock.amount); emit LockClaimed(msg.sender, lock.token, lock.amount, lock.release); return lock.amount; }
Manual code review.
Consider adding a require statement with a relevant error message to ensure i < userLocks.length.
require
i < userLocks.length
As mentioned above, "call will revert with no relevant error message." Hence there is 0 risk.
Since the index can be reused, this can be misleading for users. I think it worth a Low.
index
Low
Handle
leastwood
Vulnerability details
Impact
The
claim
function inUSDV
is intended to be called when unlocking tokens previously locked after minting or burning. Theclaim
function does not check ifi
is a valid array index, and as a result the call will revert with no relevant error message.Proof of Concept
https://github.com/code-423n4/2021-12-vader/blob/main/contracts/tokens/USDV.sol#L122-L142
Tools Used
Manual code review.
Recommended Mitigation Steps
Consider adding a
require
statement with a relevant error message to ensurei < userLocks.length
.