Platform: Code4rena
Start Date: 04/01/2022
Pot Size: $25,000 USDC
Total HM: 3
Participants: 40
Period: 3 days
Judge: Ivo Georgiev
Total Solo HM: 1
Id: 75
League: ETH
Rank: 26/40
Findings: 2
Award: $50.52
π Selected for report: 0
π Solo Findings: 0
37.3718 USDC - $37.37
ye0lde
The function below fails to perform input validation on arrays to verify the lengths match. A mismatch could lead to an exception or undefined behavior.
multipliers
is accessed without validating its length.
https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L83
Visual Studio Code, Remix
Add input validation to check that the length of multipliers
and durations_
match.
#0 - deluca-mike
2022-01-06T06:14:03Z
If there are more multipliers
than durations
, then the extra multipliers
are ignored. If there are more durations
than multipliers
, then the function will revert anyway. Further, if the admin did make a mistake, they can just call the function again. This is no-risk.
#1 - deluca-mike
2022-01-09T10:41:36Z
Duplicate #38
13.1525 USDC - $13.15
ye0lde
Redundant arithmetic underflow/overflow checks can be avoided when an underflow/overflow cannot happen.
The "unchecked" keyword can be applied since there is a require
statement to ensure the arithmetic operations would not cause an integer underflow or overflow.
For example here: https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L114-L120
Change the code to:
// Throw convenient error if trying to re-lock more than was unlocked. require(lockAmount_ <= amountUnlocked_, "INSUFFICIENT_AMOUNT_UNLOCKED"); // Handle the lock position creation and get the tokenId of the locked position. newTokenId_ = _lock(lockAmount_, duration_, destination_); uint256 withdrawAmount; unchecked { withdrawAmount = amountUnlocked_ - lockAmount_; }
A similar change can be made here: https://github.com/XDeFi-tech/xdefi-distribution/blob/3856a42df295183b40c6eee89307308f196612fe/contracts/XDEFIDistribution.sol#L169-L175
Visual Studio Code, Remix
Add the "unchecked" keyword as shown above.
#0 - deluca-mike
2022-01-06T19:34:01Z
Yup, we will use unchecked where we can.
#1 - deluca-mike
2022-01-09T10:57:09Z
Duplicate #49