ic-stable-structures vulnerable to BTreeMap memory leak when deallocating nodes with overflowsGHSA-3rcq-39xp-7xjp
MEDIUMFix: dfinity/stable-structures#212GHSA-3rcq-39xp-7xjp is a medium-severity (CVSS 5.9) CWE-401 vulnerability in ic-stable-structures. A fix is available for ic-stable-structures — see the affected versions and patch details below.
Exploitation Status
No confirmed exploitation observed yet
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-3rcq-39xp-7xjp.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
ic-stable-structuresReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects crates.io packages — download data is not available via public APIs for these ecosystems.
Description
Impact
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 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.
Patches
The problem has been fixed in PR #212 and users are asked to upgrade to version 0.6.4.
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🦀crates.io | ic-stable-structures | ≥ 0.6.0&&< 0.6.4 | 0.6.4cargo update -p ic-stable-structures --precise 0.6.4 |
Affected Products
stable structuresdfinityDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for ic-stable-structures, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update ic-stable-structures to 0.6.4 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-3rcq-39xp-7xjp is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Frequently Asked Questions
Is GHSA-3rcq-39xp-7xjp in your dependencies?
Find it across crates.io, including transitive dependencies.