sherlock-audit / 2024-05-beefy-cowcentrated-liquidity-manager-judging

5 stars 5 forks source link

darkart - Logical Error in Pausing Mechanism #93

Closed sherlock-admin3 closed 3 months ago

sherlock-admin3 commented 3 months ago

darkart

high

Logical Error in Pausing Mechanism

Summary

The function employs a logical OR (||) operator to check for two pausing conditions: strategy-specific pause and global pause. However, due to the OR operator, even when the strategy is paused, transactions can still be processed if there's no global pause. This bypasses the intended functionality of restricting access during a paused state.

Vulnerability Detail

The _whenStrategyNotPaused function utilizes a logical OR (||) operator to check for two pausing conditions:

However, due to the OR operator, the issue arises when the strategy is paused (paused() is true) but there's no global pause (factory.globalPause() is false). In this scenario:

Impact

Critical functionalities within the strategy that are guarded by this modifier might become accessible even when the strategy is paused. This could potentially lead to unexpected behavior or security vulnerabilities.

Code Snippet

https://github.com/sherlock-audit/2024-05-beefy-cowcentrated-liquidity-manager/blob/main/cowcentrated-contracts/contracts/strategies/StratFeeManagerInitializable.sol#L84-L86 https://github.com/sherlock-audit/2024-05-beefy-cowcentrated-liquidity-manager/blob/main/cowcentrated-contracts/contracts/strategies/StratFeeManagerInitializable.sol#L77-L80

Tool used

Manual Review

Recommendation

Implement the refactoring approach suggested across all functions that rely on pausing logic, including _whenStrategyNotPaused and potentially _isPaused. Here's an example :

modifier_whenStrategyNotPaused() {
    require(!paused() && !factory.globalPause(), "StrategyPaused");
    _;
}
sherlock-admin4 commented 3 months ago

2 comment(s) were left on this issue during the judging contest.

z3s commented:

Invalid; Your assumption is wrong: Because of the OR operator (||), as long as one condition is true, the entire if statement evaluates to false.

DHTNS commented:

Invalid -> watson seems confused between 'AND' & 'OR' operators