Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS0zcmNxLTM5eHAtN3hqcM4AA8W3

ic-stable-structures vulnerable to BTreeMap memory leak when deallocating nodes with overflows

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.

Permalink: https://github.com/advisories/GHSA-3rcq-39xp-7xjp
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS0zcmNxLTM5eHAtN3hqcM4AA8W3
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: 5 months ago
Updated: 5 months ago


CVSS Score: 5.9
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H

Identifiers: GHSA-3rcq-39xp-7xjp, CVE-2024-4435
References: Repository: https://github.com/dfinity/stable-structures
Blast Radius: 5.9

Affected Packages

cargo:ic-stable-structures
Dependent packages: 24
Dependent repositories: 10
Downloads: 954,441 total
Affected Version Ranges: >= 0.6.0, < 0.6.4
Fixed in: 0.6.4
All affected versions: 0.6.0, 0.6.1, 0.6.2, 0.6.3
All unaffected versions: 0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.3.0, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.6.4, 0.6.5