{"id":"CVE-2021-45681","aliases":["EUVD-2022-0715","GHSA-9rg7-3j4f-cf4x","GHSA-w4cc-pc2h-whcj","RUSTSEC-2021-0083"],"status":"published","title":"QueryInterface should call AddRef before returning pointer","description":"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.","severity":{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","level":"high","assessor":"primary","from":"nvd"},"epss":{"day":"2026-11-10","score":0.01088,"percentile":0.65602,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-787"],"published":"2021-01-20T12:00:00Z","modified":"2026-06-17T04:13:56Z","fixes":[{"ecosystem":"crates.io","package":"derive-com-impl","fixed_in":["0.1.2"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"crates.io","package":"derive-com-impl","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.1.2"}]}]},{"source":"ghsa","ecosystem":"crates.io","package":"derive-com-impl","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.1.2"}]}]},{"source":"osv","ecosystem":"crates.io","package":"derive-com-impl","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.1.2"}]}]},{"source":"osv","ecosystem":"crates.io","package":"derive-com-impl","ranges":[{"type":"SEMVER","events":[{"introduced":"0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"derive-com-impl","ranges":[{"type":"SEMVER","events":[{"introduced":"0.0.0-0"},{"fixed":"0.1.2"}]}]}],"products":[{"vendor":"derive-com-impl_project","product":"derive-com-impl"}],"references":[{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0083.html","tags":["x_refsource_MISC","x_transferred","Third Party Advisory","web","advisory"]},{"url":"https://raw.githubusercontent.com/rustsec/advisory-db/main/crates/derive-com-impl/RUSTSEC-2021-0083.md","tags":["x_refsource_MISC","x_transferred","Third Party Advisory","web"]},{"url":"https://github.com/Connicpu/com-impl/issues/1","tags":["web","report"]},{"url":"https://github.com/Connicpu/com-impl/commit/9803f31fbd1717d482d848f041044d061fca6da7","tags":["web"]},{"url":"https://github.com/advisories/GHSA-9rg7-3j4f-cf4x"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-45681","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-w4cc-pc2h-whcj"},{"url":"https://github.com/Connicpu/com-impl","tags":["package"]},{"url":"https://github.com/connicpu/com-impl","tags":["package"]},{"url":"https://crates.io/crates/derive-com-impl","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2021-45681","description":"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.","status":"published","published":"2021-12-26T21:52:59Z","modified":"2024-08-04T04:47:01.983Z","updated_at":"2026-11-02T14:33:02.580561Z"}],"euvd":[{"id":"EUVD-2022-0715","description":"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.","status":"published","published":"2021-12-26T21:52:59Z","modified":"2024-08-04T04:47:01Z","updated_at":"2026-11-03T03:08:25.77408Z"}],"ghsa":[{"id":"GHSA-w4cc-pc2h-whcj","title":"Out-of-bounds Write in derive-com-impl","description":"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.","status":"published","published":"2022-01-06T22:16:10Z","modified":"2023-06-13T17:21:56Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","level":"high"}],"cwes":["CWE-787"],"updated_at":"2026-11-02T14:36:53.654352Z"},{"id":"GHSA-9rg7-3j4f-cf4x","title":"QueryInterface should call AddRef before returning pointer","description":"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\u003chttps://docs.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)\u003e\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 \u003chttps://docs.microsoft.com/en-us/windows/win32/learnwin32/managing-the-lifetime-of-an-object#reference-counting\u003e\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","status":"published","published":"2022-06-16T23:52:51Z","modified":"2023-06-13T17:29:15Z","updated_at":"2026-11-02T14:36:53.654352Z"}],"nvd":[{"id":"CVE-2021-45681","description":"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.","status":"published","published":"2021-12-27T00:15:08.86Z","modified":"2026-06-17T04:13:56.253Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","level":"high","assessor":"primary"},{"version":"2.0","score":5,"vector":"AV:N/AC:L/Au:N/C:N/I:N/A:P","level":"medium","assessor":"primary"}],"cwes":["CWE-787"],"updated_at":"2026-11-02T14:07:02.977492Z"}],"osv":[{"id":"GHSA-w4cc-pc2h-whcj","title":"Out-of-bounds Write in derive-com-impl","description":"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.","status":"published","published":"2022-01-06T22:16:10Z","modified":"2023-11-08T04:07:21.492435Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","level":"high"}],"cwes":["CWE-787"],"updated_at":"2026-11-02T15:46:58.04805Z"},{"id":"GHSA-9rg7-3j4f-cf4x","title":"QueryInterface should call AddRef before returning pointer","description":"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\u003chttps://docs.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)\u003e\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 \u003chttps://docs.microsoft.com/en-us/windows/win32/learnwin32/managing-the-lifetime-of-an-object#reference-counting\u003e\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","status":"published","published":"2022-06-16T23:52:51Z","modified":"2023-11-08T04:07:21.492435Z","updated_at":"2026-11-02T15:46:44.225359Z"},{"id":"RUSTSEC-2021-0083","title":"QueryInterface should call AddRef before returning pointer","description":"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\u003chttps://docs.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)\u003e\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 \u003chttps://docs.microsoft.com/en-us/windows/win32/learnwin32/managing-the-lifetime-of-an-object#reference-counting\u003e\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`.","status":"published","published":"2021-01-20T12:00:00Z","modified":"2023-11-08T04:07:21.492435Z","updated_at":"2026-11-02T15:53:39.492624Z"}]}}
