DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

Using OR condition for validating zero address can be bypassed if anyone condition is True

Summary

The constructor's OR (||) condition for address validation can inadvertently allow zero addresses for critical variables, such as fjordToken, impacting contract functionality due to misconfiguration.

Vulnerability Details

During the contract's deployment, the constructor checks if any of the provided addresses are zero using an OR condition. This logic is intended to ensure that all critical addresses are valid. However, the OR condition only requires one of the conditions to be true for the entire expression to pass, meaning that if any one of the addresses is valid, the check can be bypassed, allowing other addresses to be set to zero. This is problematic for the fjordToken variable, as its immutability prevents any post-deployment correction, potentially rendering the contract unable to interact with the FJORD token.

Impact

If the contract is initialized with a zero address for fjordToken, the contract will be unable to perform essential operations such as staking, unstaking, and reward distribution. This misconfiguration can lead to a complete halt in contract functionality, affecting all users and stakeholders relying on the contract's operations.

Tools Used

Manual

Recommendations

To prevent this issue, replace the OR condition with an AND condition to ensure all addresses are checked individually. This will prevent any zero address from being set during initialization, maintaining the contract's integrity and functionality.

diff --git a/src/FjordStaking.sol b/src/FjordStaking.sol
index 46e93c4..39fd40f 100644
--- a/src/FjordStaking.sol
+++ b/src/FjordStaking.sol
@@ -286,9 +286,9 @@ contract FjordStaking is ISablierV2LockupRecipient {
address _fjordPoints
) {
if (
- _rewardAdmin == address(0) || _sablier == address(0) || _fjordToken == address(0)
- || _fjordPoints == address(0)
- ) revert InvalidZeroAddress();
+ _rewardAdmin == address(0) && _sablier == address(0) && _fjordToken == address(0)
+ && _fjordPoints == address(0)
+ ) revert InvalidZeroAddress(); //
startTime = block.timestamp;
owner = msg.sender;
Updates

Lead Judging Commences

inallhonesty Lead Judge
10 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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