sherlock-audit / 2024-06-allora-judging

0 stars 0 forks source link

abdulsamijay - Negative Stake & DelegateStek Amounts Causes Runtime Panic #119

Closed sherlock-admin2 closed 3 months ago

sherlock-admin2 commented 3 months ago

abdulsamijay

Medium

Negative Stake & DelegateStek Amounts Causes Runtime Panic

Summary

The Allora AppChain's staking mechanism allows for negative stake amounts to be processed. This issue arises from the absence of checks for negative values in the AddStake and AddDelegateStake functions. When a negative stake amount is provided, the system panics at runtime, this might lead to an unexpected behavior

Vulnerability Detail

n the Allora AppChain, the functions AddStake and AddDelegateStake are responsible for adding stakes to become a reputer and delegating stakes to a reputer, respectively. Both functions include checks to ensure that the amount is not zero. However, there is no check to prevent negative values from being processed. This oversight can lead to runtime panics when a negative stake amount is provided, temporarily disrupting the normal operation of the network.

// Delegates a stake to a reputer. Sender need not be registered to delegate stake. func (ms msgServer) DelegateStake(ctx context.Context, msg types.MsgDelegateStake) (types.MsgDelegateStakeResponse, error) { if msg.Amount.IsZero() { return nil, types.ErrReceivedZeroAmount }


## Impact
Leads to a runtime panic which may cause unexpected or undefined behaviour.
<img width="1317" alt="image" src="https://github.com/user-attachments/assets/8677aaca-017f-44ff-8234-28847c19b370">

## Tool used
Manual Review

## Recommendation
It is recommended to implement a check for negative stake amounts in both the `AddStake` and `AddDelegateStake` functions.
sherlock-admin4 commented 3 months ago

1 comment(s) were left on this issue during the judging contest.

0xmystery commented:

Negative value in stake-specific functions causes panic() which permanently halts chain

sherlock-admin2 commented 3 months ago

The protocol team fixed this issue in the following PRs/commits: https://github.com/allora-network/allora-chain/pull/441

imsrybr0 commented 2 months ago

Escalate

This is not a duplicate of #21 and should be invalid as it will not halt the chain.

The panic will be handled by the RunTx recovery mechanism and the transaction will just fail for the user sending an incorrect input without any impact on the chain or other users.

sherlock-admin3 commented 2 months ago

Escalate

This is not a duplicate of #21 and should be invalid as it will not halt the chain.

The panic will be handled by the RunTx recovery mechanism and the transaction will just fail for the user sending an incorrect input without any impact on the chain or other users.

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

abdulsamijay commented 2 months ago

The panic will be handled by the RunTx recovery mechanism and the transaction will just fail for the user sending an incorrect input without any impact on the chain or other users.

Hi, I agree that the RunTx recovery mechanism will cause the transaction to fail for the user sending incorrect input, but I believe this should still be considered a valid issue as it indicates a mishandled bug.

I was thinking more about the potential for different users continuously sending invalid amounts, which could cause runtime panics for a validator node. This might lead to performance issues, block delays, or even undefined behavior therefore I assigned this as medium.

Regarding the final severity, I leave it the the judges

WangSecurity commented 2 months ago

I agree that the report doesn't identify medium severity impact. Hence, should be invalid based on the current duplication rules:

The duplication rules assume we have a "target issue", and the "potential duplicate" of that issue needs to meet the following requirements to be considered a duplicate. Identify the root cause Identify at least a Medium impact Identify a valid attack path or vulnerability path Fulfills other submission quality requirements (e.g. provides a PoC for categories that require one) Only when the "potential duplicate" meets all three requirements will the "potential duplicate" be duplicated with the "target issue", and all duplicates will be awarded the highest severity identified among the duplicates.

Planning to accept the escalation and invalidate this report.

mystery0x commented 2 months ago

Escalate

This is not a duplicate of #21 and should be invalid as it will not halt the chain.

The panic will be handled by the RunTx recovery mechanism and the transaction will just fail for the user sending an incorrect input without any impact on the chain or other users.

I agree that panic will be handled by the recovery mechanism. I would consider this issue invalid since there is no longer any impact.

WangSecurity commented 2 months ago

Result: Invalid Unique

sherlock-admin4 commented 2 months ago

Escalations have been resolved successfully!

Escalation status: