hats-finance / HATs-Arbitration-Contracts-0x79a618f675857b45934ca1c413fd5f409cf89735

MIT License
0 stars 0 forks source link

logClaim fee logic can be improved #62

Open hats-bug-reporter[bot] opened 8 months ago

hats-bug-reporter[bot] commented 8 months ago

Github username: -- Submission hash (on-chain): 0x45ccfbcddc569eb31c09a0c54b347e101d5783bd8cae7b7c8199ac991407331d Severity: low

Description: Description

When a user logs a claim, depending on if a claim fee is set, a user will have to pay a fee. The function checks if the amount sent by the user is less than the claim fee, however it doesn't account for cases where a user sends more than the required fee.

A user who sends more than the claimFee for any reason will lose his funds, which is not acceptable.

Attachments

  1. Proof of Concept (PoC) File

HatsVaultsRegistry

    function logClaim(string calldata _descriptionHash) external payable {
        uint256 _claimFee = generalParameters.claimFee;
        if (_claimFee > 0) { 
            if (msg.value < _claimFee) //@note only less
                revert NotEnoughFeePaid();
            // solhint-disable-next-line avoid-low-level-calls
            (bool success,) = payable(owner()).call{value: msg.value}("");
            if (!success) revert ClaimFeeTransferFailed();
        }
        emit LogClaim(msg.sender, _descriptionHash);
    }
  1. Revised Code File (Optional)

change the check;

if (msg.valiue != _claimFee)
jellegerbrandy commented 8 months ago

this is by design. Also, no funds are "lost" here