Skip to content

Fix potential use-after-free in com_apartment_variable - #679

Merged
Duncan Horn (dunhor) merged 4 commits into
masterfrom
dunhor/uaf
Nov 18, 2026
Merged

Duncan Horn (dunhor) merged 4 commits into
masterfrom
dunhor/uaf

Conversation

@dunhor

Copy link
Copy Markdown
Member

Fixes #678

This is your standard case of dropping a lock while holding a resource that can disappear. There's no technical reason why we need to hold the resource - it appears to just be an attempt at an optimization - so the fix is to re-acquire the resource after obtaining the lock again.

The issue mentions reentrancy as a possible repro of the issue, however that's not a very realistic scenario and would break a potentially obvious contract. A much more reasonable repro is another thread in the same apartment racing with the get_or_create call.

@dunhor
Duncan Horn (dunhor) merged commit 7d59c30 into master Nov 18, 2026
18 checks passed
@dunhor
Duncan Horn (dunhor) deleted the dunhor/uaf branch November 18, 2026 18:14
@Ishanoshada

Copy link
Copy Markdown

Hi Duncan Horn (@dunhor) and team,

Thank you for addressing this and getting the fix merged via PR #679!

While MSRC classified and closed this as a non-security reliability issue (which is completely understandable given the trust boundary), I'm glad the core lifetime bug in com_apartment_variable.h has been resolved.

Since I originally reported and diagnosed this issue (Issue #678), would it be possible to kindly include a brief acknowledgment or mention of my contribution in the upcoming release notes or changelog?

Thanks again for maintaining WIL and for the smooth collaboration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

com_apartment_variable.h: use-after-free in apartment_variable_base::get_or_create() when creator() re-enters clear()

3 participants