Memory Corruption Vulnerability in Rutie Package: Unsafe Pointer Handling in parse_arguments
Summary
RUSTSEC-2024-0448: parse_arguments reads a caller-supplied pointer as a slice. Affects rutie across 5 version ranges.
>= 0.0.0-0, < 0.10.3
>= 0.11.0, < 0.11.3
>= 0.12.0, < 0.12.1
>= 0.13.0, < 0.13.1
>= 0.14.0, < 0.14.1
Fixed in 5 releases; the minimum fixed version depends on the release line you run. 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
Rutie is a Rust library that facilitates the integration of Ruby and Rust, allowing developers to write Ruby extensions in Rust. It provides a safe and efficient way to call Rust code from Ruby, leveraging Rust's performance and safety features. However, a recent vulnerability has been identified in the way Rutie handles pointers in its parse_arguments function, which could lead to memory corruption issues.
Vulnerability Detail
The vulnerability arises from the parse_arguments function, which accepts a caller-supplied pointer and an argument count. It uses slice::from_raw_parts to create a slice from these inputs without validating that the pointer is non-null and properly aligned, nor does it ensure that the specified number of elements is initialized. This oversight can lead to undefined behavior, including potential crashes or memory corruption, especially when a null pointer or an invalid length is passed. The maintainer confirmed that this issue can occur when Ruby calls methods with incorrect arguments, leading to unsafe memory access.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
>= 0.0.0-0, < 0.10.30.10.3 -
>= 0.11.0, < 0.11.30.11.3 -
>= 0.12.0, < 0.12.10.12.1 -
>= 0.13.0, < 0.13.10.13.1 -
>= 0.14.0, < 0.14.10.14.1
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a temporary workaround, ensure that any calls to parse_arguments are made with valid, non-null pointers and correct argument counts. Implement checks in your code to validate these inputs before passing them to the function.
Conclusion
The vulnerability in the Rutie package highlights the importance of safe pointer handling in Rust. By updating to a patched version and implementing proper input validation, developers can mitigate the risks associated with this memory corruption issue.
See every vulnerability recorded for rutie →
FAQ
The vulnerability involves unsafe handling of pointers in the parse_arguments function, which can lead to memory corruption.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
The fixed versions are 0.10.3, 0.11.3, 0.12.1, 0.13.1, and 0.14.1.
Implement input validation to ensure that pointers and argument counts passed to parse_arguments are valid.
Detailed information can be found in the RustSec advisory database or the GitHub repository for Rutie.