GHSA-3qx8-rv27-j6gp: Undefined behaviour in `kvm_ioctls :ioctls::vm::VmFd::create_device` Vulnerability

MODERATE
CWE-843
Published
Advisory Summary

GHSA-3qx8-rv27-j6gp is a MODERATE :ioctls::vm::vmfd::create_device` vulnerability (CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')) affecting Undefined behaviour in `kvm_ioctls libraries in the crates.io ecosystem. The issue involves :ioctls::vm::vmfd::create_device`. Remediation is available by upgrading affected packages to version 0.19.1.

GHSA-3qx8-rv27-j6gp at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-3qx8-rv27-j6gp
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')
Affected Product Undefined behaviour in `kvm_ioctls
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-3qx8-rv27-j6gp

To remediate this vulnerability, upgrade all affected Undefined behaviour in `kvm_ioctls dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

kvm-ioctls fixed: 0.19.1
Upgrade kvm-ioctls to 0.19.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for kvm-ioctls

How to Check if You Are Affected

To determine whether your application is affected by GHSA-3qx8-rv27-j6gp, inspect your project dependencies for Undefined behaviour in `kvm_ioctls:

inspect dependencies for kvm-ioctls

Analyze the terminal output to locate any version of Undefined behaviour in `kvm_ioctls in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.19.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion'), where the product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type. In Undefined behaviour in `kvm_ioctls, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

An issue was identified in the `VmFd::create_device function`, leading to undefined behavior and miscompilations on rustc 1.82.0 and newer due to the function's violation of Rust's pointer safety rules. The function downcasted a mutable reference to its `struct kvm_create_device` argument to an immutable pointer, and then proceeded to pass this pointer to a mutating system call. Rustc 1.82.0 and newer elides subsequent reads of this structure's fields, meaning code will not see the value written by the kernel into the `fd` member. Instead, the code will observe the value that this field was initialized to prior to calling `VmFd::create_device` (usually, 0). The issue started in kvm-ioctls 0.1.0 and was fixed in 0.19.1 by correctly using a mutable pointer.

GHSA-3qx8-rv27-j6gp Affected Undefined behaviour in `kvm_ioctls Versions

1 component(s)
Fixed Versions:
0.19.1
Product / Package Ecosystem Affected Versions Fixed Version
kvm-ioctls
crates.io
< 0.19.1
0.19.1

References

Frequently Asked Questions

What is GHSA-3qx8-rv27-j6gp?
GHSA-3qx8-rv27-j6gp is a security vulnerability in Undefined behaviour in `kvm_ioctls involving :ioctls::vm::VmFd::create_device` under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion').
Which Undefined behaviour in `kvm_ioctls versions are affected?
Affected versions include releases prior to 0.19.1 across affected packages: kvm-ioctls.
What version fixes GHSA-3qx8-rv27-j6gp?
Upgrading to 0.19.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is kvm-ioctls affected?
Yes, kvm-ioctls is affected in releases prior to 0.19.1. Upgrade your dependency to 0.19.1 or later.
What CWE is associated with GHSA-3qx8-rv27-j6gp?
GHSA-3qx8-rv27-j6gp is classified under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') (The product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.).
How can I check crates.io dependencies for GHSA-3qx8-rv27-j6gp?
Run the dependency tree command: 'inspect dependencies for kvm-ioctls'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3qx8-rv27-j6gp",
  "modified" : "2024-12-23T19:26:37Z",
  "published" : "2024-12-23T19:26:37Z",
  "aliases" : [ ],
  "summary" : "Undefined behaviour in `kvm_ioctls::ioctls::vm::VmFd::create_device`",
  "details" : "An issue was identified in the `VmFd::create_device function`, leading to undefined behavior and miscompilations on rustc 1.82.0 and newer due to the function's violation of Rust's pointer safety rules.\n\nThe function downcasted a mutable reference to its `struct kvm_create_device` argument to an immutable pointer, and then proceeded to pass this pointer to a mutating system call. Rustc 1.82.0 and newer elides subsequent reads of this structure's fields, meaning code will not see the value written by the kernel into the `fd` member. Instead, the code will observe the value that this field was initialized to prior to calling `VmFd::create_device` (usually, 0).\n\nThe issue started in kvm-ioctls 0.1.0 and was fixed in 0.19.1 by correctly using\na mutable pointer.\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "kvm-ioctls"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.19.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rust-vmm/kvm/pull/298"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rust-vmm/kvm-ioctls"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2024-0428.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-843" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-23T19:26:37Z",
    "nvd_published_at" : null
  }
}