Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request update stake can be repeated for a vault to a DSS even when the vault is staked already #61

Open
howlbot-integration bot opened this issue Aug 1, 2024 · 10 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b primary issue Highest quality submission among a set of duplicates Q-07 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_20_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality

Comments

@howlbot-integration
Copy link

Lines of code

https://github.com/code-423n4/2024-07-karak/blob/f5e52fdcb4c20c4318d532a9f08f7876e9afb321/src/entities/Operator.sol#L105

Vulnerability details

Impact

The vault when staked newly to a DSS, invokes certain code from the DSS to support initialization.
The vulnerability allows existing staked vaults to be staked again which might reinitialize or corrupt the states of the existing vault configuration for the DSS.

Proof of Concept

In the validateAndUpdateVaultStakeInDSS function from finalizeUpdateVaultStakeInDSS in Core, we see that we update the vault stake in the DSS.

function validateAndUpdateVaultStakeInDSS(CoreLib.Storage storage self, QueuedStakeUpdate memory queuedStakeUpdate)
        external
    {
        State storage operatorState = self.operatorState[queuedStakeUpdate.operator];
        validateQueuedStakeUpdate(operatorState, queuedStakeUpdate);
        updateVaultStakeInDSS(
            operatorState,
            queuedStakeUpdate.updateRequest.vault,
            queuedStakeUpdate.updateRequest.dss,
            queuedStakeUpdate.updateRequest.toStake
        );
.
.
    }

In updateVaultStakeInDSS, We see that the enumerableSet library's return value isn't checked. There is also no .contains() method used to check if the .add and .remove in this code segment is valid.

    function updateVaultStakeInDSS(State storage operatorState, address vault, IDSS dss, bool toStake) internal {
        if (toStake) {
            operatorState.vaultStakedInDssMap[dss].add(vault);
        //@audit, it isn't checked if the vault exists already in the dssMap
        } else {
            operatorState.vaultStakedInDssMap[dss].remove(vault);
        }
    }

This allows requestUpdateVaultStakeInDSS to be called once again after the first one is finalized for the same vault and the corresponding call to the DSS executed, despite the vault being staked already for the DSS.

Tools Used

Manual analysis

Recommended Mitigation Steps

Check if the dssMap contains the vault already, and if yes revert.

Assessed type

Invalid Validation

@howlbot-integration howlbot-integration bot added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value 🤖_20_group AI based duplicate group recommendation bug Something isn't working duplicate-54 sufficient quality report This report is of sufficient quality labels Aug 1, 2024
howlbot-integration bot added a commit that referenced this issue Aug 1, 2024
@c4-judge
Copy link
Contributor

MiloTruck marked the issue as unsatisfactory:
Out of scope

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Aug 11, 2024
@c4-judge
Copy link
Contributor

MiloTruck marked the issue as not a duplicate

@c4-judge c4-judge reopened this Aug 11, 2024
@c4-judge c4-judge removed the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Aug 11, 2024
@c4-judge
Copy link
Contributor

MiloTruck removed the grade

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Aug 11, 2024
@c4-judge
Copy link
Contributor

MiloTruck marked the issue as unsatisfactory:
Invalid

@c4-judge
Copy link
Contributor

MiloTruck removed the grade

@c4-judge c4-judge reopened this Aug 11, 2024
@c4-judge c4-judge added primary issue Highest quality submission among a set of duplicates and removed unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels Aug 11, 2024
@c4-judge
Copy link
Contributor

MiloTruck marked the issue as primary issue

@c4-judge
Copy link
Contributor

MiloTruck changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Aug 11, 2024
@MiloTruck
Copy link

The warden has not demonstrated how this issue has an impact that meets the requirements for high/medium severity.

The vulnerability allows existing staked vaults to be staked again which might reinitialize or corrupt the states of the existing vault configuration for the DSS.

The impact highlighted here depends on the DSS implementation, which is not in-scope. You could also argue that it is the responsibility of the DSS to handle repeated calls to finalizeUpdateVaultStakeInDSS().

Therefore, this issue is QA at best.

@c4-judge
Copy link
Contributor

MiloTruck marked the issue as grade-b

@devdks25
Copy link

@C4-Staff C4-Staff added the Q-07 label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b primary issue Highest quality submission among a set of duplicates Q-07 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_20_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

4 participants