Skip to content

Commit

Permalink
feat: adding mint address validation at create (#17)
Browse files Browse the repository at this point in the history
Fixes HAL-002

> ## Description
> After the user invokes the process_init entry point, they need to
invoke the process_create entry point to store the necessary information
to participate in the token locking process.
> 
> A piece of information that the user has to provide is the source
token account, where the tokens will be subtracted to participate.
> 
> The mentioned token account is not validated to be a token account
corresponding to the L3 token, which is expected to be the token used.
> 
> As a result, any user can create a vesting_account that does with any
token different than L3 token.
> 
> The L3 team mentioned that this situation does not represent a risk,
since the information on chain will be used on an off-chain process.
> 
> However, it is considered a good practice to restrict the
functionalities of a program used in production to narrow down the
attack surface in order to prevent unexpected behaviors.
  • Loading branch information
wei3erHase authored Oct 4, 2024
1 parent 7e7cde4 commit a0e0289
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ use crate::{
state::{pack_schedule_into_slice, unpack_schedule, VestingSchedule, VestingScheduleHeader},
};

pub const VALID_TOKEN_MINT: Pubkey =
solana_program::pubkey!("AxfBPA1yi6my7VAjqB9fqr1AgYczuuJy8tePnNUDDPpW");

pub struct Processor {}

impl Processor {
Expand Down Expand Up @@ -90,6 +93,12 @@ impl Processor {
mint_address: &Pubkey,
schedule: Schedule,
) -> ProgramResult {
// Validate the mint address matches the expected token address
if *mint_address != VALID_TOKEN_MINT {
msg!("Unsuported token mint address");
return Err(ProgramError::InvalidArgument);
}

let accounts_iter = &mut accounts.iter();

let spl_token_account = next_account_info(accounts_iter)?;
Expand Down

0 comments on commit a0e0289

Please sign in to comment.