This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
carrot - Hats can be overwritten #11
Labels
Fix Approved
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
Hats.sol
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
carrot
high
Hats can be overwritten
Summary
Child hats can be created under a non-existent admin. Creating the admin allows overwriting the properties of the child-hats, which goes against the immutability of hats.
Vulnerability Detail
When creating a hat, the code never checks if the admin passed actually exists or not. Thus it allows the creation of a hat under an admin who hasn't been created yet.
Lets say top hat is 1.0.0, and we call admin the hat 1.1.0 and child is hat 1.1.1. The child can be created before admin. When admin (1.1.0) is created after this, it overwrites the
lastHatId
of the admin, as shown herehttps://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/Hats.sol#L421-L439
Now, the next eligible hat for this admin is 1.1.1, which is a hat that was already created and minted. This can allow the admin to change the properties of the child, even if the child hat was previously immutable.
This contradicts the immutability of hats, and can be used to rug users in multiple ways, and is thus classified as high severity.
This attack can be carried out by any hat wearer on their child tree, mutating their properties.
Impact
Code Snippet
The attack can be demonstrated with the following code which carries out the following steps:
Tool used
Manual Review
Recommendation
Check if admin exists, before minting by checking any of its properties against default values
The text was updated successfully, but these errors were encountered: