oappConfig init can be called multiple times to take control of the admin
Summary
In oapp_config.rs, init can be called multiple times to override the OAppConfig admin.
Root Cause
In oapp_config.init(), there is no access control check to ensure that this function can only be called once. Anyone can call the function again to take over the admin.
#[account]
pub struct OAppConfig {
pub endpoint_program: Pubkey,
pub bump: u8,
pub admin: Pubkey,
pub usdc_hash: [u8; 32],
pub usdc_mint: Pubkey,
pub initialized: bool, // New flag to track initialization status
}
In the init function, check if self.initialized is true. If it is, return an error. Otherwise, proceed with initialization and set initialized to true.
Droll Cider Armadillo
High
oappConfig init can be called multiple times to take control of the admin
Summary
In oapp_config.rs, init can be called multiple times to override the OAppConfig admin.
Root Cause
In oapp_config.init(), there is no access control check to ensure that this function can only be called once. Anyone can call the function again to take over the admin.
Internal pre-conditions
-
External pre-conditions
-
Attack Path
Attacker calls
init()
with a new set of parameters, setting himself as admin.Impact
Attacker can take control of most of the state of the protocol
PoC
https://github.com/sherlock-audit/2024-09-orderly-network-solana-contract/blob/main/solana-vault/packages/solana/contracts/programs/solana-vault/src/state/oapp_state/oapp_config.rs#L15
Mitigation
Add a bool field to the OAppConfig struct:
In the
init
function, check ifself.initialized
is true. If it is, return an error. Otherwise, proceed with initialization and set initialized to true.