Skip to content
Memory corruption Write-up Advanced

Guest Blog Post - Memory corruption vulnerabilities in Edge

The blog post describes several memory corruption vulnerabilities in Microsoft Edge, including use-after-free and out-of-bounds read issues, found in Edge-specific features. An attacker could potentially exploit these to cause browser crashes or achieve code execution, though the post mainly focuses on crash reproduction and root cause analysis.

David Erceg Follow

Published on microsoftedge.github.io

Bounty$215,000total stated by author View original

Memory corruption issues in the browser process are typically some of the most severe issues in Chromium and browsers that are based off it. Such issues can include use-after-free (UAF) problems, as well as out-of-bounds (OOB) reads and out-of-bounds writes.

David Erceg, on microsoftedge.github.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 24 min read.

Context

This is a guest blog post published on the Microsoft Edge Vulnerability Research (EdgeVR) site, written by David Erceg (@david_erceg). It describes a set of memory corruption vulnerabilities that he found in Microsoft Edge, the Chromium-based browser, and it was disclosed on 2022-10-17. The issues are all in the browser process, which is the privileged process that hosts the browser UI, as opposed to renderer processes that host page content. The classes of bug covered are use-after-free (UAF) and out-of-bounds (OOB) read.

The post assumes the reader knows what the browser process is, how it differs from renderer processes, and what a unique_ptr is in C++. It is not a single vulnerability report but a collection of issues, each with its own short narrative, plus a worked example of how to investigate a UAF in Edge when no source code is available. The Edge Vulnerability Research Team adds response blurbs throughout, explaining how it handled the reports, how it searched for variants, and its general thoughts.

The features involved include the web app install dialog and its custom icon picker, web capture (including capture of read: pages), the guided switch dialog, the text selection mini menu, the vertical tabs group editor bubble, the tab strip drag-and-drop code, and JavaScript dialog focus handling.

Setup

The post does not describe any accounts, roles or special configuration for finding the bugs. The researcher interacted with the browser through its normal UI: the app menu, the install dialog, the reader mode, DevTools, the tab strip, vertical tabs, and so on. Some scenarios involve a second profile (the guided switch dialog) and some involve an extension (deleting a tab group, or navigating or closing a tab).

For the investigation and root cause work, the researcher used two tools plus Microsoft-provided debugging symbols:

  1. Ghidra, to decompile the binary back into an approximate version of the original code.
  2. WinDbg, to debug the running browser.

There are no AddressSanitizer (ASan) builds available for Edge, unlike Chromium, where pre-built ASan binaries are available. That absence is the reason the researcher relies on Ghidra and WinDbg to confirm that a crash is a genuine memory corruption issue rather than a harmless NULL pointer dereference.

Ghidra setup, as given in the post:

  1. Download Ghidra.
  2. In Ghidra, create a new project and import msedge.dll (found in C:\Program Files (x86)\Microsoft\Edge\Application\{version}).
  3. Open msedge.dll in the CodeBrowser tool. When asked if you would like to analyse msedge.dll, select "No".
  4. Load the PDB for msedge.dll, by selecting File > Load PDB File… Ensure that you have a local symbol storage path configured and that you've added the Microsoft symbol server (https://msdl.microsoft.com/download/symbols) as a search path.
  5. Once you've loaded the PDB file, Ghidra will process it, before performing an auto analysis of msedge.dll. Expect this process to take a while, at least several hours. Once the auto analysis has finished, you can then browse through the decompiled code generated from msedge.dll.

WinDbg setup is minimal: ensure the Microsoft symbol server is included in the symbol server settings, then attach WinDbg to the Edge browser process.

One important limit: Microsoft only provides symbols for the current version of msedge.dll, so the exact demonstration in the post cannot be reproduced against the older build it was based on. The process, not the exact addresses, is what matters.

Finding it

The researcher's approach is pattern-based. Several of the issues come from the same underlying idea: any asynchronous process, or any UI element whose lifetime is independent of the objects it references, is a candidate for a lifetime bug. The concrete patterns he describes are:

  • A dialog or menu that refers to a WebContents (a tab) can outlive that tab.
  • A tab modal dialog that refers to a Browser instance, or anything associated with it such as the BrowserView, can survive the tab and dialog being moved to another window and the original window being closed.
  • A dialog that refers to data an extension or web page can modify or delete is problematic, because that data can change while the dialog is shown.
  • Functionality added specifically to a Chromium fork is a good place to look, because it is hard to know what a fork changed without source access, whereas new features are easier to reason about.
  • Issues fixed in Chromium may still reproduce in Edge if Edge overrides or re-implements the affected code.

He also notes that BrowserList::AddObserver should always be matched with BrowserList::RemoveObserver. An unmatched pair is likely problematic, though not certainly: an object that lives for the whole browser lifetime may add an observer and never remove it, which is fine because it is never destroyed until the browser closes.

Exploitation

The post presents each issue as a scenario with steps. The following subsections follow the original order.

Step 1: UAF when selecting a custom icon for a web app

In Edge you can select a custom icon when installing a web app. Open the app menu, select Apps > Install this site as an app, and the dialog shown allows you to select a custom icon. Clicking the "Edit" link in the install dialog opens a file selection dialog from which you choose a custom icon.

In a previous version of Edge, a UAF occurred if the web app install dialog was closed after the file selection dialog was opened but before a file was selected. The code that ran when a file was selected implicitly assumed the install dialog still existed. If the tab was navigated elsewhere the dialog was closed; if the tab was closed the dialog was also closed. Either could happen while the file selection dialog was shown.

The researcher calls this a classic lifetime bug. The file selection dialog is shown asynchronously, off the browser's main UI thread, so the browser remains interactive while it is shown, which is what allows the install dialog to be closed underneath it. This issue was rewarded $30,000 USD.

Step 2: OOB read when capturing a read: page

When looking for vulnerabilities in Chromium forks, the researcher suggests looking at fork-specific functionality. The web capture feature in Edge is such a feature.

Edge uses the read: scheme for reader mode. Load a page for which reader mode is available, for example https://techcommunity.microsoft.com/t5/discussions/dev-channel-update-to-95-0-997-1-is-live/m-p/2704057, and switch to it with F9; the read: scheme is then used. Opening DevTools on a reader mode page shows that the actual page content is inside an iframe.

When a web capture is performed, the capture code has a special case for read: pages: it captures the contents of the iframe by iterating through the frames on the page. In a previous version of Edge there was no check that the end of the frames vector had been reached. So if a read: page had only a single frame, an OOB read occurred when attempting to capture it.

Examples of a read: page with a single frame are an invalid read: page such as read://_/?url=, which is really just an error page, and a view-source:read:… page. The researcher found this by experimenting with web capture on different types of pages. This issue was rewarded $30,000 USD.

Step 3: UAF after showing the guided switch dialog

This is another new Edge feature. The guided switch dialog is shown when a different profile can be used to log in to the target site. For example, if you are logged into the browser in one profile but not in a second profile, the dialog is shown when loading https://login.live.com/ in the second profile.

The dialog called BrowserList::AddObserver on creation. If the tab hosting the dialog was moved to another window and the original window was closed, the dialog did not call BrowserList::RemoveObserver on destruction. Then, if a BrowserList event was dispatched, for example because a browser window was created or closed, a UAF occurred. This issue was rewarded $30,000 USD.

Step 4: UAF with the text selection mini menu

The mini menu shown when selecting some text is another Edge-specific feature. The researcher's reasoning: for any browser UI element there are potential lifetime issues. A dialog might refer to the WebContents it was opened on, and the key question is whether the dialog can outlive the tab. If it can, that may lead to a UAF. The same applies to menus and bubble views, which are dialog-like elements shown in the browser.

A tab-specific menu that is not closed when the tab is closed is immediately suspect. Finding the issue was a matter of checking whether the menu was closed when the tab was closed. In a previous version of Edge it was not, which led to a UAF if one of the menu items was then selected. This issue was rewarded $5,000 USD.

Step 5: OOB read in the group editor bubble

Vertical tabs are another Edge-specific feature. Turn on vertical tabs in a window, group a tab, and a three dot button appears in the tab strip. Clicking it shows the group editor bubble.

Following on from the previous issue, the question is what happens if the group is deleted by an extension while the bubble is shown. In a previous version of Edge the bubble continued to be shown, leading to an OOB read when one of the menu items in the bubble was selected. The researcher notes this is very similar to issue 1228557 in the Chromium project. This issue was rewarded $30,000 USD.

The Edge Vulnerability Research Team's response quotes the original report's remediation suggestion:

Aside from ensuring that the bubble is destroyed when the group is destroyed, future issues in this area could also be prevented by changing the DHCECK in TabGroupModel::GetTabGroup to a CHECK:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/tabs/tab_group_model.cc;l=42;drc=[redacted]

The team says this was not the direction the development team took, mainly to avoid unnecessarily forking upstream code, but it prompted the VR team to look for other issues involving dereferencing an out-of-bounds iterator. One method was the tool weggli, a fast semantic search tool built on the AST parsing library tree-sitter. The team gives this example query:

Text
weggli -X -R find=find -R end=end '{ $x = std::$find(_); NOT: _($x == $end()); NOT: _($x != $end()); _(*$x); }'

The query looks for code that dereferences the result of a function named std::*find* without first comparing it to the result of any method containing the string "end". The team notes this is not the only query they explored, since many other functions return iterators, and as David's comment indicates there could be a comparison for end() enclosed in a DCHECK. While writing the post the team ran the query again and found a fixed upstream issue in Edge that had failed to merge into their forked code. They stress that weggli, like CodeQL, is not a silver bullet that only identifies vulnerabilities; it finds starting points for research and verification.

Step 6: OOB read when dragging a link over the tab strip

This issue is essentially the same as issue 1209616 in the Chromium project. When a window is closed there is a brief period where the window still exists but contains no tabs. In a previous version of Edge an OOB read could occur if a link was being dragged over the tab strip at that time.

The Chromium issue was fixed by updating TabStrip::GetDropBounds to check whether the tab strip is empty. In Edge, the EdgeTabStrip class inherits from TabStrip and EdgeTabStrip::GetDropBounds overrides TabStrip::GetDropBounds. So although the issue was fixed in Chromium, it remained present in Edge. This illustrates that it is worthwhile to check whether issues fixed in Chromium still reproduce in Edge, and that changing core Chromium code, directly or indirectly, in a fork can mean security fixes do not have the intended effect in the fork. This issue was rewarded $30,000 USD.

Step 7: UAF when closing the web app install dialog

As in the first issue, the web app install dialog allows a custom icon to be chosen. The researcher noticed a delay between selecting a custom icon file and the preview being shown in the dialog. The natural question: what happens if the dialog is closed before the icon preview is updated, that is, immediately after a file is selected?

In a previous version of Edge a UAF occurred, because the object processing the image on a background thread was destroyed in the middle of the processing operation when the dialog was closed. Again, an asynchronous process led to a lifetime issue. This issue was rewarded $30,000 USD.

The Edge Vulnerability Research Team's response says this is a very common bug pattern they have spent effort on through education and tooling. Internally, UAFs stemming from a mismatch of object lifetimes and threads using those objects account for a large number of the security team's findings. The team gives example code that looks very similar to the code that caused the issue:

In this code a task executing MyClass::Method is scheduled on a background thread. When it completes, MyClass::Callback is scheduled to execute on the sequence that originally called PostTaskAndReply. The this value for MyClass is bound as a parameter so that MyClass::Method uses the instance of MyClass. base::Unretained indicates this will be a raw pointer and will not be reference counted. Unlike the call to MyClass::Method, the first parameter of MyClass::Callback is a weak pointer, which causes Edge to check whether the instance of MyClass is still alive before attempting to execute Callback. If MyClass is destroyed on the same sequence that MyClass::Callback is scheduled, then when MyClass::Callback begins executing the object is still alive and remains alive for the entire time it runs.

In this case the bug was exactly as David described: the instance of MyClass could be destroyed while running in the background thread.

The team lists ways to audit these issues, from least to most complex:

  1. Grep. A dashboard of all newly added PostTask calls is a viable technique on commit. The cognitive load is high but verifying whether a PostTask call could lead to a problem usually takes a couple of seconds. It only helps audit new code, not code already in the code base, and is fragile if someone changes the parameters of an existing PostTask call.
  2. Clang AST matchers. Despite the heading of the chromium documentation for writing clang plugins being "Don't write a clang plugin", they can be useful. The core issue is passing a reference to this for use on another thread. Identifying the PostTask call itself can be tricky, but identifying these unsafe binds is trivial with a matcher plugin. This accurately identifies base::BindOnce and base::BindRepeating calls that store pointers or even weak pointers to these unsafe types, and can be run quickly on only recently changed files.
  3. CodeQL. Target the base::Bind* calls with CodeQL, and unlike a matcher you can find sinks where the closure created by the bind is used. GitHub has a pack of CodeQL scripts usable out of the box or as a starting point.
  4. Instrumentation. Potentially more complex, applied at build time or runtime. The idea is to pin memory access for certain object types to specific threads. For example, it is nearly ALWAYS a UAF if a pointer to a WebContents object, and many other object types, is dereferenced from any thread but the UI thread. Clang or runtime hooking can instrument memory accesses to these classes and alert on potential issues.

Step 8: UAF when closing a JavaScript dialog

In a previous version of Edge, F6 cycled focus not just between core UI elements in the browser window, such as the tab strip and address bar, but also any JavaScript dialog. F6 could shift focus to the dialog itself.

Internally, to support this, the dialog called BrowserView::SetFocusDialog on creation and BrowserView::RemoveFocusDialog on destruction. If the dialog was moved to another browser window, the original window closed, and the dialog then closed, the call to BrowserView::RemoveFocusDialog triggered a UAF, because it attempted to make a call on the original BrowserView.

The researcher uses this to explain that dialogs are a good place to look. There are essentially two types:

  • Browser modal dialogs, tied to a browser window.
  • Tab modal dialogs, tied to a tab.

This creates several places for potential issues:

  • A browser modal dialog that refers to a particular WebContents is likely wrong, since the tab can be closed without closing the dialog.
  • A tab modal dialog that refers to a particular Browser instance, or anything associated with that Browser such as the BrowserView, is likely wrong, since the tab and dialog can be moved to another browser window and the original window closed.
  • Any dialog that refers to data an extension or web page can modify or delete is problematic, precisely because the extension or page can modify data while the dialog is shown. An example is issue 1161144 in the Chromium project.

This issue was rewarded $30,000 USD.

Step 9: Verifying a memory corruption issue in Edge

For each issue the researcher typically observed a browser crash after a series of steps. The question is whether the crash is due to memory corruption. A crash referring to a valid-looking memory address is a dead giveaway, but that is not always what happens: many UAFs crash the browser with a reference to a near-NULL address, so there is a need to distinguish memory corruption from a harmless NULL pointer dereference.

In Chromium this is often trivial, because ASan builds are available: download one, reproduce the issue, and check the output. Edge has no ASan builds, so the researcher uses Ghidra and WinDbg with Microsoft's debugging symbols.

The worked example is the first UAF, the custom icon issue. After observing a crash when selecting a custom icon file, the first step is to examine the crash dump. It gives this stack trace (only the last few relevant entries are shown):

The crash occurred within EdgeWebAppCustomIcon::OnEditIconButtonPressed, which gives a starting point. The next step is to look at the EdgeWebAppCustomIcon class in Ghidra. The post refers to screenshots here but the text describes what they show: EdgeWebAppCustomIcon holds an instance of WebAppCustomIconFile in a member variable, likely as a unique_ptr. The value is initialized to NULL in the constructor, the instance member is set in EdgeWebAppCustomIcon::OnEditIconButtonPressed with any previous instance destroyed, and the instance is also destroyed when appropriate in the destructor. So EdgeWebAppCustomIcon appears to own the WebAppCustomIconFile instance and manage its lifetime. If the WebAppCustomIconFile instance being destroyed is not valid, the EdgeWebAppCustomIcon instance likely is not either.

The next step is to check how the EdgeWebAppCustomIcon instance is created and destroyed. Ghidra can do this by searching for references to EdgeWebAppCustomIcon::EdgeWebAppCustomIcon and EdgeWebAppCustomIcon::~EdgeWebAppCustomIcon, but WinDbg tends to be better because there can be multiple callers, or the caller may not be shown by Ghidra depending on how the call is made.

With WinDbg attached to the browser, set a breakpoint on the constructor:

Text
bu msedge!EdgeWebAppCustomIcon::EdgeWebAppCustomIcon

And a breakpoint on the destructor:

Text
bu msedge!EdgeWebAppCustomIcon::~EdgeWebAppCustomIcon

Running the browser with these breakpoints shows the instance being created in this way:

And destroyed in this way:

Looking at WebAppConfirmationView in Ghidra shows the EdgeWebAppCustomIcon instance stored in a member variable, again likely as a unique_ptr. To summarise:

  • WebAppConfirmationView is the view associated with the web app install dialog.
  • It holds an instance of EdgeWebAppCustomIcon in a member variable. When WebAppConfirmationView is destroyed, EdgeWebAppCustomIcon is destroyed as well.
  • WebAppConfirmationView is destroyed when the web app install dialog is closed, which can happen when the tab is navigated elsewhere or closed.

So the original scenario plays out as follows:

  1. The user opens the web app install dialog on a tab. An instance of WebAppConfirmationView is created, which creates an instance of EdgeWebAppCustomIcon and stores it in a member variable.
  2. The user clicks the "Edit" link in the install dialog, which results in a file selection dialog being shown.
  3. The tab is navigated to a different location or closed, by the page itself or by an extension. This closes the dialog and destroys both the WebAppConfirmationView and EdgeWebAppCustomIcon instances.
  4. The user chooses a file from the file selection dialog, which causes EdgeWebAppCustomIcon::OnEditIconButtonPressed to access members of the class. The EdgeWebAppCustomIcon instance has already been destroyed, so this is a UAF.

As a side note, when verifying a UAF it can be useful to see that the memory being accessed was the memory that was freed. WinDbg allows data breakpoints for that purpose. For example, you might observe the creation of the EdgeWebAppCustomIcon instance and place a data breakpoint on its address (the command assumes the address is 4fe400c5bf00):

Text
ba w8 4fe400c5bf00

The breakpoint should be hit when the instance is freed, and you can then verify that EdgeWebAppCustomIcon::OnEditIconButtonPressed is trying to access memory within that block.

Another useful feature in WinDbg preview is time travel debugging. A crash dump only gives information about where the crash occurred, which is not necessarily helpful for finding the cause. If an object is used from many places and can be allocated in various ways, a UAF involving it might crash in a variety of locations depending on what tries to access it first, and a crash dump will probably show the object involved but not where it was allocated. Time travel debugging coupled with data breakpoints is powerful for those crashes. The researcher did not need it for any of the issues listed here, but used it for more recent issues where it was essential.

Root cause

The issues share a small number of root causes:

  • Lifetime mismatch between an asynchronous operation and the UI object that started it. The file selection dialog and the background image processing both run asynchronously, so the install dialog can be destroyed while the operation is still pending, and the callback then touches freed memory.
  • Unmatched observer registration. The guided switch dialog calls BrowserList::AddObserver on creation but does not call BrowserList::RemoveObserver when it is destroyed after its tab is moved to another window and the original window is closed, so a later BrowserList event dispatches to a freed object.
  • UI elements that outlive the tab or window they refer to. The mini menu is not closed when its tab closes; the group editor bubble stays shown after the group is deleted; the JavaScript dialog calls BrowserView::RemoveFocusDialog on a BrowserView that belonged to a window that has since been closed.
  • Missing bounds checks. The web capture code iterates the frames vector for read: pages without checking for the end of the vector, so a single-frame read: page causes an OOB read. The tab strip code reads the tab strip while it is empty during window close, because the Chromium fix in TabStrip::GetDropBounds was overridden by EdgeTabStrip::GetDropBounds.

Why existing defences did not stop them: the post does not describe any specific defence that failed, but it does show two structural reasons. First, Edge has no ASan builds, so confirming a crash is memory corruption takes manual work with Ghidra and WinDbg. Second, fixes made upstream in Chromium do not automatically protect Edge when Edge overrides the affected method or re-implements the feature, as with EdgeTabStrip::GetDropBounds. The team also notes that a DCHECK comparison against end() can be compiled out, which is why the weggli query looks for dereferences without a comparison and why the team suggested a CHECK in TabGroupModel::GetTabGroup.

Impact

All of the issues are in the browser process, which the post describes as typically hosting some of the most severe issues in Chromium and Chromium-based browsers. The researcher observed browser crashes in each case. The post does not describe remote code execution, sandbox escape, or any specific attacker capability beyond the crash and the memory corruption class (UAF, OOB read). Several scenarios require the user to perform UI actions, such as opening the install dialog and choosing a file, dragging a link over the tab strip during window close, or selecting a menu item after the tab or group has gone. Some scenarios can be triggered by a page or an extension: the tab can be navigated or closed by the page itself or by an extension, and the tab group can be deleted by an extension.

The total reward for the issues described is $215,000 USD. The individual rewards stated in the post are $30,000 for the custom icon UAF, $30,000 for the read: capture OOB read, $30,000 for the guided switch dialog UAF, $5,000 for the mini menu UAF, $30,000 for the group editor bubble OOB read, $30,000 for the tab strip drag OOB read, $30,000 for the install dialog close UAF, and $30,000 for the JavaScript dialog UAF. The Edge Vulnerability Research Team notes that it aligns closely with Chromium's severity guidelines and that, due to recent changes in the upstream policy regarding user interaction, some of these issues if reported today may not be paid out at the same amount.

Fix

The post does not give the exact patch for each issue. It does say what the correct behaviour should be and, in one case, what was suggested versus what was done:

  • For the group editor bubble, the researcher suggested ensuring the bubble is destroyed when the group is destroyed, and changing the DCHECK in TabGroupModel::GetTabGroup to a CHECK. The team says this was not the direction the development team took, mainly to avoid unnecessarily forking upstream code.
  • For the tab strip drag issue, Chromium fixed it by updating TabStrip::GetDropBounds to check whether the tab strip is empty. Edge needed the equivalent check in its override.
  • For the observer issue, BrowserList::AddObserver should be matched with BrowserList::RemoveObserver.
  • For the dialogs, the guidance is structural: a browser modal dialog should not refer to a particular WebContents, a tab modal dialog should not refer to a particular Browser or BrowserView, and no dialog should refer to data an extension or page can modify or delete while it is shown.

Variants to test

  1. Async file pickers and background processing in other install or settings dialogs. Open the dialog, start the async operation, then navigate or close the tab before completing it. A positive result is a crash whose stack shows a destructor of the dialog's view followed by a callback into the destroyed object.
  2. Other read: and view-source: combinations in web capture. Try invalid read: pages such as read://_/?url= and view-source:read:… pages, and pages with a single frame. A positive result is an OOB read during capture.
  3. Observer registration in new UI. Look for BrowserList::AddObserver without a matching BrowserList::RemoveObserver, then move the hosting tab to another window, close the original window, and trigger a BrowserList event by opening or closing a window. A positive result is a UAF on the observer.
  4. Tab-specific menus and bubbles. Open the menu or bubble, close the tab, then select an item. A positive result is a UAF, as with the mini menu.
  5. Extension-driven deletion of data a bubble refers to. With the group editor bubble open, delete the group from an extension and then select a bubble item. A positive result is an OOB read.
  6. Drag and drop during window close. Drag a link over the tab strip while a window is closing, when the window still exists but has no tabs. A positive result is an OOB read in the drop bounds code.
  7. Focus handling for dialogs. Move a JavaScript dialog to another window, close the original window, then close the dialog. A positive result is a UAF in the focus removal call.
  8. Upstream fixes that Edge overrides. Take Chromium issues fixed in methods that Edge subclasses or overrides, such as TabStrip::GetDropBounds, and check whether the Edge override still reproduces. A positive result is the same crash as the original Chromium issue.
  9. Static search for iterator dereferences. Run the weggli query from the post against the code base and inspect dereferences of std::*find* results that are not compared to an end-like method, including comparisons hidden in a DCHECK. A positive result is a dereference that can be reached with an out-of-bounds iterator.
  10. Static search for unsafe binds. Use a Clang AST matcher or CodeQL to find base::BindOnce and base::BindRepeating calls that store raw pointers or weak pointers to types that must only be used on the UI thread, such as WebContents. A positive result is a bind whose closure is used on another thread or after the object can be destroyed.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 42 min read.

What happened, in plain words

A security researcher named David Erceg (@david_erceg) spent time poking at Microsoft Edge, the web browser, looking for a particular kind of programming mistake. He found several of them, reported each one to Microsoft, and Microsoft paid him a total of $215,000 USD for the reports. The write-up was published on 2022-10-17 on Microsoft's Edge Vulnerability Research (EdgeVR) blog, as a guest post.

The mistakes he found all belong to a family called memory corruption. That phrase sounds scary, and it is, but the idea is simple. A program keeps information in the computer's memory, and it has to remember which parts of memory belong to which thing. If the program loses track, it can read or write memory that it should not touch. Sometimes that just makes the browser crash. Sometimes, in the wrong hands, it can be turned into something worse.

The post is not one single bug report. It is a tour of eight separate issues, each with a short story about how he found it, plus a long worked example showing how he investigated one of the crashes to determine its root cause. The Edge security team added comments throughout, explaining how they handled each report and how they hunt for similar bugs.

Much of what he found was in Edge-specific code, meaning features that Microsoft added on top of the open-source Chromium browser that Edge is built from. That is an important clue for anyone who wants to hunt bugs themselves: new code written by one company is often less tested than code that millions of people have already looked at.

The background you need first

Before the individual bugs make sense, a few concepts need to be on the table. None of them require any prior security knowledge.

Browser process versus renderer process

Modern browsers split themselves into several programs, called processes, that run side by side.

  • The browser process is the boss. It draws the window, the tabs, the address bar, the menus and the dialogs. It has the most power on your computer.
  • The renderer processes are the workers. Each one takes a web page and turns it into what you see inside a tab. They are deliberately kept in a cage (the sandbox) so that a malicious page cannot easily reach the rest of your machine.

A bug in a renderer is bad. A bug in the browser process is worse, because the browser process is outside the cage. The issues in this post are memory corruption issues in the browser process. That is why the researcher calls them "some of the most severe issues in Chromium and browsers that are based off it".

Use-after-free (UAF)

Imagine you borrow a library book, return it, and then later try to read a note you wrote on page 42. The book is gone; the shelf space may even have been given to a different book. If you read page 42 anyway, you are reading whatever happens to be there now.

A use-after-free is exactly that, in memory. The program tells the operating system "I am done with this block of memory", the block is freed, and then some other part of the program still holds a pointer to it and uses it. The memory may now belong to something else entirely. The result can be a crash, or, in the worst case, the program can be tricked into treating attacker-controlled data as if it were its own.

Out-of-bounds (OOB) read and write

Imagine a row of ten lockers, numbered 1 to 10. If you are told to open locker 11, you are reaching past the end of the row. In memory, an out-of-bounds read means the program reads data just past the end of an array or list. An out-of-bounds write means it writes there. Reads tend to leak information; writes can corrupt neighbouring data. Both are bugs.

Asynchronous operations

An asynchronous operation is one that starts now and finishes later, while the rest of the program keeps running. Ordering a pizza is asynchronous: you place the order, you keep doing other things, and the pizza arrives at some unpredictable moment. If you move house before the pizza arrives, the delivery goes wrong.

Many of the bugs in this post come from exactly that mismatch: the browser starts something that will finish later, and by the time it finishes, the thing it was going to update has been closed or destroyed.

Dialogs, bubbles and menus

A dialog is a small window that asks you something or shows you information. A bubble is a dialog-like popup attached to a button or a piece of text. A menu is a list of actions. All three are drawn by the browser process, and all three can be closed by the user at any time, which makes them a rich source of lifetime bugs.

unique_ptr and raw pointers

In C++, the language Chromium and Edge are written in, a pointer is a value that says "the data you want is over there, at this address". A raw pointer is just that address, with no promises attached.

A unique_ptr is a special kind of pointer that owns what it points at. When the unique_ptr is destroyed, the thing it points at is destroyed too. It is like a key that also switches off the lights when you drop it. The post assumes the reader knows this, so it is worth stating plainly: when the write-up says a class "holds an instance in a member variable, likely as a unique_ptr", it means the outer object is responsible for the inner object's lifetime.

Symbols, PDB files and decompilers

When a program is compiled, the names of functions and variables are usually stripped out, leaving only numbers. A PDB file is a separate file that maps those numbers back to names. Microsoft publishes PDB files for Edge, which is what makes the investigation in this post possible.

A decompiler is a tool that takes compiled machine code and tries to turn it back into something resembling the original source code. It is never perfect, but it is close enough to follow the logic. The researcher uses Ghidra for this.

A debugger is a tool that lets you pause a running program, look at its memory, and step through it one instruction at a time. The researcher uses WinDbg for this.

AddressSanitizer (ASan)

AddressSanitizer is a special build of a program that watches every memory access and shouts loudly the moment one goes wrong. Chromium publishes ready-made ASan builds, so checking a crash in Chromium is often as simple as downloading one and reproducing the bug. Edge does not publish ASan builds, which is why the researcher had to do the slower Ghidra and WinDbg work described later.

The Edge Vulnerability Research Team's response

Throughout the original post, the Edge security team inserts short sections explaining how they handled the report, how they searched for similar bugs, and what they think about the class of issue. These are included in the beginner version too, because they show the other half of the story: what happens after a researcher presses send.

The setup

The post does not describe any special accounts, permissions or configuration. The researcher simply used Edge the way anyone would: the app menu, the install dialog, reader mode, DevTools, the tab strip, vertical tabs. A couple of scenarios involve a second browser profile, and a couple involve a browser extension, because extensions can do things like delete a tab group or navigate a tab.

For the investigation work, he used two tools plus Microsoft's debugging symbols:

  1. Ghidra, to decompile the binary back into an approximate version of the original code.
  2. WinDbg, to debug the running browser.

There are no AddressSanitizer (ASan) builds available for Edge, unlike Chromium, where pre-built ASan binaries are available. That absence is the reason the researcher relies on Ghidra and WinDbg to confirm that a crash is a genuine memory corruption issue rather than a harmless NULL pointer dereference.

Ghidra setup, as given in the post:

  1. Download Ghidra.
  2. In Ghidra, create a new project and import msedge.dll (found in C:\Program Files (x86)\Microsoft\Edge\Application\{version}).
  3. Open msedge.dll in the CodeBrowser tool. When asked if you would like to analyse msedge.dll, select "No".
  4. Load the PDB for msedge.dll, by selecting File > Load PDB File… Ensure that you have a local symbol storage path configured and that you've added the Microsoft symbol server (https://msdl.microsoft.com/download/symbols) as a search path.
  5. Once you've loaded the PDB file, Ghidra will process it, before performing an auto analysis of msedge.dll. Expect this process to take a while, at least several hours. Once the auto analysis has finished, you can then browse through the decompiled code generated from msedge.dll.

What those steps mean in plain words:

  1. Ghidra is free software; you download it from its official release page.
  2. A project in Ghidra is just a folder that holds your work. msedge.dll is the big file that contains most of Edge's browser-process code. The {version} placeholder stands for whichever version number is installed on the machine.
  3. The CodeBrowser is Ghidra's main window for looking at code. Ghidra offers to analyse the file automatically; the researcher says no at this point because he wants to load the symbols first.
  4. A symbol server is a web service that hands out PDB files on demand. Microsoft runs one at the URL shown. Adding it as a search path tells Ghidra where to fetch the names.
  5. Auto analysis is Ghidra's attempt to figure out which bytes are code, which are data, and how they connect. It is slow, but once it finishes you can read the decompiled code.

WinDbg setup is minimal: ensure the Microsoft symbol server is included in the symbol server settings, then attach WinDbg to the Edge browser process.

One important limit: Microsoft only provides symbols for the current version of msedge.dll, so the exact demonstration in the post cannot be reproduced against the older build it was based on. The process, not the exact addresses, is what matters.

How he found them

The researcher's approach is pattern-based. Several of the issues come from the same underlying idea: any asynchronous process, or any UI element whose lifetime is independent of the objects it references, is a candidate for a lifetime bug. The concrete patterns he describes are:

  • A dialog or menu that refers to a WebContents (a tab) can outlive that tab.
  • A tab modal dialog that refers to a Browser instance, or anything associated with it such as the BrowserView, can survive the tab and dialog being moved to another window and the original window being closed.
  • A dialog that refers to data an extension or web page can modify or delete is problematic, because that data can change while the dialog is shown.
  • Functionality added specifically to a Chromium fork is a good place to look, because it is hard to know what a fork changed without source access, whereas new features are easier to reason about.
  • Issues fixed in Chromium may still reproduce in Edge if Edge overrides or re-implements the affected code.

