-
Notifications
You must be signed in to change notification settings - Fork 29
Description
On certain malformed inputs contents of uninitialized memory are written to the decoded audio.
This is a security vulnerability. Examples of similar vulnerabilities in C code and discussion of the potential impact can be found here. I have also discussed a similar bug in Rust png
crate in my Auditing popular crates post.
This issue has been discovered using differential fuzzing with afl-fuzz, similar to the C vulnerabilities linked above. I shall relay further details on the issue to the maintainer privately by email.
The trivial hotfix is replacing the following line
Line 618 in b4a89e4
unsafe { buffer.set_len(new_len); } |
with buffer.resize(new_len, 0);
, but is likely to degrade performance. There are some tricks that can reduce the cost of zeroing the memory, but this approach is bound to be slower than using uninitialized memory.
However, these kinds of issues can be ruled out systemically by passing a reference to the vector to subframe::decode
instead of a slice with uninitialized memory and using something like Write trait or extend_from_slice()
to write to the vector safely without zeroing the memory first.
Once a fix is published, the issue should be added to the Rust security advisory database.