Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Fixed proxy and caller validation (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayanski committed Jul 2, 2023
1 parent d4710f5 commit 0432aee
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions packages/abstract-adapter/src/endpoints/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,27 @@ impl<Error: ContractError, CustomInitMsg, CustomExecMsg, CustomQueryMsg, Receive
let proxy_address = deps.api.addr_validate(&requested_proxy)?;
let requested_core = account_registry.assert_proxy(&proxy_address)?;

// Load the authorized addresses for the given proxy address.
let authorized = self
.authorized_addresses
.load(deps.storage, proxy_address)
.map_err(Into::into)
.map_err(unauthorized_sender)?;

if authorized.contains(sender) {
// If the sender is an authorized address, return the account_base.
if requested_core.manager == sender {
// If the caller is the manager of the indicated proxy_address, it's authorized to do the operation
// This covers the case where the proxy field of the request is indicated where it doesn't need to be
requested_core
} else {
// If the sender is NOT an authorized address, check that it is a manager of some Account.
account_registry
.assert_manager(sender)
.map_err(unauthorized_sender)?
// If not, we load the authorized addresses for the given proxy address.
let authorized = self
.authorized_addresses
.load(deps.storage, proxy_address)
.map_err(Into::into)
.map_err(unauthorized_sender)?;
if authorized.contains(sender) {
// If the sender is an authorized address, return the account_base.
requested_core
} else {
// If not, we error, this call is not permitted
Err(AdapterError::UnauthorizedAddressAdapterRequest {
adapter: self.module_id().to_string(),
sender: sender.to_string(),
})?
}
}
}
None => account_registry
Expand Down

0 comments on commit 0432aee

Please sign in to comment.