Silent Failure in MustNewDecFromString Can Lead to Node Crashes
The AlloraExecutor's ExecuteFunction method uses MustNewDecFromString to convert strings to decimals, which panics on invalid input instead of returning an error. An attacker could supply invalid decimal strings to crash the node.
Source: https://github.com/sherlock-audit/2024-06-allora-judging/issues/22
The protocol has acknowledged this issue.
Found by
defsec
Summary
The use of MustNewDecFromString in the AlloraExecutor's ExecuteFunction method ignores potential errors, which can lead to invalid parameters being passed to the node, causing crashes.
Vulnerability Detail
In the ExecuteFunction method of the AlloraExecutor, MustNewDecFromString is used to convert string values to decimal types. This function panics if it encounters an error during conversion, rather than returning an error that can be handled gracefully. The code doesn't have any error handling or recovery mechanism for these potential panics.
For example:
infererValue := alloraMath.MustNewDecFromString(responseValue.InfererValue)
If responseValue.InfererValue is not a valid decimal string, this will cause a panic, which can crash the node if not caught.
Similar issues exist for other conversions in the code, such as those for forecaster values and various attributed values.
Impact
- Malicious actors could potentially exploit this to crash nodes by providing invalid input data.
- Unexpected panics can cause the node to crash.
Code Snippet
/cmd/node/main.go#L149, /cmd/node/main.go#L162, /cmd/node/main.go#L262
Tool used
Manual Review
Recommendation
Consider adding err check on the node software.
infererValue, err := alloraMath.NewDecFromString(responseValue.InfererValue)
if err != nil {
return result, fmt.Errorf("invalid inferer value: %w", err)
}
Discussion
sherlock-admin4
1 comment(s) were left on this issue during the judging contest.
0xmystery commented:
MustNewDecFromStringcan cause panic()
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 a panic-on-error conversion function without error handling or recovery.
Impact
Malicious actors could potentially exploit this to crash nodes by providing invalid input data.
What the attacker needed
Ability to provide input to the node
The fix
The code should be fixed by using a non-panicking conversion function and checking the returned error.
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.
A function that converts text to a number can fail if the text is not a valid number. The code uses a version that crashes the whole program on failure instead of handling the error. An attacker could send bad data to crash the node.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.