# CVE-2023-34449: ink! vulnerable to incorrect decoding of storage value when using `DelegateCall`

> Incorrect decoding of storage values during delegate calls in ink! smart contracts can lead to data integrity issues or unexpected behavior.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 14 Jun 2023
- **Updated:** 30 Dec 2024
- **Also known as:** GHSA-853p-5678-hv8f

## What is CVE-2023-34449?

CVE-2023-34449 is a medium-severity vulnerability in paritytech ink, published on 14 Jun 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

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.

Weakness: CWE-754 (Improper Check for Unusual or Exceptional Conditions), CWE-253 (Incorrect Check of Function Return Value)

## Which versions are affected by CVE-2023-34449?

4 open source packages ship an affected version, including ink and ink_env. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `ink` | crates.io | From 4.0.0 | 4.2.1 |
| `ink` | crates.io | From 4.0.0 | 4.2.1 |
| `ink_env` | crates.io | From 4.0.0 | 4.2.1 |
| `ink_env` | crates.io | From 4.0.0 | 4.2.1 |

Products: Parity Ink\!.

## How do I fix CVE-2023-34449?

Upgrade ink to 4.2.1 or later.

## Is CVE-2023-34449 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-34449 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-34449 and fix it if it is affected.

What it is: CVE-2023-34449 is a medium-severity vulnerability in paritytech ink, published on 14 Jun 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-34449 exists.

Affected packages and fixed versions:
- ink (crates.io): affected from 4.0.0; fixed in 4.2.1
- ink (crates.io): affected from 4.0.0; fixed in 4.2.1
- ink_env (crates.io): affected from 4.0.0; fixed in 4.2.1
- ink_env (crates.io): affected from 4.0.0; fixed in 4.2.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-34449/ (Markdown: https://insights.sbomify.com/CVE-2023-34449/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-34449
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-34449
- OSV: https://osv.dev/vulnerability/CVE-2023-34449

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-34449/
Summaries are generated and may contain mistakes; the official description above is the record.
