Parser-aborted HTMLImageElement form-owner UAF yields page-controlled RIP (after the fix for bug 2058611)
A parser-aborted insertion of a customised built-in image element left the image's form pointer referencing a freed form, a use-after-free. The researcher turned this into a page-controlled indirect call target, so a web page could redirect execution to an address it chooses inside the content process.
Originally disclosed on Mozilla
- Fixed in 9 days
- Paid in 60 days
- Disclosed after 9 days
Created attachment 9627018 poc.html
Overview
An ordinary page can leave HTMLImageElement::mForm pointing to a freed
HTMLFormElement. A customized built-in <img> constructor moves its
parser-associated form and intended parent beneath the not-yet-inserted image.
The parser installs the form in the image's weak raw mForm pointer, then
aborts the append because it would create a DOM cycle. The abort does not clear
the image's form pointer and never performs the reciprocal registration that
would let the form destructor clear it.
The attached PoC advances the original UAF into a deterministic control-flow primitive on optimized x86-64 Firefox:
- It waits until the original form is collected, sprays same-size replacement forms, and uses the form named getter to identify the exact form that reused the stale address.
- Setting the retained image's
idthrough the stale pointer creates one valid image-name-table entry in that exact replacement form. - It keeps every other replacement form live, drops only the identified form, and waits until that one object is collected.
- A same-size
SVGFESpecularLightingElementtakes the isolated hole. Its firstSVGAnimatedStringis initialized with a non-nullVoidStringdata pointer; that pointer explicitly seeds nonzero bytes at the future stale table'smEntryCountoffset. The page then frees only this seeder. - A same-size
SVGTextPathElementreuses the isolated hole. Its first animatedhrefstring places a pointer to a page-controlled string buffer over the stale table'smOpspointer while leaving the explicitly seeded count bytes untouched. image.removeAttribute("id")entersPLDHashTable::Search(), which callsmOps->hashKey. The first eight bytes of the page string are interpreted as that function pointer.
The PoC deliberately selects the unmapped value 0x0000414141414141. The
official Release minidump reports RIP and the crash address as exactly that
value, with the caller symbolized as PLDHashTable::ComputeKeyHash() /
PLDHashTable::Search(). This is page-controlled indirect-call-target control,
not merely an allocator-influenced crash.
The page uses ordinary Custom Elements, DOM adoption, WeakRef, SVG/SMIL, and
allocation pressure. It requires no click, permission, extension, privileged
GC/CC API, browser automation, debugger, or preference change.
Build / Environment
- Ubuntu 24.04.4 LTS x86-64; Linux
6.8.0-137-generic. - Official Firefox Release
153.0.4, BuildID20260810162159, SourceStamp54be19de0e08edff0b797e55fd935dd3978b0a6d. - Mozilla's product-details endpoint reported
153.0.4as the latest Firefox Release on 2026-08-16.
The exact attachment was tested with newly empty profiles and no user.js,
Marionette, preference argument, feature override, or sandbox override. It
reproduced both with --headless and in a normal window under Xvfb; Xvfb only
provided the display server. Release crash metadata records
ProcessType=content, RemoteType=webIsolated, ContentSandboxEnabled=1, and
ContentSandboxLevel=6.
The same selected RIP also reproduced on an untouched official Firefox
Nightly 156.0a1, BuildID 20260814090231, SourceStamp
477c0df9965c2460b1582048e8ff9cb333dd2556, and on a clean optimized local
build from revision 8e42adb00f0d301d1b74f71d5f7d49228eb712c9 after all
diagnostic instrumentation was removed and the browser rebuilt.
The underlying freed access was independently classified by ASan on the local
Nightly source build. The controlled PoC intentionally targets the optimized
x86-64 object layout, where both native replacement types are 0x160 bytes.
Steps To Reproduce
-
Put
poc.htmlin an otherwise empty directory and serve it locally:Bash python3 -m http.server 8000 --bind 127.0.0.1The PoC sends its stage JSON as same-origin image requests, so the HTTP access log preserves the last completed stage even after the content process exits. The resulting 404 responses are expected and irrelevant.
-
Extract the official Firefox archive and launch it with a newly empty profile:
Bash CONTROL_PROFILE=$(mktemp -d /tmp/firefox-parser-image-control.XXXXXX) test ! -e "$CONTROL_PROFILE/user.js" timeout --signal=INT --kill-after=15s 180s \ /path/to/firefox/firefox \ --headless --no-remote --profile "$CONTROL_PROFILE" \ http://127.0.0.1:8000/poc.html test ! -e "$CONTROL_PROFILE/user.js" -
For a local minidump, add only Firefox's crash-retention variables to the command. They do not change web features, preferences, or sandboxing:
Bash MOZ_CRASHREPORTER=1 \ MOZ_CRASHREPORTER_NO_REPORT=1 \ MOZ_CRASHREPORTER_SHUTDOWN=1 \ /path/to/firefox/firefox --headless --no-remote \ --profile "$CONTROL_PROFILE" http://127.0.0.1:8000/poc.html -
A successful run records these stages before the content-process crash:
Text armed cycleAbortShape=1 adopted=1 oldForm-collection-check oldFormAlive=0 forms-sprayed sprayedForms=32768 exact-form-aba replacementIndex=46 (index may vary) replacement-collection-check replacementAlive=0 count-seeder-armed seeder-collection-check seederAlive=0 controlled-layout-armed textPaths=256 animatedStringsVerified=256 firstAnimCodeUnits=4141:4141:4141:0000:...unexpected-trigger-returnmust not appear. Collection timing may vary on a heavily loaded host; if a bounded collection check reports an error, repeat with a fresh browser process.
Actual Results
The final attached page reproduced on the official Release in both a headless run and a normal-window run. Each used a new empty profile and produced:
Crash reason: SIGSEGV / SEGV_MAPERR
Crash address: 0x0000414141414141
Thread 0 Isolated Web Co (crashed)
rip = 0x0000414141414141
rax = 0x000072fb378ae588 # page-controlled animated-string buffer
r14 = 0x000072fb3fd171c0 # stale form table / overlapping string field
Mozilla's matching Release Breakpad symbols resolve the controlled transfer:
PLDHashTable::ComputeKeyHash PLDHashTable.cpp:439
PLDHashTable::Search PLDHashTable.cpp:460
HTMLFormElement::RemoveElementFromTableInternal
HTMLFormElement.cpp:1323
HTMLFormElement::RemoveImageElementFromTable HTMLFormElement.cpp:1879
HTMLImageElement::BeforeSetAttr HTMLImageElement.cpp:249
Element::UnsetAttr Element.cpp:4262
Element::RemoveAttribute Element.cpp:1828
The selected value is derived directly from the first UTF-16 code units
4141:4141:4141:0000, whose little-endian first qword is
0x0000414141414141. The minidump's RIP equals that qword exactly.
A temporary address-only diagnostic build separately correlated the entire
reuse sequence at one native address: original form allocation and free,
replacement form allocation and free, seeder allocation and free, and
SVGTextPathElement allocation at the same address, with its animated-string
data pointer at the stale table field. Those diagnostics were removed, the
affected source files were verified clean, and the clean rebuild reproduced
the same selected RIP.
The earlier ASan validation of the root bug reports a heap-use-after-free in
HTMLFormElement::AddElementToTableInternal, with allocation in
NS_NewHTMLFormElement and release by cycle collection. The new PoC uses the
removal path because PLDHashTable::Search() reaches the hash callback
before performing a resize or another dependent access.
Expected Results
If parser insertion is aborted after SetFormElement(), every parser-installed
form association must be cleared before the element can escape to script.
Alternatively, the parser must defer the association until insertion succeeds.
HTMLImageElement::mForm must never outlive its HTMLFormElement, and a stale
image attribute mutation must never dispatch through bytes belonging to a
different DOM object.
Security Impact
This is a drive-by, web-reachable use-after-free in a site content process with a demonstrated page-controlled indirect call target. The attacker controls the object lifetime, isolates the exact freed slot, controls the replacement object, controls the string whose first qword becomes the function pointer, and chooses when the indirect call occurs. The official optimized Release reaches the exact selected RIP reliably under default web-feature configuration.
This evidence supports content-process code-execution impact rather than a denial-of-service-only classification. The attached proof deliberately chooses an unmapped marker and stops at the controlled transfer; it does not execute a payload.
Context
This is a use-after-free in Firefox's DOM and HTML code, in the component the platform lists as Core: DOM: Core & HTML. The object at the centre of it is HTMLImageElement, and specifically its mForm member: the weak raw pointer an image keeps to the HTMLFormElement it is associated with. Normally that association is reciprocal. When the parser (or script) puts a form-associated element into a form, the element records the form and the form records the element in its internal name and id tables, so that when either side goes away the other can be cleaned up.
The report describes a path where that reciprocity is broken. A customized built-in <img> constructor moves its parser-associated form and its intended parent beneath the not-yet-inserted image. The parser then installs the form in the image's weak raw mForm pointer, and immediately afterwards aborts the append because doing it would create a DOM cycle. The abort does not clear the image's form pointer, and it never performs the reciprocal registration that would let the form destructor clear it later. The result is an HTMLImageElement::mForm that points at a freed HTMLFormElement.
The report is a follow-up: the title notes it comes after the fix for bug 2058611, and the PoC turns the original use-after-free into a deterministic control-flow primitive on optimized x86-64 Firefox.
Setup
The researcher's environment:
- Ubuntu 24.04.4 LTS x86-64, Linux
6.8.0-137-generic. - Official Firefox Release
153.0.4, BuildID20260810162159, SourceStamp[redacted]. Mozilla's product-details endpoint reported153.0.4as the latest Firefox Release on 2026-08-16. - The same selected RIP also reproduced on an untouched official Firefox Nightly
156.0a1, BuildID20260814090231, SourceStamp[redacted], and on a clean optimized local build from revision[redacted]after all diagnostic instrumentation was removed and the browser rebuilt.
The exact attachment was tested with newly empty profiles and no user.js, Marionette, preference argument, feature override, or sandbox override. It reproduced both with --headless and in a normal window under Xvfb; Xvfb only provided the display server. Release crash metadata records ProcessType=content, RemoteType=webIsolated, ContentSandboxEnabled=1, and ContentSandboxLevel=6.
The underlying freed access was independently classified by ASan on the local Nightly source build. The controlled PoC intentionally targets the optimized x86-64 object layout, where both native replacement types are 0x160 bytes.
No click, permission, extension, privileged GC/CC API, browser automation, debugger or preference change is required by the page itself.
Finding it
The starting observation is the parser abort path. When a customized built-in <img> constructor moves its parser-associated form and intended parent beneath the not-yet-inserted image, the parser calls SetFormElement() and installs the form in the image's weak raw mForm pointer. It then aborts the append because the insertion would create a DOM cycle. That abort leaves the pointer in place and skips the reciprocal registration, so nothing will ever clear the image's pointer when the form is destroyed.
The earlier ASan validation of this root bug reports a heap-use-after-free in HTMLFormElement::AddElementToTableInternal, with allocation in NS_NewHTMLFormElement and release by cycle collection. The new PoC deliberately uses the removal path instead, because PLDHashTable::Search() reaches the hash callback before performing a resize or any other dependent access. That makes the first dereference of the stale table the indirect call itself.
Exploitation
The PoC advances the original UAF into a deterministic control-flow primitive on optimized x86-64 Firefox. The sequence is:
- It waits until the original form is collected, sprays same-size replacement forms, and uses the form named getter to identify the exact form that reused the stale address.
- Setting the retained image's
idthrough the stale pointer creates one valid image-name-table entry in that exact replacement form. - It keeps every other replacement form live, drops only the identified form, and waits until that one object is collected.
- A same-size
SVGFESpecularLightingElementtakes the isolated hole. Its firstSVGAnimatedStringis initialized with a non-nullVoidStringdata pointer; that pointer explicitly seeds nonzero bytes at the future stale table'smEntryCountoffset. The page then frees only this seeder. - A same-size
SVGTextPathElementreuses the isolated hole. Its first animatedhrefstring places a pointer to a page-controlled string buffer over the stale table'smOpspointer while leaving the explicitly seeded count bytes untouched. image.removeAttribute("id")entersPLDHashTable::Search(), which callsmOps->hashKey. The first eight bytes of the page string are interpreted as that function pointer.
The PoC deliberately selects the unmapped value 0x0000414141414141. The official Release minidump reports RIP and the crash address as exactly that value, with the caller symbolized as PLDHashTable::ComputeKeyHash() / PLDHashTable::Search(). That is page-controlled indirect-call-target control, not merely an allocator-influenced crash.
The page uses ordinary Custom Elements, DOM adoption, WeakRef, SVG/SMIL, and allocation pressure.
Step 1: serve the PoC
Put poc.html in an otherwise empty directory and serve it locally:
python3 -m http.server 8000 --bind [redacted]
The PoC sends its stage JSON as same-origin image requests, so the HTTP access log preserves the last completed stage even after the content process exits. The resulting 404 responses are expected and irrelevant.
Step 2: launch Firefox with a fresh profile
Extract the official Firefox archive and launch it with a newly empty profile:
CONTROL_PROFILE=$(mktemp -d /tmp/firefox-parser-image-control.XXXXXX)
test ! -e "$CONTROL_PROFILE/user.js"
timeout --signal=INT --kill-after=15s 180s \
/path/to/firefox/firefox \
--headless --no-remote --profile "$CONTROL_PROFILE" \
http://[redacted]:8000/poc.html
test ! -e "$CONTROL_PROFILE/user.js"
The two test lines check that no user.js exists before and after the run.
Step 3: keep a local minidump
For a local minidump, add only Firefox's crash-retention variables to the command. They do not change web features, preferences or sandboxing:
MOZ_CRASHREPORTER=1 \
MOZ_CRASHREPORTER_NO_REPORT=1 \
MOZ_CRASHREPORTER_SHUTDOWN=1 \
/path/to/firefox/firefox --headless --no-remote \
--profile "$CONTROL_PROFILE" http://[redacted]:8000/poc.html
Step 4: read the stage log
A successful run records these stages before the content-process crash:
armed cycleAbortShape=1 adopted=1
oldForm-collection-check oldFormAlive=0
forms-sprayed sprayedForms=32768
exact-form-aba replacementIndex=46 (index may vary)
replacement-collection-check replacementAlive=0
count-seeder-armed
seeder-collection-check seederAlive=0
controlled-layout-armed textPaths=256 animatedStringsVerified=256
firstAnimCodeUnits=[redacted]:...
unexpected-trigger-return must not appear. Collection timing may vary on a heavily loaded host; if a bounded collection check reports an error, repeat with a fresh browser process.
Step 5: the crash
The final attached page reproduced on the official Release in both a headless run and a normal-window run. Each used a new empty profile and produced:
Crash reason: SIGSEGV / SEGV_MAPERR
Crash address: 0x0000414141414141
Thread 0 Isolated Web Co (crashed)
rip = 0x0000414141414141
rax = 0x000072fb378ae588 # page-controlled animated-string buffer
r14 = 0x000072fb3fd171c0 # stale form table / overlapping string field
Mozilla's matching Release Breakpad symbols resolve the controlled transfer:
PLDHashTable::ComputeKeyHash PLDHashTable.cpp:439
PLDHashTable::Search PLDHashTable.cpp:460
HTMLFormElement::RemoveElementFromTableInternal
HTMLFormElement.cpp:1323
HTMLFormElement::RemoveImageElementFromTable HTMLFormElement.cpp:1879
HTMLImageElement::BeforeSetAttr HTMLImageElement.cpp:249
Element::UnsetAttr Element.cpp:4262
Element::RemoveAttribute Element.cpp:1828
The selected value is derived directly from the first UTF-16 code units [redacted], whose little-endian first qword is 0x0000414141414141. The minidump's RIP equals that qword exactly.
A temporary address-only diagnostic build separately correlated the entire reuse sequence at one native address: original form allocation and free, replacement form allocation and free, seeder allocation and free, and SVGTextPathElement allocation at the same address, with its animated-string data pointer at the stale table field. Those diagnostics were removed, the affected source files were verified clean, and the clean rebuild reproduced the same selected RIP.
Root cause
The mistake is in the parser's abort handling. After SetFormElement() has installed the form in the image's weak raw mForm pointer, the parser aborts the insertion because it would create a DOM cycle. The abort neither clears the image's form pointer nor performs the reciprocal registration that would let the form destructor clear it. HTMLImageElement::mForm therefore outlives its HTMLFormElement.
The second half of the problem is what a stale pointer can reach. A later attribute mutation on the image, here removeAttribute("id"), walks into the freed form's PLDHashTable through HTMLFormElement::RemoveElementFromTableInternal. PLDHashTable::Search() calls mOps->hashKey before any resize or other dependent access, so the first thing it does with the stale table is an indirect call through the mOps pointer. If the freed slot has been reused by an object whose layout places attacker-influenced bytes over mOps, the call target is page-controlled.
The PoC makes that reuse deterministic rather than allocator-dependent. The SVGFESpecularLightingElement seeder writes nonzero bytes at the stale table's mEntryCount offset through its first SVGAnimatedString data pointer, and the SVGTextPathElement then places a pointer to a page-controlled string buffer over mOps while leaving those count bytes untouched. The first eight bytes of the page string become the function pointer.
Impact
This is a drive-by, web-reachable use-after-free in a site content process with a demonstrated page-controlled indirect call target. The attacker controls the object lifetime, isolates the exact freed slot, controls the replacement object, controls the string whose first qword becomes the function pointer, and chooses when the indirect call occurs. The official optimized Release reaches the exact selected RIP reliably under default web-feature configuration.
The researcher states that this evidence supports content-process code-execution impact rather than a denial-of-service-only classification. The attached proof deliberately chooses an unmapped marker and stops at the controlled transfer; it does not execute a payload.
Fix
The report states what the fix should be rather than what was changed. If parser insertion is aborted after SetFormElement(), every parser-installed form association must be cleared before the element can escape to script. Alternatively, the parser must defer the association until insertion succeeds. HTMLImageElement::mForm must never outlive its HTMLFormElement, and a stale image attribute mutation must never dispatch through bytes belonging to a different DOM object.
Variants to test
- Other parser-aborted insertions that call a setter before the abort. Look for any element type whose parser path installs a back-pointer and then bails out on a cycle check. A positive result is a stage log showing the element escaping to script with a live pointer to an object that is later collected.
- Other weak back-pointers from DOM elements to containers. Any member that is set before a reciprocal registration and not cleared on abort is a candidate. A positive result is a stale pointer that survives a collection check (
...Alive=0) while the referring element is still reachable. - Other
PLDHashTableconsumers reached from attribute mutation. The removal path here reachesmOps->hashKeybefore any resize. A positive result is a crash whose RIP equals a qword taken from a page-controlled string, with the caller symbolized inPLDHashTable::Search(). - Other same-size replacement pairs for slot isolation. The PoC relies on both native replacement types being
0x160bytes on optimized x86-64. A positive result is the address-only diagnostic correlating allocation and free of the original object, the replacement, the seeder and the final object at one native address. - Different controlled marker values. The PoC uses the unmapped value
0x0000414141414141. A positive result is a minidump whose crash address and RIP both equal the chosen qword.
What happened, in plain words
Firefox keeps a small internal note inside every image on a web page: "this image belongs to that form over there". That note is a pointer, which is simply a memory address, a number that tells the browser where an object lives in its working memory. The bug is that in one particular situation the browser writes that note and then throws away the form without ever erasing the note. The image is left holding an address that no longer belongs to it. In computing this is called a dangling pointer, and using it later is called a use-after-free: you use memory after the browser has given it back.
What makes this report serious is what the researcher did next. Instead of just crashing the browser, he arranged for the freed memory to be reused, on purpose, by objects he controls from a web page. He then made the browser treat part of his own text as the address of a function to call. That is a big step: it means a normal web page, with no clicks and no special permissions, can influence which code the browser runs inside the process that handles website content.
This write-up walks through the whole thing slowly, from what a form and an image are inside the browser, to the exact commands used to reproduce the crash.
The pieces involved
Before the bug makes sense, a few everyday ideas need names.
- A web page is a text file the browser reads and turns into things you see: paragraphs, images, buttons. The browser builds an internal tree of these things, called the DOM (Document Object Model). Each thing in the tree, such as an image or a form, is an object in the browser's memory.
- A form is the part of a page where you type things and press a button to send them, for example a login box. Inside the browser a form is an object of type
HTMLFormElement. - An image is an object of type
HTMLImageElement. - When an image sits inside a form, the browser records the relationship in both directions: the image remembers its form, and the form keeps a list of the images inside it. This two-way bookkeeping is what lets the browser clean up correctly when either side disappears.
- A pointer is a number that says where something lives in memory. A weak pointer is a pointer that does not keep the target alive: if everything else lets go of the target, the target is removed and the weak pointer is left pointing at nothing useful.
- Memory allocation is the browser reserving a chunk of memory for an object. Freeing is giving that chunk back so it can be reused. Garbage collection (and its cousin cycle collection) is the browser's automatic cleanup of objects nobody can reach any more.
- A use-after-free is the mistake of reading or writing memory through a pointer after that memory has been freed and possibly handed to something else.
- The parser is the part of the browser that reads the page's text and builds the DOM from it, top to bottom.
- A custom element is a feature that lets a page define its own kind of HTML tag in JavaScript, the browser's scripting language. A customized built-in is a custom element that extends an existing tag, such as
<img>, instead of inventing a new one. - SVG is a way to draw shapes with text markup. SMIL is the part of SVG that animates those shapes over time.
- ASan (AddressSanitizer) is a debugging tool that watches memory and shouts when a program touches memory it should not.
- RIP is the name of the processor register that holds the address of the instruction currently being executed. If a crash report says RIP is some value, it means the processor tried to run code at that address.
- A minidump is a small snapshot of a crashed program that the browser can save for later analysis.
- Breakpad is Mozilla's system for turning those snapshots into readable function names.
Context: the two-way bookkeeping that broke
This is a use-after-free in Firefox's DOM and HTML code, in the component the platform lists as Core: DOM: Core & HTML. The object at the centre of it is HTMLImageElement, and specifically its mForm member: the weak raw pointer an image keeps to the HTMLFormElement it is associated with. Normally that association is reciprocal. When the parser (or script) puts a form-associated element into a form, the element records the form and the form records the element in its internal name and id tables, so that when either side goes away the other can be cleaned up.
Think of it like a coat check. You hand over your coat and get a ticket; the cloakroom also writes your ticket number in its book. If either side loses its half of the record, the coat can be handed to someone else while your ticket still claims it.
The report describes a path where that reciprocity is broken. A customized built-in <img> constructor moves its parser-associated form and its intended parent beneath the not-yet-inserted image. The parser then installs the form in the image's weak raw mForm pointer, and immediately afterwards aborts the append because doing it would create a DOM cycle. A DOM cycle means the tree would end up containing itself, like a box that contains the box, which the browser refuses to build. The abort does not clear the image's form pointer, and it never performs the reciprocal registration that would let the form destructor clear it later. The result is an HTMLImageElement::mForm that points at a freed HTMLFormElement.
The report is a follow-up: the title notes it comes after the fix for bug 2058611, and the PoC (proof of concept, a small program that demonstrates a bug) turns the original use-after-free into a deterministic control-flow primitive on optimized x86-64 Firefox. "Deterministic" means it happens the same way every time rather than depending on luck. A "control-flow primitive" means the attacker can influence which code the processor jumps to next.
Setup: the researcher's environment
The researcher's environment:
- Ubuntu 24.04.4 LTS x86-64, Linux
6.8.0-137-generic. Ubuntu is a Linux distribution, x86-64 is the common 64-bit processor family, and the kernel version is the core of the operating system. - Official Firefox Release
153.0.4, BuildID20260810162159, SourceStamp[redacted]. A BuildID is a timestamp-like identifier Mozilla stamps on each build; a SourceStamp identifies the exact source code revision it was built from. Mozilla's product-details endpoint reported153.0.4as the latest Firefox Release on 2026-08-16. - The same selected RIP also reproduced on an untouched official Firefox Nightly
156.0a1, BuildID20260814090231, SourceStamp[redacted], and on a clean optimized local build from revision[redacted]after all diagnostic instrumentation was removed and the browser rebuilt. Nightly is Mozilla's experimental pre-release channel. "Optimized" means compiled for speed rather than for easy debugging, which changes how objects are laid out in memory.
The exact attachment was tested with newly empty profiles and no user.js, Marionette, preference argument, feature override, or sandbox override. A profile is the folder where Firefox keeps your settings, history and add-ons; an empty one means the test starts from factory defaults. user.js is a file that can force settings on every start. Marionette is Firefox's remote-control interface for automated testing. A sandbox is the operating-system feature that limits what a process is allowed to touch. It reproduced both with --headless (no visible window) and in a normal window under Xvfb; Xvfb only provided the display server, a fake screen for machines without a monitor. Release crash metadata records ProcessType=content, RemoteType=webIsolated, ContentSandboxEnabled=1, and ContentSandboxLevel=6. In plain terms: the crash happened in the sandboxed process that handles web content, with the sandbox switched on at level 6.
The underlying freed access was independently classified by ASan on the local Nightly source build. The controlled PoC intentionally targets the optimized x86-64 object layout, where both native replacement types are 0x160 bytes. 0x160 is hexadecimal for 352, so both objects occupy 352 bytes, which is what lets one neatly take the other's place in memory.
No click, permission, extension, privileged GC/CC API, browser automation, debugger or preference change is required by the page itself. GC and CC here mean garbage collection and cycle collection, the browser's internal cleanup routines; a page normally cannot ask for them directly.
Finding it: where the pointer is left behind
The starting observation is the parser abort path. When a customized built-in <img> constructor moves its parser-associated form and intended parent beneath the not-yet-inserted image, the parser calls SetFormElement() and installs the form in the image's weak raw mForm pointer. It then aborts the append because the insertion would create a DOM cycle. That abort leaves the pointer in place and skips the reciprocal registration, so nothing will ever clear the image's pointer when the form is destroyed.
In coat-check terms: the attendant writes your ticket number in the book, then refuses the coat because the rack would fall over, but never crosses the number out. Later the number points at a coat belonging to someone else.
The earlier ASan validation of this root bug reports a heap-use-after-free in HTMLFormElement::AddElementToTableInternal, with allocation in NS_NewHTMLFormElement and release by cycle collection. "Heap" is the general-purpose pool of memory programs use for objects that come and go. The new PoC deliberately uses the removal path instead, because PLDHashTable::Search() reaches the hash callback before performing a resize or any other dependent access. That makes the first dereference of the stale table the indirect call itself. A hash table is a lookup structure that stores items in numbered slots so they can be found quickly; PLDHashTable is Firefox's version of it. A callback is a function the program hands over to be called later. An indirect call is a jump to an address stored in memory rather than written into the program, which is exactly what an attacker wants to influence.
Exploitation: turning a crash into control
The PoC advances the original UAF into a deterministic control-flow primitive on optimized x86-64 Firefox. The sequence is:
- It waits until the original form is collected, sprays same-size replacement forms, and uses the form named getter to identify the exact form that reused the stale address. "Spraying" means creating many objects of the same size so that one of them lands in the freed slot. A getter is a property that runs code when read; the form named getter looks up a form by its name.
- Setting the retained image's
idthrough the stale pointer creates one valid image-name-table entry in that exact replacement form. Theidis the element's identifier attribute. Because the image still points at the freed address, and that address now holds a new form, the write lands in the new form's table. - It keeps every other replacement form live, drops only the identified form, and waits until that one object is collected. This isolates a single hole in memory, so the next allocation is predictable.
- A same-size
SVGFESpecularLightingElementtakes the isolated hole. Its firstSVGAnimatedStringis initialized with a non-nullVoidStringdata pointer; that pointer explicitly seeds nonzero bytes at the future stale table'smEntryCountoffset. The page then frees only this seeder.SVGFESpecularLightingElementis an SVG filter object that produces a shiny lighting effect;SVGAnimatedStringis a string that can change over time. "Seeding" means writing chosen bytes into the slot so a later structure looks the way the attacker wants. - A same-size
SVGTextPathElementreuses the isolated hole. Its first animatedhrefstring places a pointer to a page-controlled string buffer over the stale table'smOpspointer while leaving the explicitly seeded count bytes untouched.SVGTextPathElementis the SVG object that draws text along a path.mOpsis the table's pointer to a set of operations, including the hash function. image.removeAttribute("id")entersPLDHashTable::Search(), which callsmOps->hashKey. The first eight bytes of the page string are interpreted as that function pointer. Removing theidattribute makes the browser try to update the form's name table, and that lookup calls through the corrupted operations pointer.
The PoC deliberately selects the unmapped value 0x0000414141414141. "Unmapped" means no memory exists at that address, so the processor cannot execute anything there and the program crashes immediately. The value is chosen because it is easy to recognise: 0x41 is the ASCII code for the capital letter A, so the address reads as a row of A's. The official Release minidump reports RIP and the crash address as exactly that value, with the caller symbolized as PLDHashTable::ComputeKeyHash() / PLDHashTable::Search(). That is page-controlled indirect-call-target control, not merely an allocator-influenced crash. In other words, the page chose the address the processor jumped to, rather than the memory allocator happening to produce a bad one.
The page uses ordinary Custom Elements, DOM adoption, WeakRef, SVG/SMIL, and allocation pressure. DOM adoption is moving an existing element from one parent to another. WeakRef is a JavaScript feature that holds a reference to an object without preventing its cleanup, so the page can tell when the object has been collected. Allocation pressure means creating lots of objects to push the browser's memory manager into reusing a particular slot.
Step 1: serve the PoC
Put poc.html in an otherwise empty directory and serve it locally:
python3 -m http.server 8000 --bind [redacted]
Line by line:
python3runs the Python 3 interpreter, which is installed on most Linux systems.-m http.servertells Python to run its built-in web server module.8000is the network port to listen on; a port is a numbered door on a computer that a service listens at.--bind [redacted]restricts the server to the local machine only, so nothing is exposed to the network.[redacted]is the standard address meaning "this computer".
The PoC sends its stage JSON as same-origin image requests, so the HTTP access log preserves the last completed stage even after the content process exits. JSON is a simple text format for structured data. Same-origin means the requests go to the same address the page came from, which browsers allow without special permission. The resulting 404 responses are expected and irrelevant; 404 is the web's "not found" answer, and the PoC only cares that the request was made and logged.
Step 2: launch Firefox with a fresh profile
Extract the official Firefox archive and launch it with a newly empty profile:
CONTROL_PROFILE=$(mktemp -d /tmp/firefox-parser-image-control.XXXXXX)
test ! -e "$CONTROL_PROFILE/user.js"
timeout --signal=INT --kill-after=15s 180s \
/path/to/firefox/firefox \
--headless --no-remote --profile "$CONTROL_PROFILE" \
http://[redacted]:8000/poc.html
test ! -e "$CONTROL_PROFILE/user.js"
Line by line:
CONTROL_PROFILE=$(mktemp -d /tmp/firefox-parser-image-control.XXXXXX)creates a brand-new empty temporary directory and stores its path in a variable calledCONTROL_PROFILE.mktemp -dmakes the directory; theXXXXXXis replaced with random characters so the name is unique.test ! -e "$CONTROL_PROFILE/user.js"checks that nouser.jsfile exists in that directory. The!means "not", and-emeans "exists". This is a guard: it proves the profile really is untouched.timeout --signal=INT --kill-after=15s 180sruns the next command with a time limit of 180 seconds. If it is still running, it first sends an interrupt signal, and if it still has not stopped 15 seconds later, it kills it. This stops a hung browser from blocking the test./path/to/firefox/firefoxis the browser executable; the path is a placeholder for wherever the archive was extracted.--headlessruns without showing a window.--no-remotestops this launch from handing the URL to an already running Firefox.--profile "$CONTROL_PROFILE"uses the fresh temporary profile.http://[redacted]:8000/poc.htmlis the page to open, served by the Python server from step 1.- The final
test ! -e ...repeats the check afterwards, so the run is shown to have left nouser.jsbehind.
The two test lines check that no user.js exists before and after the run.
Step 3: keep a local minidump
For a local minidump, add only Firefox's crash-retention variables to the command. They do not change web features, preferences or sandboxing:
MOZ_CRASHREPORTER=1 \
MOZ_CRASHREPORTER_NO_REPORT=1 \
MOZ_CRASHREPORTER_SHUTDOWN=1 \
/path/to/firefox/firefox --headless --no-remote \
--profile "$CONTROL_PROFILE" http://[redacted]:8000/poc.html
Line by line:
MOZ_CRASHREPORTER=1switches on Firefox's crash reporter, the component that writes the minidump.MOZ_CRASHREPORTER_NO_REPORT=1stops it from sending the report to Mozilla's servers, so the dump stays on the local machine.MOZ_CRASHREPORTER_SHUTDOWN=1makes sure the dump is finished and saved when the browser shuts down.- The backslashes at the end of the lines join them into one command.
- The rest is the same Firefox launch as before, with the same fresh profile and the same page.
Step 4: read the stage log
A successful run records these stages before the content-process crash:
armed cycleAbortShape=1 adopted=1
oldForm-collection-check oldFormAlive=0
forms-sprayed sprayedForms=32768
exact-form-aba replacementIndex=46 (index may vary)
replacement-collection-check replacementAlive=0
count-seeder-armed
seeder-collection-check seederAlive=0
controlled-layout-armed textPaths=256 animatedStringsVerified=256
firstAnimCodeUnits=[redacted]:...
What each line means:
armed cycleAbortShape=1 adopted=1: the page has set up the shape that triggers the parser abort, and the element has been adopted (moved) as planned.oldForm-collection-check oldFormAlive=0: the original form has been collected;Alive=0means it is gone.forms-sprayed sprayedForms=32768: 32,768 replacement forms were created to fill memory.exact-form-aba replacementIndex=46 (index may vary): one of those forms reused the freed address; the index says which one, and it can differ between runs. "ABA" is the classic name for a slot being reused by a new object that looks like the old one.replacement-collection-check replacementAlive=0: that identified replacement form has now also been collected.count-seeder-armed: the seeder object has been placed in the isolated hole.seeder-collection-check seederAlive=0: the seeder has been freed, leaving the chosen bytes behind.controlled-layout-armed textPaths=256 animatedStringsVerified=256: 256 text-path objects were created and their animated strings checked.firstAnimCodeUnits=[redacted]:...: the first characters of the animated string are the code units4141,4141,4141,0000. A code unit is one unit of text in the browser's internal UTF-16 encoding;4141is the hexadecimal representation of the letter A.
unexpected-trigger-return must not appear. That message would mean the trigger returned normally instead of crashing, which would show the setup failed. Collection timing may vary on a heavily loaded host; if a bounded collection check reports an error, repeat with a fresh browser process.
Step 5: the crash
The final attached page reproduced on the official Release in both a headless run and a normal-window run. Each used a new empty profile and produced:
Crash reason: SIGSEGV / SEGV_MAPERR
Crash address: 0x0000414141414141
Thread 0 Isolated Web Co (crashed)
rip = 0x0000414141414141
rax = 0x000072fb378ae588 # page-controlled animated-string buffer
r14 = 0x000072fb3fd171c0 # stale form table / overlapping string field
Line by line:
Crash reason: SIGSEGV / SEGV_MAPERR: the processor raised a segmentation fault, meaning the program touched memory it is not allowed to touch.SEGV_MAPERRis the specific kind: the address is not mapped to any memory at all.Crash address: 0x0000414141414141: the address that caused the fault, the row of A's the page chose.Thread 0 Isolated Web Co (crashed): the crash happened in the isolated process that handles web content.rip = 0x0000414141414141: the instruction pointer held exactly the chosen value, so the processor tried to execute code at that address.rax = 0x000072fb378ae588: a register holding the address of the page-controlled animated-string buffer, the memory the page filled with its own text.r14 = 0x000072fb3fd171c0: a register holding the stale form table address, which now overlaps the string field.
Mozilla's matching Release Breakpad symbols resolve the controlled transfer:
PLDHashTable::ComputeKeyHash PLDHashTable.cpp:439
PLDHashTable::Search PLDHashTable.cpp:460
HTMLFormElement::RemoveElementFromTableInternal
HTMLFormElement.cpp:1323
HTMLFormElement::RemoveImageElementFromTable HTMLFormElement.cpp:1879
HTMLImageElement::BeforeSetAttr HTMLImageElement.cpp:249
Element::UnsetAttr Element.cpp:4262
Element::RemoveAttribute Element.cpp:1828
This is a call stack, read from top to bottom as "who called whom". The crash happened inside PLDHashTable::ComputeKeyHash, which was called by PLDHashTable::Search, which was reached from HTMLFormElement::RemoveElementFromTableInternal, then HTMLFormElement::RemoveImageElementFromTable, then HTMLImageElement::BeforeSetAttr, then Element::UnsetAttr, and finally Element::RemoveAttribute. The file and line numbers show exactly where in the source each step sits. In plain words: removing an attribute on the image led the browser into the freed form's hash table, and the lookup called the corrupted function pointer.
The selected value is derived directly from the first UTF-16 code units [redacted], whose little-endian first qword is 0x0000414141414141. A qword is eight bytes, the size of a pointer on 64-bit systems. Little-endian is the byte order where the least significant byte comes first; here the bytes spell out the A's and then zeros, giving the address. The minidump's RIP equals that qword exactly.
A temporary address-only diagnostic build separately correlated the entire reuse sequence at one native address: original form allocation and free, replacement form allocation and free, seeder allocation and free, and SVGTextPathElement allocation at the same address, with its animated-string data pointer at the stale table field. Those diagnostics were removed, the affected source files were verified clean, and the clean rebuild reproduced the same selected RIP.
Root cause: two mistakes that combine
The mistake is in the parser's abort handling. After SetFormElement() has installed the form in the image's weak raw mForm pointer, the parser aborts the insertion because it would create a DOM cycle. The abort neither clears the image's form pointer nor performs the reciprocal registration that would let the form destructor clear it. HTMLImageElement::mForm therefore outlives its HTMLFormElement.
The second half of the problem is what a stale pointer can reach. A later attribute mutation on the image, here removeAttribute("id"), walks into the freed form's PLDHashTable through HTMLFormElement::RemoveElementFromTableInternal. PLDHashTable::Search() calls mOps->hashKey before any resize or other dependent access, so the first thing it does with the stale table is an indirect call through the mOps pointer. If the freed slot has been reused by an object whose layout places attacker-influenced bytes over mOps, the call target is page-controlled.
The PoC makes that reuse deterministic rather than allocator-dependent. The SVGFESpecularLightingElement seeder writes nonzero bytes at the stale table's mEntryCount offset through its first SVGAnimatedString data pointer, and the SVGTextPathElement then places a pointer to a page-controlled string buffer over mOps while leaving those count bytes untouched. The first eight bytes of the page string become the function pointer.
Impact: why this is more than a crash
This is a drive-by, web-reachable use-after-free in a site content process with a demonstrated page-controlled indirect call target. "Drive-by" means simply visiting a page is enough; nothing needs to be clicked or installed. The attacker controls the object lifetime, isolates the exact freed slot, controls the replacement object, controls the string whose first qword becomes the function pointer, and chooses when the indirect call occurs. The official optimized Release reaches the exact selected RIP reliably under default web-feature configuration.
The researcher states that this evidence supports content-process code-execution impact rather than a denial-of-service-only classification. Code execution means running the attacker's own instructions; denial of service means merely crashing the browser. The attached proof deliberately chooses an unmapped marker and stops at the controlled transfer; it does not execute a payload. The proof stops at the controlled transfer and does not execute a payload.
Fix: what should change
The report states what the fix should be rather than what was changed. If parser insertion is aborted after SetFormElement(), every parser-installed form association must be cleared before the element can escape to script. Alternatively, the parser must defer the association until insertion succeeds. HTMLImageElement::mForm must never outlive its HTMLFormElement, and a stale image attribute mutation must never dispatch through bytes belonging to a different DOM object. In coat-check terms: either cross the number out before refusing the coat, or do not write the number until the coat is safely on the rack.
Variants to test: where else to look
- Other parser-aborted insertions that call a setter before the abort. Look for any element type whose parser path installs a back-pointer and then bails out on a cycle check. A positive result is a stage log showing the element escaping to script with a live pointer to an object that is later collected.
- Other weak back-pointers from DOM elements to containers. Any member that is set before a reciprocal registration and not cleared on abort is a candidate. A positive result is a stale pointer that survives a collection check (
...Alive=0) while the referring element is still reachable. - Other
PLDHashTableconsumers reached from attribute mutation. The removal path here reachesmOps->hashKeybefore any resize. A positive result is a crash whose RIP equals a qword taken from a page-controlled string, with the caller symbolized inPLDHashTable::Search(). - Other same-size replacement pairs for slot isolation. The PoC relies on both native replacement types being
0x160bytes on optimized x86-64. A positive result is the address-only diagnostic correlating allocation and free of the original object, the replacement, the seeder and the final object at one native address. - Different controlled marker values. The PoC uses the unmapped value
0x0000414141414141. A positive result is a minidump whose crash address and RIP both equal the chosen qword.
Glossary
- API: a defined way for one piece of software to ask another to do something, like a menu of allowed requests.
- ASan (AddressSanitizer): a debugging tool that detects invalid memory access such as use-after-free.
- Breakpad: Mozilla's crash-reporting system that turns minidumps into readable function names.
- BuildID: an identifier Mozilla stamps on each build, based on its build time.
- Callback: a function handed to another part of the program to be called later.
- Code unit: one unit of text in UTF-16, the encoding browsers use internally for strings.
- Content process: the sandboxed process in which Firefox renders web pages, separate from the rest of the browser.
- Control-flow primitive: a bug that lets an attacker influence which code the processor executes next.
- Custom element: a page-defined HTML tag written in JavaScript.
- Customized built-in: a custom element that extends an existing tag such as
<img>. - Cycle collection: the browser's cleanup of groups of objects that reference each other and would otherwise never be freed.
- DOM (Document Object Model): the browser's internal tree of the things on a page.
- DOM adoption: moving an existing element from one parent to another.
- DOM cycle: a tree structure that would contain itself, which the browser refuses to build.
- Drive-by: an attack that works just by visiting a page, with no user action.
- Free: to give a chunk of memory back so it can be reused.
- Garbage collection: automatic cleanup of objects nothing can reach any more.
- Getter: a property that runs code when it is read.
- Hash table: a lookup structure that stores items in numbered slots for fast retrieval.
- Headless: running a browser without a visible window.
- Heap: the general-purpose pool of memory used for objects that come and go.
- Indirect call: a jump to an address stored in memory rather than written into the program.
- JSON: a simple text format for structured data.
- Little-endian: byte order where the least significant byte comes first.
- Marionette: Firefox's remote-control interface used for automated testing.
- Minidump: a small snapshot of a crashed program saved for analysis.
- Nightly: Mozilla's experimental pre-release Firefox channel.
- Optimized build: a build compiled for speed rather than easy debugging, which changes memory layout.
- Parser: the part of the browser that reads page text and builds the DOM.
- Pointer: a number that says where something lives in memory.
- Profile: the folder where Firefox keeps settings, history and add-ons.
- Qword: eight bytes, the size of a pointer on 64-bit systems.
- RIP: the processor register holding the address of the instruction being executed.
- Sandbox: an operating-system feature that limits what a process may touch.
- Seeding: writing chosen bytes into a memory slot so a later structure looks the way the attacker wants.
- Segmentation fault (SIGSEGV): the error raised when a program touches memory it is not allowed to.
- SEGV_MAPERR: the specific segmentation fault meaning the address is not mapped to any memory.
- SMIL: the part of SVG that animates shapes over time.
- SourceStamp: an identifier for the exact source code revision a build came from.
- Spraying: creating many same-size objects so one lands in a chosen freed slot.
- SVG: a way to draw shapes using text markup.
- Thread: one sequence of instructions running inside a process.
- Use-after-free (UAF): using memory through a pointer after that memory has been freed.
- UTF-16: a text encoding that represents characters as 16-bit units.
- Weak pointer: a pointer that does not keep its target alive.
- WeakRef: a JavaScript feature that references an object without preventing its cleanup.
- Xvfb: a virtual display server that provides a fake screen on machines without a monitor.