# CVE-2024-4435: BTreeMap memory leak when deallocating nodes with overflows

- Severity: Medium 5.9 (CVSS:3.1, scored by Dfinity) `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.52%, higher than 45% of CVEs (2026-12-01)
- Published: 2024-05-17T12:00:00.000Z
- Modified: 2026-06-17T08:01:52.543Z
- Also known as: GHSA-3rcq-39xp-7xjp, RUSTSEC-2024-0406
- Weaknesses: CWE-401
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: Dfinity

## Description

When storing unbounded types in a BTreeMap, a node is represented as a linked list of "memory chunks". It was discovered recently that when we deallocate a node, in some cases only the first memory chunk is deallocated, and the rest of the memory chunks remain (incorrectly) allocated, causing a memory leak. In the worst case, depending on how a canister uses the BTreeMap, an adversary could interact with the canister through its API and trigger interactions with the map that keep consuming memory due to the memory leak. This could potentially lead to using an excessive amount of memory, or even running out of memory.

This issue has been fixed in  #212 https://github.com/dfinity/stable-structures/pull/212  by changing the logic for deallocating nodes to ensure that all of a node's memory chunks are deallocated and users are asked to upgrade to version 0.6.4.. Tests have been added to prevent regressions of this nature moving forward. Note: Users of stable-structure < 0.6.0 are not affected.

Users who are not storing unbounded types in BTreeMap are not affected and do not need to upgrade. Otherwise, an upgrade to version 0.6.4 is necessary.

(As written by CVE List.)

## Affected

- ic-stable-structures: from 0.6.0 before 0.6.4
- ic-stable-structures (crates.io): from 0.6.0 before 0.6.4
- dfinity stable_structures: before 0.6.0

## Every score

- Dfinity: CVSS:3.1 5.9 Medium `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H`
- GitHub: CVSS:3.1 5.9 Medium `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H`
- RustSec Advisory Database: CVSS:3.1 5.9 Medium `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H`
- NVD: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`

## References

- <https://github.com/dfinity/stable-structures/pull/212> (issue-tracking, patch, web)
- <https://docs.rs/ic-stable-structures/0.6.4/ic_stable_structures/> (product)
- <https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/storage#stable-memory> (product, web)
- <https://github.com/dfinity/stable-structures/security/advisories/GHSA-3rcq-39xp-7xjp> (web)
- <https://nvd.nist.gov/vuln/detail/CVE-2024-4435> (advisory)
- <https://github.com/dfinity/stable-structures/commit/4f6b8ae521884833498bae26369c353c10f28ea7> (web)
- <https://docs.rs/ic-stable-structures/0.6.4/ic_stable_structures> (web)
- <https://github.com/dfinity/stable-structures> (package)
- <https://rustsec.org/advisories/RUSTSEC-2024-0406.html> (advisory, web)
- <https://crates.io/crates/ic-stable-structures> (package)

## Sources

- CVE List: [CVE-2024-4435](https://www.cve.org/CVERecord?id=CVE-2024-4435), CVE Terms of Use, modified 2024-08-01
- GitHub Advisory Database: [GHSA-3rcq-39xp-7xjp](https://github.com/advisories/GHSA-3rcq-39xp-7xjp), CC-BY-4.0, modified 2025-12-10
- RustSec Advisory Database: [RUSTSEC-2024-0406](https://rustsec.org/advisories/RUSTSEC-2024-0406.html), CC0-1.0, modified 2024-12-04
- NVD: [CVE-2024-4435](https://nvd.nist.gov/vuln/detail/CVE-2024-4435), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2024-4435 · Whole record: https://cve.day/CVE-2024-4435.json · Rebuilt by cve.day 2026-11-25T22:58:40.684Z
