Closed sherlock-admin2 closed 3 months ago
1 comment(s) were left on this issue during the judging contest.
0xmystery commented:
GetIdsOfActiveTopics
incorrectly assumes that IDs of active topics are always sequential
The protocol team fixed this issue in the following PRs/commits: https://github.com/allora-network/allora-chain/pull/406
Based on the discussion under #115 planning to invalidate this report as it doesn’t have medium or high impact
defsec
Medium
Pagination method fails to return complete pages for non-consecutive active topic IDs
Summary
The current implementation of
GetIdsOfActiveTopics
does not correctly handle cases where active topic IDs are non-consecutive, potentially returning incomplete pages of results.Vulnerability Detail
The
GetIdsOfActiveTopics
function uses a range-based iteration approach that assumes topic IDs are consecutive. When there are gaps in the active topic ID sequence, this method may return fewer results than requested, even when more active topics exist.For example, if topic IDs 1 and 3 are active, but 2 is not, a request for 2 items might only return ID 1, missing ID 3.
Example case :
Impact
This issue can lead to:
Code Snippet
keeper.go#L1605
Tool used
Manual Review
Recommendation
Modify the
GetIdsOfActiveTopics
function to ensure it returns the correct number of active topic IDs, regardless of gaps in the ID sequence. This could involve:Here's a high-level pseudocode example of how the function could be modified: