sherlock-audit / 2024-05-kwenta-x-perennial-integration-update-judging

5 stars 3 forks source link

Informational 08 Inconsistent Handling Of Comparison Cases #45

Closed sherlock-admin3 closed 5 months ago

sherlock-admin3 commented 5 months ago

Informational 08 Inconsistent Handling Of Comparison Cases

Low/Info issue submitted by 1337web3

Summary

The MultiInvoker::canExecuteOrder function should appropriately handle all comparison cases in the TriggerOrderLib::fillable function.

Vulnerability Detail

The TriggerOrderLib::fillable function currently only considers the comparison cases of -1 and 1, neglecting other possible comparison values. This could lead to incorrect validation of whether an order can be executed or not.

https://github.com/sherlock-audit/2024-05-kwenta-x-perennial-integration-update/blob/main/perennial-v2/packages/perennial-extensions/contracts/MultiInvoker.sol#L109-L114

https://github.com/sherlock-audit/2024-05-kwenta-x-perennial-integration-update/blob/main/perennial-v2/packages/perennial-extensions/contracts/types/TriggerOrder.sol#L52-L57

Impact

The incomplete handling of comparison cases in TriggerOrderLib::fillable might result in erroneous validation decisions, potentially allowing orders to be executed incorrectly or preventing valid orders from being executed.

Code Snippet

int8 comparison;    // -2 = lt, -1 = lte, 0 = eq, 1 = gte, 2 = gt

Tool used

Manual Review

Recommendation

Ensure that MultiInvoker::canExecuteOrder properly handles all comparison cases defined in TriggerOrderLib::fillable by updating the implementation to consider all possible comparison values (-2, -1, 0, 1, 2) according to the defined logic.