CVE-2021-25900: Buffer overflow in SmallVec::insert_many
9.8
CVSS Score
3.1
Basic Information
CVE ID
GHSA ID
EPSS Score
0.66903%
CWE
Published
5/24/2022
Updated
9/18/2023
KEV Status
No
Technology
Rust
Technical Details
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| smallvec | rust | >= 0.6.3, < 0.6.14 | 0.6.14 |
| smallvec | rust | >= 1.0.0, < 1.6.1 | 1.6.1 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability explicitly occurs in SmallVec::insert_many as described in all sources. The commit diff shows critical changes to this function's memory handling logic - specifically replacing a direct iterator loop with a two-phase approach (handling size_hint lower bound first, then inserting excess elements safely). The original implementation's unsafe pointer arithmetic and conditional reallocation when 'num_added >= lower_size_bound' was insufficient to prevent buffer overflow when the iterator exceeded its hinted size. The added test_insert_many_overflow in the patch directly validates this failure scenario.