Описание
ink! vulnerable to incorrect decoding of storage value when using DelegateCall
Summary
The return value when using delegate call mechanics, either through CallBuilder::delegate or ink_env::invoke_contract_delegate, is being decoded incorrectly.
Description
Consider this minimal example:
In this example we are executing the Callee code in the context of the Caller contract. This means we'll be using the storage values of the Caller contract.
Running this code we expect the delegate call to return value as it was stored in the Caller contract. However, due to the reported bug a different value is returned (for the case of uints it is 256 times the expected value).
Impact
After conducting an analysis of the on-chain deployments of ink! contracts on Astar, Shiden, Aleph Zero, Amplitude and Pendulum, we have found that no contracts on those chains have been affected by the issue.
This bug was related to the mechanics around decoding a call's return buffer, which was changed as part of https://github.com/paritytech/ink/pull/1450. Since this feature was only released in ink! 4.0.0 no previous versions are affected.
Mitigations
If you have an ink! 4.x series contract, please update it to the 4.2.1 patch release that we just published.
Credits
Thank you Facundo Lerena from CoinFabrik for reporting this problem in a well-structured and responsible way.
Ссылки
- https://github.com/paritytech/ink/security/advisories/GHSA-853p-5678-hv8f
- https://nvd.nist.gov/vuln/detail/CVE-2023-34449
- https://github.com/paritytech/ink/pull/1450
- https://github.com/paritytech/ink/commit/f1407ee9f87e5f64d467a22d26ee88f61db7f3db
- https://docs.rs/ink_env/4.2.0/ink_env/call/struct.CallBuilder.html#method.delegate
- https://docs.rs/ink_env/4.2.0/ink_env/fn.invoke_contract_delegate.html
Пакеты
ink
>= 4.0.0, < 4.2.1
4.2.1
ink_env
>= 4.0.0, < 4.2.1
4.2.1
Связанные уязвимости
ink! is an embedded domain specific language to write smart contracts in Rust for blockchains built on the Substrate framework. Starting in version 4.0.0 and prior to version 4.2.1, the return value when using delegate call mechanics, either through `CallBuilder::delegate` or `ink_env::invoke_contract_delegate`, is decoded incorrectly. This bug was related to the mechanics around decoding a call's return buffer, which was changed as part of pull request 1450. Since this feature was only released in ink! 4.0.0, no previous versions are affected. Users who have an ink! 4.x series contract should upgrade to 4.2.1 to receive a patch.