He also notes that BrowserList::AddObserver should always be matched with BrowserList::RemoveObserver. An unmatched pair is likely problematic, though not certainly: an object that lives for the whole browser lifetime may add an observer and never remove it, which is fine because it is never destroyed until the browser closes.

In everyday terms: an observer is a subscription. If you subscribe to a newsletter when you sign up, you should unsubscribe when you leave. If you do not, the newsletter keeps arriving at an address that no longer exists, and the postal service may hand it to whoever lives there now. BrowserList is the browser's list of open windows; adding an observer means "tell me when windows open or close". Removing it means "stop telling me".

The eight issues, one by one

The following subsections follow the original order.

Step 1: UAF when selecting a custom icon for a web app

In Edge you can select a custom icon when installing a web app. Open the app menu, select Apps > Install this site as an app, and the dialog shown allows you to select a custom icon. Clicking the "Edit" link in the install dialog opens a file selection dialog from which you choose a custom icon.

In a previous version of Edge, a UAF occurred if the web app install dialog was closed after the file selection dialog was opened but before a file was selected. The code that ran when a file was selected implicitly assumed the install dialog still existed. If the tab was navigated elsewhere the dialog was closed; if the tab was closed the dialog was also closed. Either could happen while the file selection dialog was shown.

The researcher calls this a classic lifetime bug. The file selection dialog is shown asynchronously, off the browser's main UI thread, so the browser remains interactive while it is shown, which is what allows the install dialog to be closed underneath it. This issue was rewarded $30,000 USD.

In plain words: you click "Edit", the browser asks the operating system to show a file picker, and while that picker is open you can still click around in the browser. If you close the tab, the install dialog is destroyed. Then you pick a file, and the code that handles the file tries to update a dialog that no longer exists. That is the use-after-free.

Step 2: OOB read when capturing a read: page

When looking for vulnerabilities in Chromium forks, the researcher suggests looking at fork-specific functionality. The web capture feature in Edge is such a feature.

Edge uses the read: scheme for reader mode. Load a page for which reader mode is available, for example https://techcommunity.microsoft.com/t5/discussions/dev-channel-update-to-95-0-997-1-is-live/m-p/2704057, and switch to it with F9; the read: scheme is then used. Opening DevTools on a reader mode page shows that the actual page content is inside an iframe.

A scheme is the first part of a web address, the bit before ://. You already know https: and http:. Edge adds read: for its reader mode, which strips a page down to just the article text. An iframe is a page inside a page, like a picture-in-picture window.

When a web capture is performed, the capture code has a special case for read: pages: it captures the contents of the iframe by iterating through the frames on the page. In a previous version of Edge there was no check that the end of the frames vector had been reached. So if a read: page had only a single frame, an OOB read occurred when attempting to capture it.

A vector is a growable list. Iterating through it means visiting each item in turn. If the code keeps going after the last item, it reads past the end, which is the out-of-bounds read.

Examples of a read: page with a single frame are an invalid read: page such as read://_/?url=, which is really just an error page, and a view-source:read:… page. The researcher found this by experimenting with web capture on different types of pages. This issue was rewarded $30,000 USD.

view-source: is another scheme; it shows the raw HTML of a page instead of rendering it. Combining it with read: produces an unusual page with only one frame, which is exactly the case the capture code mishandled.

Step 3: UAF after showing the guided switch dialog

This is another new Edge feature. The guided switch dialog is shown when a different profile can be used to log in to the target site. For example, if you are logged into the browser in one profile but not in a second profile, the dialog is shown when loading https://login.live.com/ in the second profile.

A profile is a separate set of bookmarks, passwords and logins inside the same browser. The guided switch dialog is Edge's way of saying "you are signed in to this site in another profile; would you like to switch?".

The dialog called BrowserList::AddObserver on creation. If the tab hosting the dialog was moved to another window and the original window was closed, the dialog did not call BrowserList::RemoveObserver on destruction. Then, if a BrowserList event was dispatched, for example because a browser window was created or closed, a UAF occurred. This issue was rewarded $30,000 USD.

In plain words: the dialog subscribed to window events when it opened, but forgot to unsubscribe when it closed in a particular sequence (tab moved to another window, original window closed). Later, when the browser announced "a window opened" or "a window closed", it tried to notify the dialog, which was already gone. That is the use-after-free.

Step 4: UAF with the text selection mini menu

The mini menu shown when selecting some text is another Edge-specific feature. The researcher's reasoning: for any browser UI element there are potential lifetime issues. A dialog might refer to the WebContents it was opened on, and the key question is whether the dialog can outlive the tab. If it can, that may lead to a UAF. The same applies to menus and bubble views, which are dialog-like elements shown in the browser.

A tab-specific menu that is not closed when the tab is closed is immediately suspect. Finding the issue was a matter of checking whether the menu was closed when the tab was closed. In a previous version of Edge it was not, which led to a UAF if one of the menu items was then selected. This issue was rewarded $5,000 USD.

In plain words: you select some text, a small menu pops up, you close the tab, and the menu stays on screen. If you then click an item in that menu, the code tries to act on a tab that no longer exists.

Step 5: OOB read in the group editor bubble

Vertical tabs are another Edge-specific feature. Turn on vertical tabs in a window, group a tab, and a three dot button appears in the tab strip. Clicking it shows the group editor bubble.

Vertical tabs put the tab list down the side of the window instead of across the top. A tab group is a named collection of tabs, like a folder for tabs.

Following on from the previous issue, the question is what happens if the group is deleted by an extension while the bubble is shown. In a previous version of Edge the bubble continued to be shown, leading to an OOB read when one of the menu items in the bubble was selected. The researcher notes this is very similar to issue 1228557 in the Chromium project. This issue was rewarded $30,000 USD.

In plain words: the bubble is showing information about a group. An extension deletes the group. The bubble does not notice, and when you click an item in it, the code reads data that is no longer there.

The Edge Vulnerability Research Team's response quotes the original report's remediation suggestion:

Aside from ensuring that the bubble is destroyed when the group is destroyed, future issues in this area could also be prevented by changing the DHCECK in TabGroupModel::GetTabGroup to a CHECK:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/tabs/tab_group_model.cc;l=42;drc=[redacted]

A DCHECK is a debug-only check: it runs in special test builds but is compiled out of the version you actually use. A CHECK is a check that always runs, even in the shipped browser. The researcher is suggesting that a check that only exists in debug builds is not enough to protect real users.

The team says this was not the direction the development team took, mainly to avoid unnecessarily forking upstream code, but it prompted the VR team to look for other issues involving dereferencing an out-of-bounds iterator. One method was the tool weggli, a fast semantic search tool built on the AST parsing library tree-sitter. The team gives this example query:

Text
weggli -X -R find=find -R end=end '{ $x = std::$find(_); NOT: _($x == $end()); NOT: _($x != $end()); _(*$x); }'

Line by line, in plain words:

  • weggli is the name of the program being run.
  • -X and -R find=find -R end=end are options that tell weggli how to treat certain names. The -R options define replacements so that the pattern can match any function whose name contains find or end.
  • The single-quoted part is the pattern to search for. It is written in a small language that describes shapes of code.
  • $x = std::$find(_); means "a variable $x is assigned the result of calling some function whose name starts with std:: and contains find". In C++, std::find is a standard function that looks for an item in a list and returns its position.
  • NOT: _($x == $end()); means "and there is no comparison of $x against the result of a function whose name contains end".
  • NOT: _($x != $end()); means "and there is no inequality comparison against such a function either".
  • _(*$x); means "and the code then dereferences $x", that is, it uses the value that $x points at.

Put together, the query finds code that looks up an item in a list, does not check whether the lookup succeeded, and then uses the result anyway. That is exactly the shape of an out-of-bounds read.

The query looks for code that dereferences the result of a function named std::*find* without first comparing it to the result of any method containing the string "end". The team notes this is not the only query they explored, since many other functions return iterators, and as David's comment indicates there could be a comparison for end() enclosed in a DCHECK. While writing the post the team ran the query again and found a fixed upstream issue in Edge that had failed to merge into their forked code. They stress that weggli, like CodeQL, is not a silver bullet that only identifies vulnerabilities; it finds starting points for research and verification.

