XGameRuntime: QueryApiImpl forwarding classes can read past PC vtable and leak COM refs #2399
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#2399
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ahmetbagci8 on GitHub · 2026-11-25 17:48 UTC · original
Summary
In
crates/xcl/src/hle/xgameruntime/api.rs(QueryApiImpl, lines 278-289):layout()merges multiple known IIDs of a class (from different GDK versions with different PC vtable lengths) into a singleObj. Becauseforward_alias_objis only used when!known, querying an older known IID of a forwarding class (such asXGameUi) caches that shorter PC COM object ino.pc. A subsequent query for a newer known IID ino.iface.iidsreusesowith the older PC object, so calling any newer forwarded slot inforward()(*(*(o as *const *const usize)).add(slot)) reads past the end of the PC vtable.o.pc.loadfollowed byo.pc.storeis also a TOCTOU race: concurrentQueryApiImplcalls both callpc_object(&c, &i)and one overwrites and leaks the other's COM reference.Suggested fix
Always route forwarding classes through
forward_alias_obj(o, c, i)regardless ofknown:Not tested
082944135cd2b96288470a595861fa608eee08dcwithout a new runtime test.AI use
api.rsand drafted this report; the author reviewed it before posting.github-bot referenced this issue2026-11-26 05:35:05 +00:00