sherlock-audit / 2024-06-boost-aa-wallet-judging

3 stars 1 forks source link

RealMaushish - Incorrect casting in `SignerValidator.sol` #449

Open sherlock-admin4 opened 1 month ago

sherlock-admin4 commented 1 month ago

RealMaushish

High

Incorrect casting in SignerValidator.sol

Summary

SignerValidator.sol#Validate() checks one condition in which it ensure that incentive quantity is lower or equal to incentiveID

Vulnerability Detail

SignerValidator.sol#Validate() checks make sure that incentive quantity is lower or equal to incentiveID

 function validate(uint256 boostId, uint256 incentiveId, address claimant, bytes calldata claimData)
        external
        override
        returns (bool)
    {
        if (msg.sender != _validatorCaller) revert BoostError.Unauthorized();

        (BoostClaimData memory claim) = abi.decode(claimData, (BoostClaimData));
        (SignerValidatorInputParams memory validatorData) =
            abi.decode(claim.validatorData, (SignerValidatorInputParams));

        bytes32 hash = hashSignerData(boostId, validatorData.incentiveQuantity, claimant, claim.incentiveData);

        if (uint256(validatorData.incentiveQuantity) <= incentiveId) {
            revert BoostError.InvalidIncentive(validatorData.incentiveQuantity, incentiveId);
        }
        if (!signers[validatorData.signer]) revert BoostError.Unauthorized();

        // Mark the incentive as claimed to prevent replays
        // checks internally if the incentive has already been claimed
        _used.setOrThrow(hash, incentiveId);

        // Return the result of the signature check
        // no need for a sig prefix since it's encoded by the EIP712 lib
        return validatorData.signer.isValidSignatureNow(hash, validatorData.signature);
    }

here lies the issue:

But clearly there is a lack of check for such design choice

Impact

Users wont be able to claim incentives as the quantity will be maximum which will make the check revert

Code Snippet

https://github.com/sherlock-audit/2024-06-boost-aa-wallet/blob/main/boost-protocol/packages/evm/contracts/validators/SignerValidator.sol#L50

Tool used

Manual Review

Recommendation