You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The token withdrawal implementation lacks proper validation of fee amounts against token amounts, which could lead to arithmetic underflow and potential loss of funds.
Root Cause
In the oapp_lz_receive.rs:117 the withdrawl logic performs unchecked substraction:
VaultAuthority needs to be initialized with proper PDA seeds and bump
user_deposit_wallet and vault_deposit_wallet need to be properly initialized Associated Token Accounts
Vault needs to have sufficient token balance to process withdrawals
External pre-conditions
LayerZero message needs to be properly formatted and contain withdrawal parameters
Cross-chain message needs to be successfully delivered and processed by LayerZero endpoint
Attack Path
Attacker crafts a malicious LayerZero message with fee greater than token_amount
Message is sent through LayerZero to solana chain
Message arrives and passes message validation checks
Withdrawal processing begins and attempts to subtract fee from token amount
This scenario occurs: If fee > token_amount: Arithmetic underflow causes transaction to fail or withdraw more from the vault
Impact
The protocol suffers a critical loss of funds due to arithmetic underflow in amount_to_transfer calculation. When fee > token_amount, the subtraction operation token_amount - fee will underflow , resulting in a very large number .
Example:
If token_amount = 100 and fee = 101 amount_to_transfer = token_amount - fee
In u64:100 - 101underflows to 18446744073709551615 (2^64 - 1)
The attacker can withdraw this massive amount of tokens from the vault
PoC
No response
Mitigation
No response
The text was updated successfully, but these errors were encountered:
sherlock-admin4
changed the title
Abundant Walnut Rooster - Missing Fee Validation in Token Withdrawal
davidkathoh - Missing Fee Validation in Token Withdrawal
Nov 6, 2024
davidkathoh
Medium
Missing Fee Validation in Token Withdrawal
Summary
The token withdrawal implementation lacks proper validation of fee amounts against token amounts, which could lead to arithmetic underflow and potential loss of funds.
Root Cause
In the
oapp_lz_receive.rs:117
the withdrawl logic performs unchecked substraction:https://github.com/sherlock-audit/2024-09-orderly-network-solana-contract/blob/main/solana-vault/packages/solana/contracts/programs/solana-vault/src/instructions/oapp_instr/oapp_lz_receive.rs#L117-L123
Internal pre-conditions
VaultAuthority
needs to be initialized with proper PDA seeds and bumpuser_deposit_wallet
andvault_deposit_wallet
need to be properly initialized Associated Token AccountsVault
needs to have sufficient token balance to process withdrawalsExternal pre-conditions
Attack Path
fee
greater thantoken_amount
Impact
The protocol suffers a critical loss of funds due to arithmetic underflow in
amount_to_transfer
calculation. Whenfee
>token_amount
, the subtraction operationtoken_amount - fee
will underflow , resulting in a very large number .Example:
If t
oken_amount
= 100 andfee
= 101amount_to_transfer = token_amount - fee
In u64:
100 - 101
underflows to18446744073709551615
(2^64 - 1)The attacker can withdraw this massive amount of tokens from the vault
PoC
No response
Mitigation
No response
The text was updated successfully, but these errors were encountered: