Any user can call this instruction and pass any account as the rebate_to account
Attack Path
Calling the swap instruction and passing any account to the rebate_to account is enough to trigger this functionality
Impact
There is little impact as these account is only emitted through an event but this emitted event could be used to trick event listeners in the case of an actual attack scenario.
PoC
Passing any account into the rebate_to account when the swap instruction is called
Mitigation
Validate rebate_to account by performing the following steps
Step 2
Make the state module public
pub mod state;
Step 3
Verify rebate_to account is owned by the rebate_manager program and add other custom checks
rebate_to: Account<'info, rebate_manager::state::rebate_info::RebateInfo>, in swap.rs
chinepun
Medium
Rebate_to account not validated during Swapping
Summary
There is a missing check to the rebate account when swapping is performed, hence any account could be passed into the rebate account.
Root Cause
rebate_to account not validated
Internal pre-conditions
Any user can call this instruction and pass any account as the
rebate_to
accountAttack Path
Calling the
swap
instruction and passing any account to therebate_to
account is enough to trigger this functionalityImpact
There is little impact as these account is only emitted through an event but this emitted event could be used to trick event listeners in the case of an actual attack scenario.
PoC
Passing any account into the
rebate_to
account when theswap
instruction is calledMitigation
Validate
rebate_to
account by performing the following stepsStep 1 Add
to Cargo.toml
Step 2 Make the state module public
pub mod state;
Step 3 Verify
rebate_to
account is owned by therebate_manager
program and add other custom checksrebate_to: Account<'info, rebate_manager::state::rebate_info::RebateInfo>,
inswap.rs