This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
rvierdiiev - Hat wearer can call function with limited amount of gas in order to make toggle call revert and use previous active status #20
Labels
Escalation Resolved
This issue's escalations have been approved/rejected
Non-Reward
This issue will not receive a payout
rvierdiiev
high
Hat wearer can call function with limited amount of gas in order to make toggle call revert and use previous active status
Summary
Hat wearer can call function with limited amount of gas in order to make toggle call revert and use previous active status
Vulnerability Detail
Each hat has
toggle
address, which controls if has is active. Once hat is not active, then it's not calculated inside user's balance. In other words, in case if hat is not active, then user any user that has this hat token, doesn't actually wear a hat and his balance is 0.https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/Hats.sol#L1149-L1162
This is how
_isActive
is implemented.https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/Hats.sol#L890-L917
As you can see, it tries to get result from
toggle
address, which should say if hat is still active.It's possible that toggle is eoa or address 0. In this case it will just call
_getHatStatus(_hat)
in order to retrieve info from hat.config.Also
toggle
can be smart contract. In this case it will return result which then will be returned.It's also possible for attacker to run this function with limited amount of gas in order to revert
toggle
call with out of gas error. In that case, function will use_getHatStatus
function to get status. For this call to succeed it's needed to havetoggle
contract with big logic, so function_isActive
callstoggle.getHatStatus
with 63/64 of gas sent to the_isActive
function, which is not enough, sotoggle.getHatStatus
reverts and remaining 1/64 gas is still enough to finish function that attacker called.Suppose, that
hat
is active now and there istoggle
contract for that hat. The next call totoggle.getHatStatus
will return false and will freeze all hat wearers.So maybe someone is going to call
checkHatStatus
, which will reset hat status in config to non active.But attacker(which is any hat wearer) can frontrun that call.
He can call next function with limited amount of gas(to make
toggle
call revert) and still be hat wearer.This gives attacker ability to still call function as he is wearing a hat, because of that he can pass
_checkAdmin
restriction, so he can make changes likechangeHatToggle
,changeHatEligibility
,mintHat
.Using this trick he can try to call
approveLinkTopHatToTree
which is using_checkAdminOrWearer
function, which callsisWearerOfHat
function, which checks user's balance.After
checkHatStatus
function will be called, then hat status will be set to false and wearer will not be able to use that trick anymore.Impact
User can pass toggle checking.
Code Snippet
Provided above
Tool used
Manual Review
Recommendation
Maybe in case of toggle call is reverted, you need to revert too.
The text was updated successfully, but these errors were encountered: