CVE-2018-20991
Description
An issue was discovered in the smallvec crate before 0.6.3 for Rust. The Iterator implementation mishandles destructors, leading to a double free.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
In smallvec crate before 0.6.3, the `SmallVec::insert_many` method mishandles destructors, causing a double free during unwinding.
Vulnerability
Description
The smallvec crate for Rust provides a "small vector" optimization that stores a small number of items on the stack before spilling to the heap. In versions before 0.6.3, the SmallVec::insert_many method contains a flaw in its Iterator implementation that mishandles destructors, leading to a double free [1][2]. The root cause is that the method does not properly update the vector length before iterating over the inserted elements, so if a panic occurs during iteration, the drop implementation may run on already-freed memory [2][4].
Exploitation
Prerequisites
An attacker can exploit this vulnerability without authentication or user interaction, as the CVSS vector (AV:N/AC:L/PR:N/UI:N) indicates network-based exploitation with low complexity [2]. The bug is triggered when insert_many is called with an iterator that panics during insertion, causing Rust's unwinding mechanism to invoke destructors on invalid state. This requires a crafted input that causes the panic, but no special privileges are needed.
Impact
Successful exploitation results in a double free, leading to memory corruption. The CVSS score of 9.8 (Critical) reflects high impacts on confidentiality, integrity, and availability [2]. An attacker could potentially corrupt heap or stack data, leading to arbitrary code execution or denial of service.
Mitigation
Status
The vulnerability is fixed in smallvec versions 0.6.3, 0.3.4, 0.4.5, and 0.5.1 [2]. Users should update to these patched versions immediately. The advisory notes that versions prior to 0.3.2 are unaffected because they do not include the vulnerable insert_many method [2].
AI Insight generated on May 22, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
smallveccrates.io | >= 0.3.2, < 0.6.3 | 0.6.3 |
Affected products
3- Rust/smallvecdescription
- ghsa-coords2 versionspkg:cargo/smallvecpkg:rpm/suse/librsvg&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Package%20Hub%2015%20SP2
>= 0.3.2, < 0.6.3+ 1 more
- (no CPE)range: >= 0.3.2, < 0.6.3
- (no CPE)range: < 2.42.9-3.6.1
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
4- github.com/advisories/GHSA-rxr4-x558-x7hwghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2018-20991ghsaADVISORY
- github.com/servo/rust-smallvec/issues/96ghsaWEB
- rustsec.org/advisories/RUSTSEC-2018-0003.htmlghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.