Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

whitehair0330 - Incorrect calculation of the lossFee in the GasProcess.processExecutionFee() function. #166

Closed
sherlock-admin2 opened this issue Jun 20, 2024 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue Sponsor Disputed The sponsor disputed this issue's validity Won't Fix The sponsor confirmed this issue will not be fixed

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Jun 20, 2024

whitehair0330

Medium

Incorrect calculation of the lossFee in the GasProcess.processExecutionFee() function.

Summary

In the processExecutionFee() function, the lossFee is always miscalculated to 0.

Vulnerability Detail

At L24, the lossFee is calculated. However, the executionFee was already adjusted to the same value as userExecutionFee. Consequently, the lossFee is consistently calculated as 0. This leads to the inaccurate modification of the CommonData.

        if (executionFee > cache.userExecutionFee) {
23          executionFee = cache.userExecutionFee;
24          lossFee = executionFee - cache.userExecutionFee;
        } else {

        [...]

39          CommonData.addLossExecutionFee(lossFee);

Impact

The incorrect calculation of the lossFee leads to the improper modification of the CommonData.

Code Snippet

https://github.com/sherlock-audit/2024-05-elfi-protocol/blob/main/elfi-perp-contracts/contracts/process/GasProcess.sol#L17-L41

Tool used

Manual Review

Recommendation

The GasProcess.processExecutionFee() function should be fixed as follows.

-           executionFee = cache.userExecutionFee;
            lossFee = executionFee - cache.userExecutionFee;
+           executionFee = cache.userExecutionFee;

Duplicate of #108

@sherlock-admin3 sherlock-admin3 added Won't Fix The sponsor confirmed this issue will not be fixed and removed Won't Fix The sponsor confirmed this issue will not be fixed labels Jun 21, 2024
@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Jun 27, 2024
@sherlock-admin3 sherlock-admin3 added Sponsor Disputed The sponsor disputed this issue's validity Won't Fix The sponsor confirmed this issue will not be fixed labels Jul 3, 2024
@sherlock-admin2 sherlock-admin2 changed the title Dazzling Leather Sidewinder - Incorrect calculation of the lossFee in the GasProcess.processExecutionFee() function. whitehair0330 - Incorrect calculation of the lossFee in the GasProcess.processExecutionFee() function. Jul 3, 2024
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Jul 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue Sponsor Disputed The sponsor disputed this issue's validity Won't Fix The sponsor confirmed this issue will not be fixed
Projects
None yet
Development

No branches or pull requests

2 participants