Undefined Behavior Risk in stainless_ffmpeg: Stream Accessor Vulnerability
Summary
RUSTSEC-2025-0169: FormatContext stream accessors can cause undefined behavior from safe code. Affects stainless_ffmpeg versions >= 0.0.0-0, < 0.6.0. Fixed in 0.6.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The stainless_ffmpeg package is a Rust library that provides bindings to the FFmpeg multimedia framework, enabling developers to work with audio and video streams. It offers various functionalities, including stream management and codec handling. However, certain public methods in the FormatContext class expose a critical vulnerability that can lead to undefined behavior when incorrect stream indices are provided.
Vulnerability Detail
The vulnerability arises from the exposure of several safe public methods in the FormatContext class that accept a stream_index parameter. These methods perform unsafe pointer operations without validating the stream_index, allowing safe Rust code to pass negative or out-of-bounds indices. This can lead to out-of-bounds pointer access, resulting in undefined behavior, crashes, or potential security risks.
How To Fix
Minimum fixed version
0.6.0
This is the first release that contains the fix.
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, ensure that any calls to the affected methods validate the stream_index before passing it. For example:
let valid_index = if stream_index >= 0 && stream_index < total_streams { stream_index } else { return Err("Invalid stream index"); };
let codec_id = format_context.get_codec_id(valid_index);
Conclusion
The stainless_ffmpeg package has a vulnerability related to unsafe stream accessors that can lead to undefined behavior. It is crucial to update to version 0.6.0 or later to mitigate this risk. Additionally, validating input parameters can serve as a temporary workaround until the package is updated.
See every vulnerability recorded for stainless_ffmpeg →
FAQ
The vulnerability allows for unsafe pointer operations due to unvalidated stream indices, leading to potential undefined behavior.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
Failure to address this vulnerability may result in application crashes, undefined behavior, or security risks due to out-of-bounds memory access.
Yes, the issue is fixed in version 0.6.0 of stainless_ffmpeg. It is recommended to update to this version or later.
If an immediate update is not possible, implement input validation for the stream_index parameter in your code to prevent unsafe access.