{"id":"CVE-2024-4435","published":"2024-05-21T09:41:35Z","modified":"2024-08-01T20:40:47Z","title":"BTreeMap memory leak when deallocating nodes with overflows","vendor":"Internet Computer","product":"ic-stable-structures","tier":"tail","description":{"text":"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.\n\nThis 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.\n\nUsers 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.","provenance":"source","from":"CVE.org"},"cvss":{"score":5.9,"severity":"MEDIUM","version":"3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00515,"percentile":0.44798,"provenance":"source"},"cwes":[{"id":"CWE-401","name":"Missing Release of Memory after Effective Lifetime"}],"references":[{"url":"https://github.com/dfinity/stable-structures/pull/212","tags":[]},{"url":"https://docs.rs/ic-stable-structures/0.6.4/ic_stable_structures/","tags":[]},{"url":"https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/storage#stable-memory","tags":[]}],"priority":{"score":13.1,"factors":[{"name":"EPSS percentile","points":8.96},{"name":"CVSS severity","points":4.13}]},"vendorSlug":"internet-computer","affectedVersions":[{"vendor":"Internet Computer","product":"ic-stable-structures","versions":[">= 0.6.0, < 0.6.4"]}],"capec":[{"id":"CAPEC-131","name":"Resource Leak Exposure"}],"ssvc":{"exploitation":"none","automatable":"no","technicalImpact":"partial","timestamp":"2024-05-23T20:17:52.489055Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"crates.io","package":"ic-stable-structures","vulnerableRanges":[">=0.6.0, <0.6.4"],"patched":["0.6.4"],"from":["GHSA-3rcq-39xp-7xjp","RUSTSEC-2024-0406"],"provenance":"source"}],"summary":{"text":"A memory leak in the BTreeMap implementation of the ic-stable-structures library (Internet Computer) occurs when deallocating nodes that store unbounded types: only the first memory chunk of a node is freed, leaving the remaining chunks allocated. An unauthenticated remote attacker who can reach a canister's API may be able to repeatedly trigger map operations that consume memory, potentially exhausting the canister's memory, but only for canisters that use BTreeMap with unbounded types and under certain usage patterns.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T21:46:57Z"},"euvd":{"id":"EUVD-2024-1394","exploited":false,"provenance":"source"}}