code-423n4 / 2023-06-stader-findings

1 stars 1 forks source link

Problem with ValiodatorStatus.INITIALIZED #330

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-06-stader/blob/7566b5a35f32ebd55d3578b8bd05c038feb7d9cc/contracts/library/ValidatorStatus.sol#L4-L11 https://github.com/code-423n4/2023-06-stader/blob/7566b5a35f32ebd55d3578b8bd05c038feb7d9cc/contracts/PermissionlessNodeRegistry.sol#L712-L716

Vulnerability details

Impact

Detailed description of the impact of this finding. The default value for Enums in solidity are always the first parameters in them. In the ValidatorStatus Enum however, INITIALIZED is the first value and therefore the default value of the ValidatorStatus for all addresses checked.

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.

function onlyInitializedValidator(uint256 _validatorId) internal view {
        if (_validatorId == 0 || validatorRegistry[_validatorId].status != ValidatorStatus.INITIALIZED) {
            revert UNEXPECTED_STATUS();
        }
    }

enum ValidatorStatus {
    INITIALIZED,
    INVALID_SIGNATURE,
    FRONT_RUN,
    PRE_DEPOSIT,
    DEPOSITED,
    WITHDRAWN
}

Tools Used

Manual review

Recommended Mitigation Steps

I suggest a diferent value for the first ValidatorStatus paramater. e.g UNINITIALIZED

Assessed type

Invalid Validation

Picodes commented 1 year ago

And so? How can this be used for an attack? Or what's the impact?

c4-judge commented 1 year ago

Picodes marked the issue as unsatisfactory: Invalid