Probable free of uninitialized pointer in ProxyAccessible::RelationByType()
The function RelationByType() in ProxyAccessible.cpp declares a pointer without initialising it, and if the call to get_relationTargetsOfType() fails before allocating memory, the code later attempts to free that uninitialised pointer. This could lead to insecure behaviour, though the reporter has no proof of concept and is unsure how to trigger the function.
Originally disclosed on Mozilla
- Fixed in 10 months
- Paid in 10 months
- Disclosed after 10 months
ProxyAccessible::RelationByType() (accessible\ipc\win\ProxyAccessible.cpp) probably can attempt to free an uninitialized pointer.
The bug is on line 394, which doesn't initialize |targets|. If something inside |acc->get_relationTargetsOfType()| (resolves to isaAccessible::get_relationTargetsOfType()) on line 396 fails before that function allocates memory for |targets| (e.g., the Accessible object becomes defunct), line 407 will attempt to free an uninitialized pointer, probably causing insecure behavior.
I do not currently have a POC (how do you make this function run?)
BTW, it also appears that lines 379, 391, and 398 are meant to read
return nsTArray<ProxyAccessible*>();
instead of
nsTArray<ProxyAccessible*>();
374: nsTArray<ProxyAccessible*> 375: ProxyAccessible::RelationByType(RelationType aType) const 376: { 377: RefPtr<IAccessible2_2> acc = QueryInterface<IAccessible2_2>(this); 378: if (!acc) { 379: nsTArray<ProxyAccessible*>(); 380: } 381: 382: _bstr_t relationType; 383: for (uint32_t idx = 0; idx < ArrayLength(sRelationTypePairs); idx++) { 384: if (aType == sRelationTypePairs[idx].first) { 385: relationType = sRelationTypePairs[idx].second; 386: break; 387: } 388: } 389: 390: if (!relationType) { 391: nsTArray<ProxyAccessible*>(); 392: } 393: 394: IUnknown** targets; 395: long nTargets = 0; 396: HRESULT hr = acc->get_relationTargetsOfType(relationType, 0, &targets, &nTargets); 397: if (FAILED(hr)) { 398: nsTArray<ProxyAccessible*>(); 399: } 400: 401: nsTArray<ProxyAccessible*> proxies; 402: for (long idx = 0; idx < nTargets; idx++) { 403: IUnknown* target = targets[idx]; 404: proxies.AppendElement(GetProxyFor(Document(), target)); 405: target->Release(); 406: } 407: CoTaskMemFree(targets); 408: 409: return Move(proxies); 410: }
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the pointer variable targets is declared without initialisation, and the error-handling paths do not return early, so an uninitialised pointer can reach the free call.
Impact
This could cause insecure behaviour, but the reporter has no proof of concept and does not know how to make the function run.
What the attacker needed
None
The fix
The pointer should be initialised to null and the error paths should return early instead of falling through.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A pointer is a variable that holds a memory address. If you free a pointer that was never given a valid address, the program may crash or behave unpredictably. Here, a pointer is declared but not set before a function call that might fail, and the code then tries to free it anyway.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.