This repository has been archived by the owner on Jan 19, 2025. It is now read-only.
LZ_security - The SelectTopNWorkerNonces function lacks a sorting algorithm internally. #96
Labels
Medium
A 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
LZ_security
Medium
The SelectTopNWorkerNonces function lacks a sorting algorithm internally.
Summary
The SelectTopNWorkerNonces function lacks a sorting algorithm internally and only selects N workers from the array.
Vulnerability Detail
We can see that the function lacks a sorting algorithm and only selects N workers from the array. The SelectTopNWorkerNonces function is used in the requestTopicWorkers function.
It can be seen that workerNonces is unsorted data, and after being processed by synth.SelectTopNWorkerNonces, it only selects N workers from the array rather than selecting the latest N workers based on the Nonce.
Impact
It does not select the top N latest worker nonces as intended. Moreover, selecting workers not within the top might result in choosing workers that are already offline or not able to return the desired data correctly.
Code Snippet
https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/x/emissions/keeper/inference_synthesis/nonce_mgmt.go#L51
https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/app/topics_handler.go#L71
Tool used
Manual Review
Recommendation
Add the SortByBlockHeight function within the SelectTopNWorkerNonces function.
The text was updated successfully, but these errors were encountered: