Every CVE Search/ Get API key

CVE-2021-45681

QueryInterface should call AddRef before returning pointer

7.5 HighFix available

An issue was discovered in the derive-com-impl crate before 0.1.2 for Rust. An invalid reference (and memory corruption) can occur because AddRef might not be called before returning a pointer.

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
Low
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
None
Integrity
None
Availability
High

Exploit likelihood

1.09%Up 0.6 points since Dec 27, 2021
90%50%10%1%

What each source reports

NVD Score used 7.5

An issue was discovered in the derive-com-impl crate before 0.1.2 for Rust. An invalid reference (and memory corruption) can occur because AddRef might not be called before returning a pointer.

Record
CVE-2021-45681
CVSS 3.1
7.5 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
CVSS 2.0
5.0 MediumAV:N/AC:L/Au:N/C:N/I:N/A:P
Weakness
CWE-787
Updated
2026-11-02
CVE List No score

An issue was discovered in the derive-com-impl crate before 0.1.2 for Rust. An invalid reference (and memory corruption) can occur because AddRef might not be called before returning a pointer.

Record
CVE-2021-45681
Updated
2026-11-02
EUVDEUVD-2022-0715 No score

An issue was discovered in the derive-com-impl crate before 0.1.2 for Rust. An invalid reference (and memory corruption) can occur because AddRef might not be called before returning a pointer.

Record
EUVD-2022-0715
Updated
2026-11-03
GitHub AdvisoriesGHSA-w4cc-pc2h-whcj 7.5

Out-of-bounds Write in derive-com-impl

An issue was discovered in the derive-com-impl crate before 0.1.2 for Rust. An invalid reference (and memory corruption) can occur because AddRef might not be called before returning a pointer.

Record
GHSA-w4cc-pc2h-whcj
CVSS 3.1
7.5 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness
CWE-787
Updated
2026-11-02
GitHub AdvisoriesGHSA-9rg7-3j4f-cf4x No score

QueryInterface should call AddRef before returning pointer

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.

Record
GHSA-9rg7-3j4f-cf4x
Updated
2026-11-02
OSVGHSA-w4cc-pc2h-whcj 7.5

Out-of-bounds Write in derive-com-impl

An issue was discovered in the derive-com-impl crate before 0.1.2 for Rust. An invalid reference (and memory corruption) can occur because AddRef might not be called before returning a pointer.

Record
GHSA-w4cc-pc2h-whcj
CVSS 3.1
7.5 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness
CWE-787
Updated
2026-11-02
OSVGHSA-9rg7-3j4f-cf4x No score

QueryInterface should call AddRef before returning pointer

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.

Record
GHSA-9rg7-3j4f-cf4x
Updated
2026-11-02
OSVRUSTSEC-2021-0083 No score

QueryInterface should call AddRef before returning pointer

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.

Record
RUSTSEC-2021-0083
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
derive-com-impl
crates.io
before 0.1.2
0.1.2
derive-com-impl
crates.io
All versions None known
derive-com-impl
crates.io
0.0.0-0 up to 0.1.2
0.1.2

History

History
RecordedChangedSources
aliasesEUVD
first indexedCVE List, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2021-45681 is a high vulnerability (CVSS 7.5) in Derive-com-impl Project Derive-com-impl, published January 20, 2021. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 1.09%, the 65th percentile. Fixed in derive-com-impl 0.1.2.

References

Show 4 moreShow less
MoveEnter Open