An iterator is a cursor that points at a position in a list. Comparing it to end() is how C++ code asks "have I reached the end?". If the comparison is hidden inside a DCHECK, it disappears in the shipped build, and the safety net is gone.

Step 6: OOB read when dragging a link over the tab strip

This issue is essentially the same as issue 1209616 in the Chromium project. When a window is closed there is a brief period where the window still exists but contains no tabs. In a previous version of Edge an OOB read could occur if a link was being dragged over the tab strip at that time.

The Chromium issue was fixed by updating TabStrip::GetDropBounds to check whether the tab strip is empty. In Edge, the EdgeTabStrip class inherits from TabStrip and EdgeTabStrip::GetDropBounds overrides TabStrip::GetDropBounds. So although the issue was fixed in Chromium, the issue remained present in Edge. This illustrates that it is worthwhile to check whether issues fixed in Chromium still reproduce in Edge, and that changing core Chromium code, directly or indirectly, in a fork can mean security fixes do not have the intended effect in the fork. This issue was rewarded $30,000 USD.

In plain words: inheritance means one class builds on another. Overriding means the child class replaces a method with its own version. Chromium fixed the parent's version, but Edge's child version was still the old, broken one. The fix never reached the code that actually ran.

Step 7: UAF when closing the web app install dialog

As in the first issue, the web app install dialog allows a custom icon to be chosen. The researcher noticed a delay between selecting a custom icon file and the preview being shown in the dialog. The natural question: what happens if the dialog is closed before the icon preview is updated, that is, immediately after a file is selected?

In a previous version of Edge a UAF occurred, because the object processing the image on a background thread was destroyed in the middle of the processing operation when the dialog was closed. Again, an asynchronous process led to a lifetime issue. This issue was rewarded $30,000 USD.

A thread is a stream of instructions running inside a process. A background thread is one that does work while the main thread keeps the window responsive. If the object doing the background work is destroyed while the work is still running, the work touches freed memory.

The Edge Vulnerability Research Team's response says this is a very common bug pattern they have spent effort on through education and tooling. Internally, UAFs stemming from a mismatch of object lifetimes and threads using those objects account for a large number of the security team's findings. The team gives example code that looks very similar to the code that caused the issue:

This is a single C++ statement, but it is dense. Line by line, in plain words:

  • base::ThreadPool::PostTaskAndReply( is the call that says "run this work on a background thread, and when it finishes, run this other thing back on the original thread".
  • FROM_HERE, is a marker that records where in the source code the call was made, so that logs and crash reports can point at it.
  • {base::MayBlock(), base::TaskPriority::BEST_EFFORT, base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}, is a set of options. BEST_EFFORT means it is low priority. SKIP_ON_SHUTDOWN means "if the browser is shutting down, do not bother running this".
  • base::BindOnce( starts the description of the work to run on the background thread. BindOnce means it will run exactly once.
  • base::IgnoreResult(&MyClass::Method), names the function to run, MyClass::Method, and says its return value can be ignored.
  • base::Unretained(this), passes the current object (this) to that function as a raw pointer. Unretained literally means "I am not keeping this alive; I am just handing over the address".
  • parameter), is an extra argument passed to the method.
  • base::BindOnce(&MyClass::Callback, weak_ptr_factory_.GetWeakPtr())); describes the follow-up work. MyClass::Callback will run back on the original thread, and it is given a weak pointer to the object rather than a raw one.

In this code a task executing MyClass::Method is scheduled on a background thread. When it completes, MyClass::Callback is scheduled to execute on the sequence that originally called PostTaskAndReply. The this value for MyClass is bound as a parameter so that MyClass::Method uses the instance of MyClass. base::Unretained indicates this will be a raw pointer and will not be reference counted. Unlike the call to MyClass::Method, the first parameter of MyClass::Callback is a weak pointer, which causes Edge to check whether the instance of MyClass is still alive before attempting to execute Callback. If MyClass is destroyed on the same sequence that MyClass::Callback is scheduled, then when MyClass::Callback begins executing the object is still alive and remains alive for the entire time it runs.

A weak pointer is a pointer that can tell you whether the thing it points at still exists. It is like a phone number that tells you whether the line is still connected before you dial. A raw pointer has no such feature; it just dials.

In this case the bug was exactly as David described: the instance of MyClass could be destroyed while running in the background thread.

A race condition is when two things happen at the same time and the outcome depends on which one gets there first.

The team lists ways to audit these issues, from least to most complex:

  1. Grep. A dashboard of all newly added PostTask calls is a viable technique on commit. The cognitive load is high but verifying whether a PostTask call could lead to a problem usually takes a couple of seconds. It only helps audit new code, not code already in the code base, and is fragile if someone changes the parameters of an existing PostTask call.
  2. Clang AST matchers. Despite the heading of the chromium documentation for writing clang plugins being "Don't write a clang plugin", they can be useful. The core issue is passing a reference to this for use on another thread. Identifying the PostTask call itself can be tricky, but identifying these unsafe binds is trivial with a matcher plugin. This accurately identifies base::BindOnce and base::BindRepeating calls that store pointers or even weak pointers to these unsafe types, and can be run quickly on only recently changed files.
  3. CodeQL. Target the base::Bind* calls with CodeQL, and unlike a matcher you can find sinks where the closure created by the bind is used. GitHub has a pack of CodeQL scripts usable out of the box or as a starting point.
  4. Instrumentation. Potentially more complex, applied at build time or runtime. The idea is to pin memory access for certain object types to specific threads. For example, it is nearly ALWAYS a UAF if a pointer to a WebContents object, and many other object types, is dereferenced from any thread but the UI thread. Clang or runtime hooking can instrument memory accesses to these classes and alert on potential issues.

In plain words, those four techniques are:

  1. Grep is the simple text search you may have used on your computer. It is quick to run but only finds what you already know to look for.
  2. Clang AST matchers are a way of asking the compiler to find code by its shape rather than its text. An AST is the tree structure the compiler builds from your code. A matcher plugin is a small add-on that describes a shape and flags every match.
  3. CodeQL is a query language for code. It lets you ask questions like "where is the result of this bind actually used?", which is more powerful than a shape match.
  4. Instrumentation means adding extra code that watches the program as it runs. Here the idea is to tag certain objects as "UI thread only" and shout if any other thread touches them.

Step 8: UAF when closing a JavaScript dialog

In a previous version of Edge, F6 cycled focus not just between core UI elements in the browser window, such as the tab strip and address bar, but also any JavaScript dialog. F6 could shift focus to the dialog itself.

A JavaScript dialog is the little box a page can show with alert(), confirm() or prompt(). Focus is which element currently receives your keystrokes.

Internally, to support this, the dialog called BrowserView::SetFocusDialog on creation and BrowserView::RemoveFocusDialog on destruction. If the dialog was moved to another browser window, the original window closed, and the dialog then closed, the call to BrowserView::RemoveFocusDialog triggered a UAF, because it attempted to make a call on the original BrowserView.

In plain words: the dialog remembered which window it belonged to. You moved it to a different window and closed the original. When the dialog closed, it tried to tell the original window "I am done with focus", but that window was gone.

The researcher uses this to explain that dialogs are a good place to look. There are essentially two types:

  • Browser modal dialogs, tied to a browser window.
  • Tab modal dialogs, tied to a tab.

Modal means the dialog blocks interaction with what is behind it until it is dismissed.

This creates several places for potential issues:

  • A browser modal dialog that refers to a particular WebContents is likely wrong, since the tab can be closed without closing the dialog.
  • A tab modal dialog that refers to a particular Browser instance, or anything associated with that Browser such as the BrowserView, is likely wrong, since the tab and dialog can be moved to another browser window and the original window closed.
  • Any dialog that refers to data an extension or web page can modify or delete is problematic, precisely because the extension or page can modify data while the dialog is shown. An example is issue 1161144 in the Chromium project.

This issue was rewarded $30,000 USD.

Step 9: Verifying a memory corruption issue in Edge

For each issue the researcher typically observed a browser crash after a series of steps. The question is whether the crash is due to memory corruption. A crash referring to a valid-looking memory address is a dead giveaway, but that is not always what happens: many UAFs crash the browser with a reference to a near-NULL address, so there is a need to distinguish memory corruption from a harmless NULL pointer dereference.

A NULL pointer is a pointer that points at nothing. Dereferencing one is a bug, but a boring one: the program crashes immediately and predictably. A near-NULL address is a very small number, which often means the program was working from a NULL base and added a small offset. That can be a sign of a UAF rather than a simple NULL dereference, but it is not conclusive.

In Chromium this is often trivial, because ASan builds are available: download one, reproduce the issue, and check the output. Edge has no ASan builds, so the researcher uses Ghidra and WinDbg with Microsoft's debugging symbols.

The worked example is the first UAF, the custom icon issue. After observing a crash when selecting a custom icon file, the first step is to examine the crash dump. It gives this stack trace (only the last few relevant entries are shown):

A stack trace is the list of function calls that led to the crash, newest at the top. Reading it from the bottom up tells you the story of what happened. Line by line, in plain words:

  • msedge.dll!views::Link::OnMouseReleased(class ui::MouseEvent const &) is the bottom of the visible stack: the user released the mouse button over a link. This is the "Edit" link in the install dialog.
  • msedge.dll!base::internal::Invoker<...>::Run() is the machinery that turns a click into a call to the link's handler. The long template text in the middle is just the type of the callback being invoked.
  • msedge.dll!EdgeWebAppCustomIcon::OnEditIconButtonPressed() is the handler that runs when the Edit button is pressed. This is where the crash happened.
  • msedge.dll!WebAppCustomIconFile::~WebAppCustomIconFile() is the destructor of the icon file object, which is the top of the visible stack. The crash occurred while this destructor was running, inside the handler above.

The crash occurred within EdgeWebAppCustomIcon::OnEditIconButtonPressed, which gives a starting point. The next step is to look at the EdgeWebAppCustomIcon class in Ghidra. The post refers to screenshots here but the text describes what they show: EdgeWebAppCustomIcon holds an instance of WebAppCustomIconFile in a member variable, likely as a unique_ptr. The value is initialized to NULL in the constructor, the instance member is set in EdgeWebAppCustomIcon::OnEditIconButtonPressed with any previous instance destroyed, and the instance is also destroyed when appropriate in the destructor. So EdgeWebAppCustomIcon appears to own the WebAppCustomIconFile instance and manage its lifetime. If the WebAppCustomIconFile instance being destroyed is not valid, the EdgeWebAppCustomIcon instance likely is not either.

The next step is to check how the EdgeWebAppCustomIcon instance is created and destroyed. Ghidra can do this by searching for references to EdgeWebAppCustomIcon::EdgeWebAppCustomIcon and EdgeWebAppCustomIcon::~EdgeWebAppCustomIcon, but WinDbg tends to be better because there can be multiple callers, or the caller may not be shown by Ghidra depending on how the call is made.

With WinDbg attached to the browser, set a breakpoint on the constructor:

Text
bu msedge!EdgeWebAppCustomIcon::EdgeWebAppCustomIcon

A breakpoint is a command that tells the debugger "pause the program when it reaches this function". Line by line:

  • bu is the WinDbg command for "break on unresolved symbol". It sets a breakpoint by name, even if the address is not yet known.
  • msedge!EdgeWebAppCustomIcon::EdgeWebAppCustomIcon is the full name of the constructor. The ! separates the module (msedge) from the function name.

And a breakpoint on the destructor:

Text
bu msedge!EdgeWebAppCustomIcon::~EdgeWebAppCustomIcon

Same command, different function. The ~ in ~EdgeWebAppCustomIcon is C++ syntax for a destructor, the function that runs when the object is destroyed.

Running the browser with these breakpoints shows the instance being created in this way:

Reading from the bottom up: chrome::EdgeShowSiteDialog is the function that opens the install dialog. It creates a WebAppConfirmationView, which is the view (the visible content) of that dialog. That view, in turn, creates the EdgeWebAppCustomIcon.

And destroyed in this way:

Reading from the bottom up: the operating system reports that the window was destroyed (views::NativeWidgetAura::OnWindowDestroyed). The widget layer reacts (views::Widget::OnNativeWidgetDestroyed), then deletes the delegate (views::WidgetDelegate::DeleteDelegate), which runs the scalar deleting destructor of WebAppConfirmationView, which runs its destructor, which runs the destructor of EdgeWebAppCustomIcon. In other words, the icon object is destroyed as a consequence of the dialog's window being destroyed.

Looking at WebAppConfirmationView in Ghidra shows the EdgeWebAppCustomIcon instance stored in a member variable, again likely as a unique_ptr. To summarise:

  • WebAppConfirmationView is the view associated with the web app install dialog.
  • It holds an instance of EdgeWebAppCustomIcon in a member variable. When WebAppConfirmationView is destroyed, EdgeWebAppCustomIcon is destroyed as well.
  • WebAppConfirmationView is destroyed when the web app install dialog is closed, which can happen when the tab is navigated elsewhere or closed.

So the original scenario plays out as follows:

  1. The user opens the web app install dialog on a tab. An instance of WebAppConfirmationView is created, which creates an instance of EdgeWebAppCustomIcon and stores it in a member variable.
  2. The user clicks the "Edit" link in the install dialog, which results in a file selection dialog being shown.
  3. The tab is navigated to a different location or closed, by the page itself or by an extension. This closes the dialog and destroys both the WebAppConfirmationView and EdgeWebAppCustomIcon instances.
  4. The user chooses a file from the file selection dialog, which causes EdgeWebAppCustomIcon::OnEditIconButtonPressed to access members of the class. The EdgeWebAppCustomIcon instance has already been destroyed, so this is a UAF.

As a side note, when verifying a UAF it can be useful to see that the memory being accessed was the memory that was freed. WinDbg allows data breakpoints for that purpose. For example, you might observe the creation of the EdgeWebAppCustomIcon instance and place a data breakpoint on its address (the command assumes the address is 4fe400c5bf00):

Text
ba w8 4fe400c5bf00

A data breakpoint is different from a normal breakpoint. A normal breakpoint pauses when the program reaches a particular line of code. A data breakpoint pauses when the program touches a particular piece of memory. Line by line:

  • ba is the WinDbg command for "break on access".
  • w means "break on write".
  • 8 means the size of the watched region is 8 bytes.
  • 4fe400c5bf00 is the address to watch. The post uses this as an example address; it is not a real address you should expect to see.

The breakpoint should be hit when the instance is freed, and you can then verify that EdgeWebAppCustomIcon::OnEditIconButtonPressed is trying to access memory within that block.

Another useful feature in WinDbg preview is time travel debugging. A crash dump only gives information about where the crash occurred, which is not necessarily helpful for finding the cause. If an object is used from many places and can be allocated in various ways, a UAF involving it might crash in a variety of locations depending on what tries to access it first, and a crash dump will probably show the object involved but not where it was allocated. Time travel debugging coupled with data breakpoints is powerful for those crashes. The researcher did not need it for any of the issues listed here, but used it for more recent issues where it was essential.

Time travel debugging lets you record a session and then rewind it, like a video player for the program's execution. Instead of guessing what happened before the crash, you can step backwards and watch it happen.

Root cause

The issues share a small number of root causes:

  • Lifetime mismatch between an asynchronous operation and the UI object that started it. The file selection dialog and the background image processing both run asynchronously, so the install dialog can be destroyed while the operation is still pending, and the callback then touches freed memory.
  • Unmatched observer registration. The guided switch dialog calls BrowserList::AddObserver on creation but does not call BrowserList::RemoveObserver when it is destroyed after its tab is moved to another window and the original window is closed, so a later BrowserList event dispatches to a freed object.
  • UI elements that outlive the tab or window they refer to. The mini menu is not closed when its tab closes; the group editor bubble stays shown after the group is deleted; the JavaScript dialog calls BrowserView::RemoveFocusDialog on a BrowserView that belonged to a window that has since been closed.
  • Missing bounds checks. The web capture code iterates the frames vector for read: pages without checking for the end of the vector, so a single-frame read: page causes an OOB read. The tab strip code reads the tab strip while it is empty during window close, because the Chromium fix in TabStrip::GetDropBounds was overridden by EdgeTabStrip::GetDropBounds.

Why existing defences did not stop them: the post does not describe any specific defence that failed, but it does show two structural reasons. First, Edge has no ASan builds, so confirming a crash is memory corruption takes manual work with Ghidra and WinDbg. Second, fixes made upstream in Chromium do not automatically protect Edge when Edge overrides the affected method or re-implements the feature, as with EdgeTabStrip::GetDropBounds. The team also notes that a DCHECK comparison against end() can be compiled out, which is why the weggli query looks for dereferences without a comparison and why the team suggested a CHECK in TabGroupModel::GetTabGroup.

Impact

The post describes memory corruption issues in the browser process as typically some of the most severe issues in Chromium and Chromium-based browsers. The researcher observed browser crashes in each case. The post does not describe remote code execution, sandbox escape, or any specific attacker capability beyond the crash and the memory corruption class (UAF, OOB read). Several scenarios require the user to perform UI actions, such as opening the install dialog and choosing a file, dragging a link over the tab strip during window close, or selecting a menu item after the tab or group has gone. Some scenarios can be triggered by a page or an extension: the tab can be navigated or closed by the page itself or by an extension, and the tab group can be deleted by an extension.

The total reward for the issues described is $215,000 USD. The individual rewards stated in the post are $30,000 for the custom icon UAF, $30,000 for the read: capture OOB read, $30,000 for the guided switch dialog UAF, $5,000 for the mini menu UAF, $30,000 for the group editor bubble OOB read, $30,000 for the tab strip drag OOB read, $30,000 for the install dialog close UAF, and $30,000 for the JavaScript dialog UAF. The Edge Vulnerability Research Team notes that it aligns closely with Chromium's severity guidelines and that, due to recent changes in the upstream policy regarding user interaction, some of these issues if reported today may not be paid out at the same amount.

Fix

The post does not give the exact patch for each issue. It does say what the correct behaviour should be and, in one case, what was suggested versus what was done:

  • For the group editor bubble, the researcher suggested ensuring the bubble is destroyed when the group is destroyed, and changing the DCHECK in TabGroupModel::GetTabGroup to a CHECK. The team says this was not the direction the development team took, mainly to avoid unnecessarily forking upstream code.
  • For the tab strip drag issue, Chromium fixed it by updating TabStrip::GetDropBounds to check whether the tab strip is empty. Edge needed the equivalent check in its override.
  • For the observer issue, BrowserList::AddObserver should be matched with BrowserList::RemoveObserver.
  • For the dialogs, the guidance is structural: a browser modal dialog should not refer to a particular WebContents, a tab modal dialog should not refer to a particular Browser or BrowserView, and no dialog should refer to data an extension or page can modify or delete while it is shown.

Variants to test

These are the follow-up experiments the post suggests, written so that someone new to security can follow them. Each one is a way of asking "does the same mistake happen somewhere else?".

  1. Async file pickers and background processing in other install or settings dialogs. Open the dialog, start the async operation, then navigate or close the tab before completing it. A positive result is a crash whose stack shows a destructor of the dialog's view followed by a callback into the destroyed object.
  2. Other read: and view-source: combinations in web capture. Try invalid read: pages such as read://_/?url= and view-source:read:… pages, and pages with a single frame. A positive result is an OOB read during capture.
  3. Observer registration in new UI. Look for BrowserList::AddObserver without a matching BrowserList::RemoveObserver, then move the hosting tab to another window, close the original window, and trigger a BrowserList event by opening or closing a window. A positive result is a UAF on the observer.
  4. Tab-specific menus and bubbles. Open the menu or bubble, close the tab, then select an item. A positive result is a UAF, as with the mini menu.
  5. Extension-driven deletion of data a bubble refers to. With the group editor bubble open, delete the group from an extension and then select a bubble item. A positive result is an OOB read.
  6. Drag and drop during window close. Drag a link over the tab strip while a window is closing, when the window still exists but has no tabs. A positive result is an OOB read in the drop bounds code.
  7. Focus handling for dialogs. Move a JavaScript dialog to another window, close the original window, then close the dialog. A positive result is a UAF in the focus removal call.
  8. Upstream fixes that Edge overrides. Take Chromium issues fixed in methods that Edge subclasses or overrides, such as TabStrip::GetDropBounds, and check whether the Edge override still reproduces. A positive result is the same crash as the original Chromium issue.
  9. Static search for iterator dereferences. Run the weggli query from the post against the code base and inspect dereferences of std::*find* results that are not compared to an end-like method, including comparisons hidden in a DCHECK. A positive result is a dereference that can be reached with an out-of-bounds iterator.
  10. Static search for unsafe binds. Use a Clang AST matcher or CodeQL to find base::BindOnce and base::BindRepeating calls that store raw pointers or weak pointers to types that must only be used on the UI thread, such as WebContents. A positive result is a bind whose closure is used on another thread or after the object can be destroyed.

Glossary

  • AddressSanitizer (ASan): a special build of a program that watches every memory access and reports the moment one goes wrong.
  • Asynchronous: an operation that starts now and finishes later, while the rest of the program keeps running.
  • AST (abstract syntax tree): the tree structure a compiler builds from source code, used by tools to find code by shape rather than text.
  • Breakpoint: a debugger command that pauses the program when it reaches a particular function or line.
  • Browser process: the privileged part of a browser that draws the window, tabs, menus and dialogs.
  • Bubble: a dialog-like popup attached to a button or piece of text.
  • CHECK: a check in C++ that always runs, even in the shipped build.
  • Clang AST matcher: a plugin that asks the compiler to flag code matching a particular shape.
  • CodeQL: a query language for searching code by meaning rather than text.
  • Crash dump: a file recorded when a program crashes, containing the state of the program at that moment.
  • Data breakpoint: a debugger command that pauses when a particular piece of memory is read or written.
  • DCHECK: a debug-only check in C++ that is compiled out of the shipped build.
  • Decompiler: a tool that turns compiled machine code back into something resembling source code.
  • Debugger: a tool that lets you pause a running program, inspect its memory, and step through it.
  • Dialog: a small window that asks the user something or shows information.
  • Focus: which element on screen currently receives the user's keystrokes.
  • Ghidra: a free decompiler and reverse-engineering tool from the US National Security Agency.
  • Grep: a simple text search tool.
  • iframe: a page embedded inside another page.
  • Inheritance: in object-oriented programming, when one class builds on another and can reuse or replace its methods.
  • Instrumentation: extra code added to a program so that it reports what it is doing while it runs.
  • Iterator: a cursor that points at a position in a list.
  • JavaScript dialog: the small box a page shows with alert(), confirm() or prompt().
  • Memory corruption: a class of bug where a program reads or writes memory it should not touch.
  • Menu: a list of actions shown by the browser.
  • Modal: a dialog that blocks interaction with what is behind it until dismissed.
  • NULL pointer: a pointer that points at nothing.
  • Observer: a subscription to events, such as "tell me when a window opens or closes".
  • Out-of-bounds (OOB) read: reading data just past the end of an array or list.
  • Out-of-bounds (OOB) write: writing data just past the end of an array or list.
  • Overriding: when a child class replaces a method inherited from its parent with its own version.
  • PDB file: a file that maps compiled code back to function and variable names.
  • Pointer: a value that says where in memory some data lives.
  • Profile: a separate set of bookmarks, passwords and logins inside the same browser.
  • Race condition: when two things happen at the same time and the outcome depends on which gets there first.
  • Raw pointer: a pointer with no ownership or lifetime guarantees.
  • Reader mode: a browser feature that strips a page down to just its article text.
  • Renderer process: the part of a browser that turns a web page into what you see in a tab, kept in a sandbox.
  • Sandbox: a cage that limits what a process is allowed to do on the computer.
  • Scheme: the first part of a web address, such as https: or read:.
  • Stack trace: the list of function calls that led to a crash, newest at the top.
  • Symbol server: a web service that hands out PDB files on demand.
  • Thread: a stream of instructions running inside a process.
  • Time travel debugging: a debugger feature that records a session and lets you rewind it.
  • Tree-sitter: a library for parsing source code into a tree structure.
  • unique_ptr: a C++ pointer that owns what it points at and destroys it when it goes away.
  • Use-after-free (UAF): using memory after the program has said it is done with it.
  • Vector: a growable list in C++.
  • Vertical tabs: a browser layout that puts the tab list down the side of the window.
  • Weak pointer: a pointer that can tell you whether the thing it points at still exists.
  • Weggli: a fast semantic search tool for C and C++ code, built on tree-sitter.
  • WinDbg: Microsoft's debugger for Windows programs.

More by David Erceg

View all

1 more disclosed report, best first.

More from Microsoft

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.