Update Rust crate thin-vec to v0.2.16 [SECURITY]#1095
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.2.14→0.2.16GitHub Vulnerability Alerts
GHSA-xphw-cqx3-667j
Summary
A Double Free / Use-After-Free (UAF) vulnerability has been identified in the
IntoIter::dropandThinVec::clearimplementations of thethin_veccrate.Both vulnerabilities share the same root cause and can trigger memory corruption using only safe Rust code — no
unsafeblocks required.Undefined Behavior has been confirmed via Miri and AddressSanitizer (ASAN).
Details
Both vulnerabilities share the same root cause. 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::dropLocation:
thin-vec/src/lib.rsL.2308~2314IntoIter::droptransfers ownership of the internal buffer viamem::replace, then sequentially frees elements viaptr::drop_in_place.If a panic occurs during element deallocation,
set_len_non_singleton(0)is never reached. During unwinding,vecis dropped again, re-freeing already-freed elements.The standard library's
std::vec::IntoIterprevents this with a DropGuard pattern, but thin-vec lacks this defense.Vulnerability 2 —
ThinVec::clearclear()callsptr::drop_in_place(&mut self[..])followed byself.set_len(0)to reset the length.If a panic occurs during element deallocation,
set_len(0)is never executed. When theThinVecitself is subsequently dropped, already-freed elements are freed again.Recommended Fix
Both vulnerabilities can be resolved with the same pattern:
drop_in_placeto guaranteeset_len(0)is called regardless of panicdrop_in_placePoC
Requirements: Rust nightly toolchain,
thin-vec = "0.2.14"PoC-1:
IntoIter::dropMiri output:
ASAN output:
PoC-2:
ThinVec::clearImpact
Affected code: All code satisfying the following conditions simultaneously:
ThinVecstores heap-owning types (String,Vec,Box, etc.)into_iter()and dropped before being fully consumed, or(Vulnerability 2)
clear()is called while a remaining element'sDropimplementation can panicDropimplementation of a remaining element triggers a panicAdditionally, when combined with
Box<dyn Trait>types, an exploit primitive enabling Arbitrary Code Execution (ACE) via heap spray and vtable hijacking has been confirmed. If the freed fat pointer slot (16 bytes) at the point of Double Drop is reclaimed by an attacker-controlled fake vtable, subsequent Drop calls can be redirected to attacker-controlled code.Severity
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:HRelease Notes
mozilla/thin-vec (thin-vec)
v0.2.16Compare Source
when the Drop implementation of the item panics.
v0.2.15Compare Source
thin_vecmacro not being hygienic when recursingConfiguration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.