Open JOE1994 opened 3 years ago
Heads up: this issue has been included in the RustSec advisory database. It will be surfaced by tools such as cargo-audit or cargo-deny from now on.
Once a fix is released to crates.io, please open a pull request to update the advisory with the patched version, or file an issue on the advisory database repository.
Hello :crab: , we (Rust group @sslab-gatech) found a memory-safety/soundness issue in this crate while scanning Rust code on crates.io for potential vulnerabilities.
Issue Description
common::Slice::<T, H>::new
Drop uninitialized memory upon panic withinT::default()
. https://github.com/ibabushkin/arenavec/blob/f931efb96ffe85a6433eb1861b698ad38515e427/src/common.rs#L73-L89common::SliceVec::<T, H>::resize_with
double free upon panic withinT::drop
in line 438. https://github.com/ibabushkin/arenavec/blob/f931efb96ffe85a6433eb1861b698ad38515e427/src/common.rs#L417-L443common::SliceVec::<T, H>::resize
double free upon panic withinT::drop
in line 466. https://github.com/ibabushkin/arenavec/blob/f931efb96ffe85a6433eb1861b698ad38515e427/src/common.rs#L445-L471Proof of Concept
Example program below exhibits a double drop on the same object.
[derive(Clone)]
struct Foo(usize, Option);
impl Drop for Foo {
fn drop(&mut self) {
println!("Dropping {:?}", self.0);
if self.0 == 1 && ATOMIC_TRUE.compare_and_swap(true, false, SeqCst) {
println!("THIS WILL PANIC {:?}", self.1.as_ref().unwrap());
}
}
}
static ATOMIC_TRUE: AtomicBool = AtomicBool::new(true); const DEFAULT_CAPACITY: usize = 4096 << 8; fn main() { let arena = Arena::init_capacity(ArenaBacking::SystemAllocation, DEFAULT_CAPACITY).unwrap();
}
Dropping 1 thread 'main' panicked at 'called
Option::unwrap()
on aNone
value', examples/arenavec.rs:14:62 note: run withRUST_BACKTRACE=1
environment variable to display a backtrace Dropping 99 Dropping 0 Dropping 1