Email me

Rust advisories / ic-stable-structures

Vulnerability MediumRUSTSEC-2024-0406 · ic-stable-structures

RUSTSEC-2024-0406: BTreeMap memory leak when deallocating nodes with overflows

Short answerA security vulnerability in the ic-stable-structures crate: BTreeMap memory leak when deallocating nodes with overflows. Medium severity (CVSS 5.9). Fixed in 0.6.4: update to a fixed version.

Crateic-stable-structures
TypeVulnerability (denial-of-service)
Affected versionsFrom 0.6.0 before 0.6.4.
Fixed in0.6.4
SeverityMedium, CVSS 5.9
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
Published2024-05-17
Last changed2024-12-04
Also known asCVE-2024-4435, GHSA-3rcq-39xp-7xjp

What to do

  1. See which version you have: cargo tree -i ic-stable-structures (it also shows which of your dependencies pulls it in).
  2. Update within your version requirement: cargo update -p ic-stable-structures. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for example ic-stable-structures = "0.6.4") or update the dependency that pulls it in.
  3. Check again with cargo audit, or paste your Cargo.lock into our Cargo.toml checker.

Details from the advisory

When storing unbounded types in a BTreeMap, a node is represented as a linked list of "memory chunks". In some cases, when we deallocate a node 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 dfinity/stable-structures/pull/212 by changing the logic for deallocating nodes to ensure that all of a node's memory chunks are deallocated. Tests have been added to prevent regressions of this nature moving forward.

**Note:** Users of stable-structure < 0.6.0 are not affected.

Workarounds

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.

References

References

From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.

Up next

Are you affected?Check your whole dependency treePaste Cargo.lock: every advisory, for your exact versions.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