Use-After-Free and Double Free in IntoIter::drop When Element Drop Panics
A Double Free / Use-After-Free (UAF) vulnerability has been identified in the `IntoIter::drop` and `ThinVec::clear` implementations of the `thin-vec` crate. Both vulnerabilities share the same root cause and can trigger memory corruption using only safe Rust code - no unsafe blocks required. Undefined Behavior has been confirmed via Miri and AddressSanitizer (ASAN). ## Details When a **panic occurs** during sequential element deallocation, the subsequent length cleanup code (`set_len(0)`) is never executed. During stack unwinding, the container is dropped again, causing already-freed memory to be re-freed (Double Free / UAF). ### Vulnerability 1 - `IntoIter::drop` `IntoIter::drop` transfers ownership of the internal buffer via `mem::replace`, then sequentially frees elements via `ptr::drop_in_place`. If a panic occurs during element deallocation, `set_len_non_singleton(0)` is never reached. During unwinding, `vec` is dropped again, re-freeing already-freed elements. The standard library's `std::vec::IntoIter` prevents this with a **DropGuard pattern**, but thin-vec lacks this defense. ### PoC ```rust use thin_vec::ThinVec; struct PanicBomb(String); impl Drop for PanicBomb { fn drop(&mut self) { if self.0 == "panic" { panic!("panic!"); } println!("Dropping: {}", self.0); } } fn main() { let mut v = ThinVec::new(); v.push(PanicBomb(String::from("normal1"))); v.push(PanicBomb(String::from("panic"))); // trigger element v.push(PanicBomb(String::from("normal2"))); let mut iter = v
- Products
- thin-vec
- Affected versions
- Not specified
- Fixed versions
- 0.2.16
- CVEs
- CVE-2026-6654
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 30 Oct 2026, 08:43 UTC · Revision 1
Source evidence
Use-After-Free and Double Free in IntoIter::drop When Element Drop Panics
core-osv · Original sourcePublished 14 Apr 2026, 12:00 UTC
A Double Free / Use-After-Free (UAF) vulnerability has been identified in the `IntoIter::drop` and `ThinVec::clear` implementations of the `thin-vec` crate. Both vulnerabilities share the same root cause and can trigger memory corruption using only safe Rust code - no unsafe blocks required. Undefined Behavior has been confirmed via Miri and AddressSanitizer (ASAN). ## Details When a **panic occurs** during sequential element deallocation, the subsequent length cleanup code (`set_len(0)`) is never executed. During stack unwinding, the container is dropped again, causing already-freed memory to be re-freed (Double Free / UAF). ### Vulnerability 1 - `IntoIter::drop` `IntoIter::drop` transfers ownership of the internal buffer via `mem::replace`, then sequentially frees elements via `ptr::drop_in_place`. If a panic occurs during element deallocation, `set_len_non_singleton(0)` is never reached. During unwinding, `vec` is dropped again, re-freeing already-freed elements. The standard library's `std::vec::IntoIter` prevents this with a **DropGuard pattern**, but thin-vec lacks this defense. ### PoC ```rust use thin_vec::ThinVec; struct PanicBomb(String); impl Drop for PanicBomb { fn drop(&mut self) { if self.0 == "panic" { panic!("panic!"); } println!("Dropping: {}", self.0); } } fn main() { let mut v = ThinVec::new(); v.push(PanicBomb(String::from("normal1"))); v.push(PanicBomb(String::from("panic"))); // trigger element v.push(PanicBomb(String::from("normal2"))); let mut iter = v
osv:RUSTSEC-2026-0103
thin-vec
Fixed versions: 0.2.16
Complete source record
{
"id": "7801f58d2a16fe9ae7f4c5ce254464a93f6c5a0cfd3a12397794628013c8c0a4",
"url": "https://osv.dev/vulnerability/RUSTSEC-2026-0103",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "Use-After-Free and Double Free in IntoIter::drop When Element Drop Panics",
"summary": "A Double Free / Use-After-Free (UAF) vulnerability has been identified in the `IntoIter::drop` and `ThinVec::clear` implementations of the `thin-vec` crate. Both vulnerabilities share the same root cause and can trigger memory corruption using only safe Rust code - no unsafe blocks required. Undefined Behavior has been confirmed via Miri and AddressSanitizer (ASAN). ## Details When a **panic occurs** during sequential element deallocation, the subsequent length cleanup code (`set_len(0)`) is never executed. During stack unwinding, the container is dropped again, causing already-freed memory to be re-freed (Double Free / UAF). ### Vulnerability 1 - `IntoIter::drop` `IntoIter::drop` transfers ownership of the internal buffer via `mem::replace`, then sequentially frees elements via `ptr::drop_in_place`. If a panic occurs during element deallocation, `set_len_non_singleton(0)` is never reached. During unwinding, `vec` is dropped again, re-freeing already-freed elements. The standard library's `std::vec::IntoIter` prevents this with a **DropGuard pattern**, but thin-vec lacks this defense. ### PoC ```rust use thin_vec::ThinVec; struct PanicBomb(String); impl Drop for PanicBomb { fn drop(&mut self) { if self.0 == \"panic\" { panic!(\"panic!\"); } println!(\"Dropping: {}\", self.0); } } fn main() { let mut v = ThinVec::new(); v.push(PanicBomb(String::from(\"normal1\"))); v.push(PanicBomb(String::from(\"panic\"))); // trigger element v.push(PanicBomb(String::from(\"normal2\"))); let mut iter = v",
"evidence": "osv:RUSTSEC-2026-0103",
"products": [
{
"name": {
"value": "thin-vec",
"evidence": "/affected/0/package/name"
},
"prerequisites": [],
"fixed_versions": [
{
"value": "0.2.16",
"evidence": "/affected/0/ranges"
}
],
"affected_versions": []
}
],
"severity": "high",
"structured": {
"id": "RUSTSEC-2026-0103",
"aliases": [
"CVE-2026-6654",
"GHSA-xphw-cqx3-667j",
"RUSTSEC-2026-0103"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H"
}
],
"affected": [
{
"ranges": [
{
"type": "SEMVER",
"events": [
{
"introduced": "0.0.0-0"
},
{
"fixed": "0.2.16"
}
]
}
],
"package": {
"name": "thin-vec",
"purl": "pkg:cargo/thin-vec",
"ecosystem": "crates.io"
},
"database_specific": {
"cvss": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H",
"source": "https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2026-0103.json",
"categories": [
"code-execution",
"memory-corruption",
"memory-exposure"
],
"informational": null
},
"ecosystem_specific": {
"affects": {
"os": [],
"arch": [],
"functions": []
},
"affected_functions": null
}
}
],
"modified": "2026-10-12T18:00:08.228043402Z",
"provider": "osv",
"references": [
"https://crates.io/crates/thin-vec",
"https://rustsec.org/advisories/RUSTSEC-2026-0103.html",
"https://github.com/mozilla/thin-vec/commit/df64748355222525c344ecd9d2c9f59a662e1678"
],
"provider_metadata": {
"license": "CC0-1.0"
}
},
"related_cves": [
{
"value": "CVE-2026-6654",
"evidence": "/aliases"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 306383,
"published_at": "2026-04-14T12:00:00+00:00"
}