You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello 🦀 ,
we (Rust group @sslab-gatech) found a memory-safety/soundness issue in this crate while scanning Rust code on crates.io for potential vulnerabilities.
let len:u32 = de::Deserialize::deserialize(&mut*self)?;
letmut buf = Vec::with_capacity(len asusize);
unsafe{ buf.set_len(len asusize)}
self.read_size(u64::from(len))?;
self.reader.read_exact(&mut buf[..])?;
Ok(buf)
}
Deserializer::read_vec method creates an uninitialized buffer and passes it to user-provided Read implementation (self.reader.read_exact). This is unsound, because it allows safe Rust code to exhibit an undefined behavior (read from uninitialized memory).
Suggested Fix
It is safe to zero-initialize the newly allocated part of u8 buffer before read(), in order to prevent user-provided Read from getting access to the old contents from the newly allocated heap memory.
Thank you for checking out this issue 👍
The text was updated successfully, but these errors were encountered:
Hello 🦀 ,
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
cdr-rs/src/de.rs
Lines 70 to 77 in 880a281
Deserializer::read_vec
method creates an uninitialized buffer and passes it to user-provided Read implementation (self.reader.read_exact
). This is unsound, because it allows safe Rust code to exhibit an undefined behavior (read from uninitialized memory).Suggested Fix
It is safe to zero-initialize the newly allocated part of
u8
buffer before read(), in order to prevent user-provided Read from getting access to the old contents from the newly allocated heap memory.Thank you for checking out this issue 👍
The text was updated successfully, but these errors were encountered: