Skip to content

Commit

Permalink
fix: check sender in ibc_receive_internal_call in router and factory,…
Browse files Browse the repository at this point in the history
… comment typo
  • Loading branch information
joemonem committed Dec 16, 2024
1 parent b9de31c commit 93d14d5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/hub/router/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ pub fn execute_release_escrow(

ensure!(
transfer_amount.checked_add(remaining_withdraw_amount)? == amount,
ContractError::new("Amount mismatch after trasnfer calculations")
ContractError::new("Amount mismatch after transfer calculations")
);

if !transfer_amount.is_zero() {
Expand Down
4 changes: 4 additions & 0 deletions contracts/hub/router/src/ibc/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ pub fn ibc_receive_internal_call(
info: MessageInfo,
msg: IbcPacketReceiveMsg,
) -> Result<Response, ContractError> {
ensure!(
info.sender == env.contract.address,
ContractError::Unauthorized {}
);
// Get the chain data from current channel received
let channel = msg.packet.dest.channel_id;
let chain_uid = CHANNEL_TO_CHAIN_UID.load(deps.storage, channel)?;
Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity/factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub fn execute(
ibc::ack_and_timeout::ibc_ack_packet_internal_call(deps, info, env, ack)
}
ExecuteMsg::IbcCallbackReceive { receive_msg } => {
ibc::receive::ibc_receive_internal_call(deps, env, receive_msg)
ibc::receive::ibc_receive_internal_call(deps, env, info, receive_msg)
}
ExecuteMsg::NativeReceiveCallback { msg } => {
execute_native_receive_callback(deps, env, info, msg)
Expand Down
8 changes: 7 additions & 1 deletion contracts/liquidity/factory/src/ibc/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use cosmwasm_std::entry_point;
use cosmwasm_std::{
ensure, from_json, to_json_binary, CosmosMsg, DepsMut, Env, IbcPacketReceiveMsg,
IbcReceiveResponse, Response, StdError, SubMsg, Uint128, WasmMsg,
IbcReceiveResponse, MessageInfo, Response, StdError, SubMsg, Uint128, WasmMsg,
};
use euclid::{
chain::{ChainUid, CrossChainUserWithLimit},
Expand Down Expand Up @@ -54,8 +54,14 @@ pub fn ibc_packet_receive(
pub fn ibc_receive_internal_call(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: IbcPacketReceiveMsg,
) -> Result<Response, ContractError> {
ensure!(
info.sender == env.contract.address,
ContractError::Unauthorized {}
);

let router = msg.packet.src.port_id.replace("wasm.", "");
let state = STATE.load(deps.storage)?;
ensure!(
Expand Down

0 comments on commit 93d14d5

Please sign in to comment.