GHSA-9rg7-3j4f-cf4x: Derive com impl QueryInterface Should Call AddRef Before Vulnerability

MODERATE
Published
Advisory Summary

GHSA-9rg7-3j4f-cf4x is a MODERATE queryinterface should call addref before vulnerability (General Security Weakness) affecting Derive com impl libraries in the crates.io ecosystem. The issue involves queryinterface should call addref before returning pointer. Remediation is available by upgrading affected packages to version 0.1.2.

GHSA-9rg7-3j4f-cf4x at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-9rg7-3j4f-cf4x
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Derive com impl
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-9rg7-3j4f-cf4x

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

derive-com-impl fixed: 0.1.2
Upgrade derive-com-impl to 0.1.2
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 derive-com-impl

How to Check if You Are Affected

To determine whether your application is affected by GHSA-9rg7-3j4f-cf4x, inspect your project dependencies for Derive com impl:

inspect dependencies for derive-com-impl

Analyze the terminal output to locate any version of Derive com impl in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.1.2), 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 General Security Weakness. In Derive com impl, 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

Affected version of this crate, which is a required dependency in com-impl, provides a faulty implementation of the `IUnknown::QueryInterface` method. `QueryInterface` implementation must call `IUnknown::AddRef` before returning the pointer, as describe in this documentation: <https://docs.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)> As it is not incrementing the refcount as expected, the following calls to `IUnknown::Release` method will cause WMI to drop reference to the interface, and can lead to invalid reference. This is documented in <https://docs.microsoft.com/en-us/windows/win32/learnwin32/managing-the-lifetime-of-an-object#reference-counting> There is no simple workaround, as you can't know how many time QueryInterface will be called. The only way to quick fix this is to use the macro expanded version of the code and modify the QueryInterface method to add the AddRef call yourself. The issue was corrected in commit `9803f31fbd1717d482d848f041044d061fca6da7`.

GHSA-9rg7-3j4f-cf4x Affected Derive com impl Versions

1 component(s)
Fixed Versions:
0.1.2
Product / Package Ecosystem Affected Versions Fixed Version
derive-com-impl
crates.io
< 0.1.2
0.1.2

References

Frequently Asked Questions

What is GHSA-9rg7-3j4f-cf4x?
GHSA-9rg7-3j4f-cf4x is a security vulnerability in Derive com impl involving QueryInterface should call AddRef before returning pointer under General Security Weakness.
Which Derive com impl versions are affected?
Affected versions include releases prior to 0.1.2 across affected packages: derive-com-impl.
What version fixes GHSA-9rg7-3j4f-cf4x?
Upgrading to 0.1.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is derive-com-impl affected?
Yes, derive-com-impl is affected in releases prior to 0.1.2. Upgrade your dependency to 0.1.2 or later.
What CWE is associated with GHSA-9rg7-3j4f-cf4x?
GHSA-9rg7-3j4f-cf4x is classified under General Security Weakness.
How can I check crates.io dependencies for GHSA-9rg7-3j4f-cf4x?
Run the dependency tree command: 'inspect dependencies for derive-com-impl'. 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-9rg7-3j4f-cf4x",
  "modified" : "2022-06-16T23:52:51Z",
  "published" : "2022-06-16T23:52:51Z",
  "aliases" : [ ],
  "summary" : "QueryInterface should call AddRef before returning pointer",
  "details" : "Affected version of this crate, which is a required dependency in com-impl, \nprovides a faulty implementation of the `IUnknown::QueryInterface` method.\n\n`QueryInterface` implementation must call `IUnknown::AddRef` before returning the pointer,\nas describe in this documentation:\n<https://docs.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)>\n\nAs it is not incrementing the refcount as expected, the following calls to `IUnknown::Release` method \nwill cause WMI to drop reference to the interface, and can lead to invalid reference.\n\nThis is documented in <https://docs.microsoft.com/en-us/windows/win32/learnwin32/managing-the-lifetime-of-an-object#reference-counting>\n\nThere is no simple workaround, as you can't know how many time QueryInterface will be called.\nThe only way to quick fix this is to use the macro expanded version of the code and modify \nthe QueryInterface method to add the AddRef call yourself.\n\nThe issue was corrected in commit `9803f31fbd1717d482d848f041044d061fca6da7`.\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "derive-com-impl"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.1.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Connicpu/com-impl/issues/1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Connicpu/com-impl/commit/9803f31fbd1717d482d848f041044d061fca6da7"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Connicpu/com-impl"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2021-0083.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-16T23:52:51Z",
    "nvd_published_at" : null
  }
}