admin can specity which tokens can deposit into solana vault and for every token a token hash will be generated and when a user want to deposit into vault they should send token hash as a parameter and based on that solana vault give them permission to deposit into vault but this is a wrong and malicious user can bypass that
PoC
Textual PoC:
1-admin call set_token with usdc as parameter,its mean users just can deposit usdc
2-malicious user mints a fake token and then create a token account with fake token
3-malicious user call deposit instruction with token account belongs to fake token and token hash generated for usdc as a paramter
4-deposit function send a message to layer zero with usdc token hash as a parameter
5-ledger will be updated by received message from layer zero
6-malicious user requests withdrawal siguature
7-orderly network execute user's withdrawal request and send usdc to receiver instead of fake token
Coded PoC:
please run commands based on readme and then replace 05deposit_vault.ts
Petite Pecan Starfish
High
malicious user can drain solana vault
Summary
malicious user can drain solana vault
Root Cause
admin can specity which tokens can deposit into solana vault and for every token a token hash will be generated and when a user want to deposit into vault they should send token hash as a parameter and based on that solana vault give them permission to deposit into vault but this is a wrong and malicious user can bypass that
PoC
Textual PoC: 1-admin call set_token with usdc as parameter,its mean users just can deposit usdc 2-malicious user mints a fake token and then create a token account with fake token 3-malicious user call deposit instruction with token account belongs to fake token and token hash generated for usdc as a paramter 4-deposit function send a message to layer zero with usdc token hash as a parameter 5-ledger will be updated by received message from layer zero 6-malicious user requests withdrawal siguature 7-orderly network execute user's withdrawal request and send usdc to receiver instead of fake token
Coded PoC: please run commands based on readme and then replace 05deposit_vault.ts
PoC
```typescript import * as anchor from "@coral-xyz/anchor"; import { Keypair, PublicKey, SystemProgram, Transaction, ComputeBudgetProgram, sendAndConfirmTransaction } from "@solana/web3.js"; import { hexlify } from '@ethersproject/bytes' import { OftTools } from "@layerzerolabs/lz-solana-sdk-v2"; import { Options } from "@layerzerolabs/lz-v2-utilities"; import * as utils from "./utils"; import * as constants from "./constants"; import { PacketPath } from '@layerzerolabs/lz-v2-utilities' import { EndpointProgram, EventPDADeriver, SimpleMessageLibProgram, UlnProgram } from '@layerzerolabs/lz-solana-sdk-v2' import OAppIdl from "../target/idl/solana_vault.json"; import { SolanaVault } from "../target/types/solana_vault"; import { utf8 } from "@coral-xyz/anchor/dist/cjs/utils/bytes"; const OAPP_PROGRAM_ID = new PublicKey(OAppIdl.metadata.address); const OAppProgram = anchor.workspace.SolanaVault as anchor.ProgramCode Snippet
https://github.com/sherlock-audit/2024-09-orderly-network-solana-contract/blob/main/solana-vault/packages/solana/contracts/programs/solana-vault/src/instructions/vault_instr/deposit.rs#L85
Impact
1-malicious user can bypass allowed token hash 2-malicious user can drain vault
Mitigation
consider to generate token hash in deposit instruction instead of get that from user