Non-deterministic Ranges in Inference Synthesis Causing Inconsistent State Across Nodes
The inference synthesis process uses non-deterministic ranges, causing different nodes to produce inconsistent state. This can lead to inconsistent inference and forecast results, difficulty in debugging, potential data corruption, and consensus issues.
Source: https://github.com/sherlock-audit/2024-06-allora-judging/issues/38
Found by
0x416, defsec, imsrybr0, volodya
Summary
In the inference_synthesis package, the inference synthesis process is utilizing non-deterministic ranges. This non-deterministic behavior can lead to inconsistent state across different nodes, particularly for any data saved from the inference synthesis. The inconsistency can cause significant issues in the system's overall functionality and reliability.
Vulnerability Detail
In the inference_synthesis package, the inference synthesis process is utilizing non-deterministic ranges. This non-deterministic behavior can lead to inconsistent state across different nodes, particularly for any data saved from the inference synthesis. The inconsistency can cause significant issues in the system's overall functionality and reliability.
The code section in question involves creating deep copies of various maps and structs within the SynthPalette struct. While the cloning function is properly creating deep copies, the inference synthesis process itself is not deterministic, which leads to the described issue.
Impact
This issue can cause multiple nodes in a distributed system to have differing states due to the non-deterministic ranges used during inference synthesis. This can result in:
- Inconsistent inference and forecast results across nodes.
- Difficulty in debugging and maintaining the system due to unpredictable state changes.
- Potential data corruption or loss of data integrity, which can affect overall system performance and reliability.
- Issues in consensus mechanisms if nodes cannot agree on a single state.
Code Snippet
synth_palette_bootstrap.go#L58-L82
func (p SynthPalette) Clone() SynthPalette {
inferenceByWorker := make(map[Worker]*emissionstypes.Inference, len(p.InferenceByWorker))
for k, v := range p.InferenceByWorker {
inferenceCopy := *v
inferenceByWorker[k] = &inferenceCopy
}
forecastByWorker := make(map[Worker]*emissionstypes.Forecast, len(p.ForecastByWorker))
for k, v := range p.ForecastByWorker {
forecastCopy := *v
forecastByWorker[k] = &forecastCopy
}
forecastImpliedInferenceByWorker := make(map[Worker]*emissionstypes.Inference, len(p.ForecastImpliedInferenceByWorker))
for k, v := range p.ForecastImpliedInferenceByWorker {
inferenceCopy := *v
forecastImpliedInferenceByWorker[k] = &inferenceCopy
}
infererRegrets := make(map[Worker]*StatefulRegret, len(p.InfererRegrets))
for k, v := range p.InfererRegrets {
regretCopy := *v
infererRegrets[k] = ®retCopy
}
forecasterRegrets := make(map[Worker]*StatefulRegret, len(p.ForecasterRegrets))
for k, v := range p.ForecasterRegrets {
regretCopy := *v
forecasterRegrets[k] = ®retCopy
}
Tool used
Manual Review
Recommendation
- Review the inference synthesis process and identify the sources of non-determinism.
- Ensure that all ranges and related calculations are deterministic, i.e., they produce the same output given the same input across all nodes.
Discussion
sherlock-admin3
1 comment(s) were left on this issue during the judging contest.
0xmystery commented:
Map is non-deterministic
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/allora-network/allora-chain/pull/408
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the use of non-deterministic ranges (such as iterating over maps) in the inference synthesis process causes different nodes to compute different results.
Impact
Multiple nodes may have differing states, leading to inconsistent inference and forecast results, debugging difficulties, potential data corruption, and consensus issues.
What the attacker needed
None
The fix
The protocol team fixed this issue in the referenced PRs/commits.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a blockchain, all nodes must compute the same result from the same input. Here, the code used a method that could produce different results on different nodes, so they might disagree on the state. This can break the system's reliability.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.