Closed sherlock-admin3 closed 3 months ago
1 comment(s) were left on this issue during the judging contest.
0xmystery commented:
Map is non-deterministic
The protocol team fixed this issue in the following PRs/commits: https://github.com/allora-network/allora-chain/pull/408
0x416
High
Non-deterministic approach to iterate over the map can result in inconsistent state between nodes and validators
Summary
Non-deterministic approach to iterate over the map can result in inconsistent state between nodes and validators
Vulnerability Detail
https://www.halborn.com/blog/post/top-5-security-vulnerabilities-cosmos-developers-need-to-watch-out-for
the third one applies to the current codebase:
the same issue is here in this line of code
these function is used by:
calling this function first time the function could return
[(worker1, weight1), (worker2, weigh2)]
then next time the function could return
[(worker2, weight2), (worker1, weight1)]
then the code access the array first time at index 0, the code get worker1 info,
then the code access the array second time at index 0, the code get worker2 info.
this would leads to inconsistent state between nodes for data saved from inference synthesis
Impact
this would leads to inconsistent state between nodes for data saved from inference synthesis
Code Snippet
https://github.com/sherlock-audit/2024-06-allora/blob/4e1bc73db32873476f8b0a88945815d3978d931c/allora-chain/x/emissions/keeper/inference_synthesis/common.go#L37
Tool used
Manual Review
Recommendation
the current code convert map to array, but the code should iterate over array instead of maps
Duplicate of #38