Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

GimelSec - Nested linked trees could cause recursion stack overflow #102

Closed
sherlock-admin opened this issue Mar 9, 2023 · 0 comments
Closed
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Mar 9, 2023

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 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.

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

@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Mar 12, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant