Closed gangov closed 9 months ago
btw in that line of thoughts - we have the following:
pub struct TokenInitInfo {
pub token_wasm_hash: BytesN<32>,
pub token_a: Address,
pub token_b: Address,
}
and
pub struct StakeInitInfo {
pub stake_wasm_hash: BytesN<32>,
pub min_bond: i128,
pub max_distributions: u32,
pub min_reward: i128,
}
should we get rid of wasm
there, too?
The function
create_liquidity_pool
in thefactory
contract is used to deploy new pool contracts:The
deploy_lp_contract
function has the following logic:As we can see the
deploy_lp_contract
function deploys a new contract using the address of the current running contract, thesalt
computed withtokenA
andtokenB
, and with thelp_wasm_hash
.The issue is that as we can see from the
create_liquidity_pool
function is thatlp_wasm_hash
is provided as input to the function vialp_init_info.lp_wasm_hash
. So, a malicious user can make the factory to deploy arbitrary code.Impact
Users would expect that the code created via the phoenix factory is always the same.
Recommendation
The
lp_wasm_hash
should be saved into the instance storage of the contract instead of being provided via user input.