{"id":"CVE-2021-45681","aliases":["CVE-2021-45681","GHSA-9rg7-3j4f-cf4x","GHSA-w4cc-pc2h-whcj","RUSTSEC-2021-0083"],"related":[],"kind":"vulnerability","state":"published","title":"QueryInterface should call AddRef before returning pointer","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"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`.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Se ha detectado un problema en la crate derive-com-impl versiones anteriores a 0.1.2 para Rust. Puede producirse una referencia no válida (y corrupción de memoria) porque AddRef podría no ser llamado antes de devolver un puntero","source":"nvd"}],"published":"2021-01-20T12:00:00.000Z","modified":"2026-06-17T04:13:56.253Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub","scheme":"rating","rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:N/A:P","score":5,"rating":"MEDIUM"}],"cwes":["CWE-787"],"affected":[{"ranges":[{"version":"n/a","status":"affected"}],"source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.1.2"}],"ecosystem":"crates.io","package":"derive-com-impl","purl":"pkg:cargo/derive-com-impl","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"crates.io","package":"derive-com-impl","purl":"pkg:cargo/derive-com-impl","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.1.2"}],"ecosystem":"crates.io","package":"derive-com-impl","purl":"pkg:cargo/derive-com-impl","source":"rustsec"},{"ranges":[{"status":"affected","fixed":"0.1.2"}],"vendor":"derive-com-impl_project","product":"derive-com-impl","cpe":"cpe:2.3:a:derive-com-impl_project:derive-com-impl:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0083.html","tags":["advisory","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://raw.githubusercontent.com/rustsec/advisory-db/main/crates/derive-com-impl/RUSTSEC-2021-0083.md","tags":["third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/Connicpu/com-impl/issues/1","tags":["report","web"],"sources":["ghsa","rustsec"]},{"url":"https://github.com/Connicpu/com-impl/commit/9803f31fbd1717d482d848f041044d061fca6da7","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/Connicpu/com-impl","tags":["package"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-45681","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/connicpu/com-impl","tags":["package"],"sources":["ghsa"]},{"url":"https://crates.io/crates/derive-com-impl","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"mitre","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-45681","url":"https://www.cve.org/CVERecord?id=CVE-2021-45681","licence":"CVE Terms of Use","modified":"2024-08-04T04:47:01.983Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9rg7-3j4f-cf4x","url":"https://github.com/advisories/GHSA-9rg7-3j4f-cf4x","licence":"CC-BY-4.0","modified":"2023-11-08T04:07:21.492Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-w4cc-pc2h-whcj","url":"https://github.com/advisories/GHSA-w4cc-pc2h-whcj","licence":"CC-BY-4.0","modified":"2023-11-08T04:07:21.492Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2021-0083","url":"https://rustsec.org/advisories/RUSTSEC-2021-0083.html","licence":"CC0-1.0","modified":"2023-11-08T04:07:21.492Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-45681","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-45681","licence":"Public domain","modified":"2026-06-17T04:13:56.253Z"}],"updatedAt":"2026-11-25T22:58:06.259Z","epss":{"score":0.01088,"percentile":0.66296,"date":"2026-12-01T12:00:22.000Z"}}