-
Notifications
You must be signed in to change notification settings - Fork 0
obront - Changing hat toggle address can lead to unexpected changes in status #34
Comments
The risk here is limited since toggle modules are treated as the source of truth for hat status and so admins should be aware that changing the toggle also changes the source of truth. But the recommended fix is simple and cheap enough that it makes sense to apply. @zobront, does this same concept apply to eligibility? |
@spengrah Agreed. The only situation I think would break a user's assumption is a change from contract => EOA, because in most cases the toggle will be saved in The same is true with |
Escalate for 10 USDC Disagree with being sever enough for being a medium. The Sherlock doc state "The vulnerability must be something that is not considered an acceptable risk by a reasonable protocol team." However, as was explained, this problem is present both for As noted in the comment by spengrah, the fix was implemented mostly because it is not expensive to do so, even though the risk is limited. |
You've created a valid escalation for 10 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Escalation rejected The issue is a valid medium |
This issue's escalations have been rejected! Watsons who escalated this issue will have their escalation amount deducted from their next payout. |
zobront added "Fix Approved" label |
obront
medium
Changing hat toggle address can lead to unexpected changes in status
Summary
Changing the toggle address should not change the current status unless intended to. However, in the event that a contract's toggle status hasn't been synced to local state, this change can accidentally toggle the hat back on when it isn't intended.
Vulnerability Detail
When an admin for a hat calls
changeHatToggle()
, thetoggle
address is updated to a new address they entered:Toggle addresses can be either EOAs (who must call
setHatStatus()
to change the local config) or contracts (who must implement thegetHatStatus()
function and return the value).The challenge comes if a hat has a toggle address that is a contract. The contract changes its toggle value to
false
but is never checked (which would push the update to the local state). The admin thus expects that the hat is turned off.Then, the toggle is changed to an EOA. One would expect that, until a change is made, the hat would remain in the same state, but in this case, the hat defaults back to its local storage state, which has not yet been updated and is therefore set to
true
.Even in the event that the admin knows this and tries to immediately toggle the status back to
false
, it is possible for a malicious user to sandwich their transaction between the change to the EOA and the transaction to toggle the hat off, making use of a hat that should be off. This could have dramatic consequences when hats are used for purposes such as multisig signing.Impact
Hats may unexpectedly be toggled from
off
toon
during toggle address transfer, reactivating hats that are intended to be turned off.Code Snippet
https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/Hats.sol#L623-L636
Tool used
Manual Review
Recommendation
The
changeHatToggle()
function needs to callcheckHatToggle()
before changing over to the new toggle address, to ensure that the latest status is synced up.The text was updated successfully, but these errors were encountered: