Email me

Rust advisories / derive-com-impl

Vulnerability MediumRUSTSEC-2021-0083 · derive-com-impl

RUSTSEC-2021-0083: QueryInterface should call AddRef before returning pointer

Short answerA security vulnerability in the derive-com-impl crate: QueryInterface should call AddRef before returning pointer. GitHub rates it Medium. Fixed in 0.1.2: update to a fixed version.

Cratederive-com-impl
TypeVulnerability (memory-corruption)
Affected versionsBefore 0.1.2.
Fixed in0.1.2
SeverityMedium (GitHub rating)
Published2021-01-20
Last changed2023-11-08
Also known asCVE-2021-45681, GHSA-9rg7-3j4f-cf4x, GHSA-w4cc-pc2h-whcj
Affected functionsderive_com_impl::derive_com_impl

What to do

  1. See which version you have: cargo tree -i derive-com-impl (it also shows which of your dependencies pulls it in).
  2. Update within your version requirement: cargo update -p derive-com-impl. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for example derive-com-impl = "0.1.2") or update the dependency that pulls it in.
  3. Check again with cargo audit, or paste your Cargo.lock into our Cargo.toml checker.

Details from the advisory

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.

References

From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.

Up next

Are you affected?Check your whole dependency treePaste Cargo.lock: every advisory, for your exact versions.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