Open sherlock-admin4 opened 4 months ago
The protocol team fixed this issue in the following PRs/commits: https://github.com/andromedaprotocol/andromeda-core/pull/551
withdraw_fund
function is now working as an emergency for withdrawing funds (including locked rewards and funds to handle unexpected cases)
fix-reviews note:
https://github.com/andromedaprotocol/andromeda-core/pull/551
This PR removes the logic of execute_withdraw_fund()
to calculate the quantity, and directly withdraws all the balance, solving the problem of Slash
quantity difference
bin2chen
Medium
if Slash Validator occurs, UNSTAKING_QUEUE's unstake amount will not be accurate
Summary
UNSTAKING_QUEUE
holdsUnbondingDelegationEntry.initial_balance
. If aSlash Validator
occurs, which actually unstake amount isUnbondingDelegationEntry.balance
, this value will be smaller thanUnbondingDelegationEntry.initial_balance
which will causeexecute_withdraw_fund()
to fail.Vulnerability Detail
in
andromeda-validator-staking
We can get the stake funds back in the following waysx/staking
transfer funds (UnbondingDelegationEntry.balance=100) toandromeda-validator-staking
sender
fromandromeda-validator-staking
If it doesn't happen
Slash Validator
, balance == initial_balance https://github.com/cosmos/cosmos-sdk/blob/207b30262fc4ae62cb6fc7c2f6df1dfaf7bc1c4d/x/staking/proto/cosmos/staking/v1beta1/staking.proto#L238However, happen
Slash Validator
, the actual funds received will be less than the value recorded in the `UNSTAKING_QUEUE' record. https://github.com/cosmos/cosmos-sdk/tree/main/x/staking#slash-unbonding-delegationImpact
If a
Slash Validator
occurs, the value of theUNSTAKING_QUEUE
record will be less than the actual value received Resulting inCode Snippet
https://github.com/sherlock-audit/2024-05-andromeda-ado/blob/main/andromeda-core/contracts/finance/andromeda-validator-staking/src/contract.rs#L333
Tool used
Manual Review
Recommendation
when the balance is insufficient, only the balance is returned