Summary
| Target | Microsoft Office (winword.exe) · Windows OLE |
| Affected | Windows 7 / 10 / 11 |
| Type | Double free · use-after-free (CWE-416) |
| Impact | Remote code execution (CVSS 9.8, Critical) |
| Patch | Microsoft security update, January 2025 |
Description
This vulnerability can occur in M365 product lines that support OleObject insertion. It allows the same object to be released twice, potentially invoking a function at an arbitrary address.
Analysis
Below is an excerpt of the code at the time the vulnerability was discovered.
__int64 __fastcall UtOlePresStmToContentsStm(IStorage *pstg, wchar_t *puiStatus, int a3, unsigned int *lpszPresStm)
{
IStorage_vtbl *v5; // rax
int v7; // r14d
int v9; // ebx
HRESULT v10; // eax
IStream *pstmContents; // [rsp+40h] [rbp-19h] BYREF
IStream *pstmOlePres; // [rsp+48h] [rbp-11h] BYREF
tagFORMATETC foretc; // [rsp+50h] [rbp-9h] BYREF
tagHDIBFILEHDR hdfh; // [rsp+70h] [rbp+17h] BYREF
*lpszPresStm = 0;
v5 = pstg->__vftable;
pstmContents = 0i64;
v7 = 1;
if ( v5->CreateStream(pstg, L"CONTENTS", 18u, 0, 0, &pstmContents) )
return 0i64;
pstmContents->Release(pstmContents); // need to initialize pstmContents
pstg->DestroyElement(pstg, L"CONTENTS");
v9 = pstg->OpenStream(pstg, &word_F40E0, 0i64, 16u, 0, &pstmOlePres); // this line make pstmOlePres == pstmContents
if ( !v9 )
{
foretc.ptd = 0i64;
v9 = UtReadOlePresStmHeader(pstmOlePres, &foretc, 0i64, 0i64);
if ( v9 < 0 )
goto $errRtn_199;
v9 = ((__int64 (__fastcall *)(IStream *, tagHDIBFILEHDR *, __int64))pstmOlePres->Read)(pstmOlePres, &hdfh, 16i64);
if ( v9 < 0 )
goto $errRtn_199;
v9 = OpenOrCreateStream(pstg, L"CONTENTS", &pstmContents);
if ( v9 >= 0 )
{
...
}
$errRtn_199:
if ( pstmOlePres )
pstmOlePres->Release(pstmOlePres); // first release
if ( pstmContents )
pstmContents->Release(pstmContents); // second release & crash trigger
if ( foretc.ptd )
...
}
After the CONTENTS stream is released, pstmContents is never cleared, so the following OpenStream call reclaims the slot that was just freed and pstmOlePres ends up pointing at the same object. The error path then releases both pointers in turn, freeing the same object twice.
The patch
It has now been patched by adding some lines:
+ IsEnabled = wil::details::FeatureImpl<__WilFeatureTraits_Feature_3047977275>::__private_IsEnabled(&`wil::Feature<__WilFeatureTraits_Feature_3047977275>::GetImpl'::`2'::impl);
+ v10 = pstmContents;
+ v11 = !IsEnabled;
v12 = pstg->lpVtbl;
+ if ( !v11 )
+ v10 = 0LL;
+ pstmContents = v10;
Clearing the released pointer to NULL stops the second release from happening on the error path.
Result
As a result of this vulnerability, the IP register can be controlled.

Exploitability
I consider that this vulnerability could be utilized as part of an attack scenario. For research purposes, I disabled the DEP protection to demonstrate the feasibility of using an exploit chain gadget and prove its malicious potential. Additionally, an extra scenario is needed for a complete ASLR bypass — in the PoC recording, ASLR mitigation was circumvented probabilistically.
This vulnerability can also occur in the Preview Pane feature supported by M365 products. The PoC below takes that path: selecting the downloaded POC.docx in Explorer is enough for the preview to run the calculator — the document is never opened.
POC.docx and the calculator comes up.