You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The contract call that uses DelegateCall must be protected with access controls that check the address of the caller. That's important because the untrusted code called with DelegateCall can change storage values of the caller.
Examples:
#[ink(message)]pubfnbad(&mutself,hash:Hash){let selector = ink::selector_bytes!("delegatee_fn");let _ = build_call::<DefaultEnvironment>().delegate(hash).exec_input(ExecutionInput::new(Selector::new(selector))).returns::<()>().try_invoke();// Bad: No access control}#[ink(message)]pubfngood(&mutself,hash:Hash){ifself.env().caller() == ALLOWED_USER{// Good: Access control is implementedlet selector = ink::selector_bytes!("delegatee_fn");let _ = build_call::<DefaultEnvironment>().delegate(hash).exec_input(ExecutionInput::new(Selector::new(selector))).returns::<()>().try_invoke();}}
The implementation should check all the invocations of the created call objects in MIR. Each invocation should be preceded by the condition that uses self.env().caller() or the hash of the delegatee contract.
The contract call that uses DelegateCall must be protected with access controls that check the address of the caller. That's important because the untrusted code called with
DelegateCall
can change storage values of the caller.Examples:
The implementation should check all the invocations of the created call objects in MIR. Each invocation should be preceded by the condition that uses self.env().caller() or the hash of the delegatee contract.
Reference: SWC-112
Related: #1965
The text was updated successfully, but these errors were encountered: