reset_vault.rs and reinit_vault.rs does not work as intended
Summary
When reset_vault.apply() is called, the ownership of the vault authority program is given back to the system and the space in vault authority is set to zero.
When that happens, it is not possible to reinit() the vault since the ownership is currently the Solana System Program. Also, there is no reallocation of required space when reinitializing the vault.
Root Cause
In ResetVault, the vault_authority is assigned to the system and the data space is reduced to zero:
The ownership of vault_authority is already the Solana System Program
The vault is already initialized, but there is no storage space give to the reinitialization.
For reference, this is how delete_account() works in the Solana program. The account is sent to the system and the data size is set to zero. This account cannot be retrieved and reinitialized.
/// Helper function to totally delete an account on-chain
#[cfg(target_os = "solana")]
fn delete_account(account_info: &AccountInfo) -> Result<(), ProgramError> {
account_info.assign(&system_program::id());
account_info.realloc(0, false)
}
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
reset_vault and reinit_vault does not work.
PoC
No response
Mitigation
Remove the assign line to transfer of ownership to Solana system program.
When calling reinit.apply, reallocate space for the vault:
Droll Cider Armadillo
Medium
reset_vault.rs and reinit_vault.rs does not work as intended
Summary
When
reset_vault.apply()
is called, the ownership of the vault authority program is given back to the system and the space in vault authority is set to zero.When that happens, it is not possible to
reinit()
the vault since the ownership is currently the Solana System Program. Also, there is no reallocation of required space when reinitializing the vault.Root Cause
In ResetVault, the
vault_authority
is assigned to the system and the data space is reduced to zero:In reinit_vault.rs, the function
apply()
attempts to reinitialize the existingvault_authority
.This will not work for two reasons.
vault_authority
is already the Solana System ProgramFor reference, this is how
delete_account()
works in the Solana program. The account is sent to the system and the data size is set to zero. This account cannot be retrieved and reinitialized.Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
reset_vault
andreinit_vault
does not work.PoC
No response
Mitigation