Sablier

Sablier
DeFiFoundry
53,440 USDC
View results
Submission Details
Severity: low
Invalid

No Limits When Setting State Variable Amounts

Summary

The SablierV2 contracts allow certain state variables to be set without limits, which can lead to potential issues with unreasonable or harmful values being assigned. This report highlights specific instances where such vulnerabilities exist and provides recommendations for mitigating these risks.

Vulnerability Details

Several instances were identified in the SablierV2 contracts where state variables are set without imposing limits. These instances are as follows:

File: v2-core/src/SablierV2LockupDynamic.sol
71 MAX_SEGMENT_COUNT = maxSegmentCount;

https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/SablierV2LockupDynamic.sol#L71

File: v2-core/src/SablierV2LockupTranched.sol
66 MAX_TRANCHE_COUNT = maxTrancheCount;

https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/SablierV2LockupTranched.sol#L66

File: v2-core/src/abstracts/SablierV2Lockup.sol
589 _streams[streamId].amounts.refunded = senderAmount;

https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/abstracts/SablierV2Lockup.sol#L589

File: v2-core/src/libraries/Helpers.sol
101 amounts.brokerFee = uint128(ud(totalAmount).mul(brokerFee).intoUint256());

https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/libraries/Helpers.sol#L101

Impact

Without proper limits, these variables can be set to extremely high or low values, leading to potential overflows, excessive gas costs, or other unintended behaviors that can compromise the contract’s functionality and security.

Tools Used

  • Manual code review

Recommendations

  1. Implement Limits: Enforce reasonable limits when setting state variables to ensure they remain within acceptable ranges. For example:

    require(maxSegmentCount > 0 && maxSegmentCount <= MAX_ALLOWED_SEGMENT_COUNT, "Invalid segment count");
    MAX_SEGMENT_COUNT = maxSegmentCount;
  2. Validation Functions: Create validation functions that check the values before they are assigned to state variables.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Info/Gas/Invalid as per Docs

https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity

Support

FAQs

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