You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
sherlock-admin opened this issue
Mar 9, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
Nested linked trees could cause recursion stack overflow
Summary
There is no limit on the depth of nested linked trees. Hats protocol could suffer from recursion stack overflow because of the Solidity stack slots limit.
Vulnerability Detail
There are many recursive functions in the Hats.sol and HatsIdUtilities.sol. And they would traverse the linked trees. If the depth of the linked trees are too large, those functions could suffer from recursion stack overflow because of the Solidity stack slots limit.
Impact
Those recursive functions suffer from recursion stack overflow.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
GimelSec
medium
Nested linked trees could cause recursion stack overflow
Summary
There is no limit on the depth of nested linked trees. Hats protocol could suffer from recursion stack overflow because of the Solidity stack slots limit.
Vulnerability Detail
There are many recursive functions in the
Hats.sol
andHatsIdUtilities.sol
. And they would traverse the linked trees. If the depth of the linked trees are too large, those functions could suffer from recursion stack overflow because of the Solidity stack slots limit.Impact
Those recursive functions suffer from recursion stack overflow.
Code Snippet
https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/HatsIdUtilities.sol#L96
https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/HatsIdUtilities.sol#L184
https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/HatsIdUtilities.sol#L151
https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/HatsIdUtilities.sol#L194
https://github.com/Hats-Protocol/hats-protocol/blob/fafcfdf046c0369c1f9e077eacd94a328f9d7af0/src/Hats.sol#L831
Tool used
Manual Review
Recommendation
Don’t use recursive functions, use loops instead. Or add a limit on the depth of linked trees.
Duplicate of #96
The text was updated successfully, but these errors were encountered: