-
Notifications
You must be signed in to change notification settings - Fork 0
chaduke - noCircularLinkage() might fail to detect circles in the tree #28
Comments
This is not a duplicate of #96 since it deals with circular admins rather than a DOS/stack-too-deep issue stemming from recursion. |
I'm still thinking this through, but I think that we can rely on the fact that if there is an undetectable circle then there will be infinite recursion, which (as noted) will result in a revert. While not as clean as bubbling up the TODO:
|
Upon further inspection, I don't think this is an issue because it would not be possible to enter into this scenario in the first place. In the poc test above, |
Escalate for 10 USDC This scenario cannot happen, because |
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 accepted Not a valid issue |
This issue's escalations have been accepted! Contestants' payouts and scores will be updated according to the changes made on this issue. |
chaduke
medium
noCircularLinkage() might fail to detect circles in the tree
Summary
noCircularLinkage(A, B)
can detect circles that A is involved, but fail to detect the presence of circles of the whole tree in which A is not involved. As a result, when there is a circle in other branches of the tree, the function will get into infinite recursion and revert due to out of gas. The function will fail to detect when there is a circle in another branch that A is not part of.Vulnerability Detail
The main issue of
noCircularLinkage(A, B)
is that it assumes: if there is a circle in the tree, then A must be involved. However, circles might exist in various branches, not just in the branch of A.https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/HatsIdUtilities.sol#L194-L200
In the following code POC, we show that five tophats 1, 2, 3, 4, 5, when there is a cycle 2->3->4->5->3, and 1 is not involved, then
noCircularLinkage(1, 2)
will fail to detect the circle and revert due to infinite recursion.Impact
noCircularLinkage() might fail to detect circles in the tree.
This might create circular management and confuse the power hierarchy in an organization. In addition, many functions (those that use recursions) will revert due to out of gas since they depend on the the property that there is no circle in the tree. For example,
getHatLevel()
will revert when there is a circle in the tree.Code Snippet
See above
Tool used
VSCode
Manual Review
Recommendation
The text was updated successfully, but these errors were encountered: