Free of static memory in ExecuteServiceCommand()
The code fails to check the return value of UuidToString(), which can fail under out-of-memory conditions. If it fails, the code unconditionally frees a pointer that still points to static memory, causing an invalid free.
Originally disclosed on Mozilla
- Fixed in 5 days
- Paid in 8 days
- Disclosed after 5 days
ExecuteServiceCommand() (toolkit\components\maintenanceservice\workmonitor.cpp) can attempt to free static memory if it experiences an OOM.
The bug is that line 584 doesn't check the status from UuidToString(), which can fail with OOM (see https://msdn.microsoft.com/en-us/library/windows/desktop/aa379352(v=vs.85).aspx ). If that occurs, line 588 unconditionally frees |guidString|, which contains a pointer to static memory:
570: BOOL
571: ExecuteServiceCommand(int argc, LPWSTR *argv)
572: {
573: if (argc < 3) {
574: LOG_WARN(("Not enough command line arguments to execute a service command"));
575: return FALSE;
576: }
577:
578: // The tests work by making sure the log has changed, so we put a
579: // unique ID in the log.
580: RPC_WSTR guidString = RPC_WSTR(L"");
581: GUID guid;
582: HRESULT hr = CoCreateGuid(&guid);
583: if (SUCCEEDED(hr)) {
584: UuidToString(&guid, &guidString);
585: }
586: LOG(("Executing service command %ls, ID: %ls",
587: argv[2], reinterpret_cast<LPCWSTR>(guidString)));
588: RpcStringFree(&guidString);
...
774: }
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 missing check on the return value of UuidToString() leads to freeing a pointer that was not allocated by that function.
Impact
If the system is out of memory, the program may crash or behave unpredictably due to the invalid free.
What the attacker needed
Out-of-memory condition
The fix
The code should check the return value of UuidToString() and only free the string if the call succeeded.
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.
This is a bug in a Windows program. When the program runs out of memory, a function that creates a unique ID fails, but the code ignores that failure and later tries to free memory that was never allocated. That can crash the program or cause unpredictable behaviour.
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.