Skip to content
Memory corruption Advisory Advanced CVE-2026-11136

Use after free in Canvas (CVE-2026-11136)

A use-after-free occurs in CanvasRenderingContext2D::drawFocusIfNeeded when the canvas size is invalid, causing the cached path to be freed while still referenced. An attacker could trigger renderer memory corruption by visiting a malicious web page.

Jungwoo Lee Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 53 days

Report description

CanvasRenderingContext2D::drawFocusIfNeeded dangling Path use-after-free


Bug location

Where do you want to report your vulnerability?

Chrome VRP – Report security issues affecting the Chrome browser. See program rules

Which URL (or repository) have you found the vulnerability in?

https://chromium.googlesource.com/chromium/src


The problem

Please describe the technical details of the vulnerability

The problem

Summary

CanvasRenderingContext2D::drawFocusIfNeeded(Element*) passes the current canvas path into DrawFocusIfNeededInternal() by const Path&. If DrawFocusRing() loses the 2D context because the canvas size is invalid, the cached current path is destroyed before DrawFocusIfNeededInternal() returns. The same stale reference is then used by UpdateElementAccessibility(path, element).

In the tested trigger, the freed object is the SkPathData behind the cached current path. The ASAN report shows the first invalid access as WRITE of size 4 to the freed region.

Chrome Version

The crash was reproduced on a downloadable Chromium 149 ASAN build on Linux x86_64. The downloaded ASAN package was requested with --version 149.0.7779.3, and the extracted browser used for the run reported Chromium 149.0.7779.0. I also checked the corresponding Chromium 149 source tree, including Skia, to verify the code path shown below.

Root Cause

The vulnerable path starts here in third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc:

C++
void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element) {
  DrawFocusIfNeededInternal(GetPath(), element);
}

void CanvasRenderingContext2D::DrawFocusIfNeededInternal(const Path& path,
                                                         Element* element) {
  if (!FocusRingCallIsValid(path, element))
    return;

  if (element->GetDocument().FocusedElement() == element) {
    ScrollPathIntoViewInternal(path);
    DrawFocusRing(path, element);
  }

  UpdateElementAccessibility(path, element);
}

GetPath() returns a reference backed by PathBuilder::CurrentPath(). The cached object is stored in mutable std::optional<Path> current_path_.

The same call then reaches the context-loss path:

C++
void CanvasRenderingContext2D::DrawFocusRing(const Path& path,
                                             Element* element) {
  if (!GetOrCreatePaintCanvas())
    return;

  ...
}

CanvasResourceProvider*
CanvasRenderingContext2D::GetOrCreateResourceProvider() {
  ...

  if (!canvas()->IsValidImageSize()) {
    did_fail_to_create_resource_provider_ = true;
    if (!canvas()->Size().IsEmpty()) {
      LoseContext(CanvasRenderingContext::kInvalidCanvasSize);
    }
    return nullptr;
  }

  ...
}

LoseContext() clears the cached path through the normal reset path:

C++
void CanvasRenderingContext2D::LoseContext(LostContextMode lost_mode) {
  if (context_lost_mode_ != kNotLostContext)
    return;
  context_lost_mode_ = lost_mode;
  ResetInternal();
  ...
}
C++
void Canvas2DRecorderContext::ResetInternal() {
  ...
  CanvasPath::Clear();
  ...
}

void Clear() {
  line_builder_.Clear();
  arc_builder_.Clear();
  path_builder_.Reset();
}

void PathBuilder::ClearCachedData() {
  current_path_.reset();
  current_bounds_.reset();
}

Execution then continues in the same stack frame and reuses the stale reference:

C++
void CanvasRenderingContext2D::UpdateElementAccessibility(const Path& path,
                                                          Element* element) {
  ...
  AXObjectCache* ax_object_cache =
      element->GetDocument().ExistingAXObjectCache();
  if (!ax_object_cache) {
    return;
  }
  ax_object_cache->UpdateAXForAllDocuments();

  const AffineTransform& transform = GetState().GetTransform();
  const Path transformed_path =
      transform.IsIdentity()
          ? path
          : PathBuilder(path).Transform(transform).Finalize();

  PhysicalRect element_rect =
      PhysicalRect::EnclosingRect(transformed_path.BoundingRect());
  ...
}

In the attached PoC, transform.IsIdentity() is true. The dangling path is copied into transformed_path, BoundingRect() is called, and the temporary is then destroyed. The observed ASAN WRITE of size 4 matches the sk_sp<SkPathData> copy path incrementing the freed reference count.

Trigger Sequence

The trigger uses only standard web APIs.

  1. Create a <canvas> and get a 2D rendering context.
  2. Resize the canvas to 20000 x 20000.
  3. Build a non-empty current path with beginPath() and rect().
  4. Focus a descendant fallback element inside the canvas.
  5. Call ctx.drawFocusIfNeeded(btn).

The trigger does not call drawing or transform APIs after the resize. Calls such as fillRect(), stroke(), isPointInPath(), scale(), rotate(), or setTransform() would reach GetOrCreatePaintCanvas() before drawFocusIfNeeded() and would lose the context too early.

Reproduction

Test Builds

The following public builds were used for this report.

  1. ASAN build used for the crash reproduction:
Text
Downloaded with get_asan_chrome.py --version 149.0.7779.3
Executed browser version: Chromium 149.0.7779.0
Linux x86_64
  1. Release build used as a public Chrome 149 reference binary:
Text
Google Chrome for Testing 149.0.7784.0, Linux x86_64

How the test environment was prepared

The ASAN build can be downloaded with Chromium's helper script:

Bash
python3 chromium-149/tools/get_asan_chrome/get_asan_chrome.py \
  --version 149.0.7779.3 \
  --os linux \
  --download_directory /home/qwerty/chrome-agent/chromium-149.0.7779.3-linux-asan-download

For the runs in this report, the extracted browser was stored at:

Text
/home/qwerty/chrome-agent/chromium-149.0.7779.3-linux-asan/chrome

The public release build can be downloaded from Chrome for Testing:

Bash
wget https://storage.googleapis.com/chrome-for-testing-public/149.0.7784.0/linux64/chrome-linux64.zip
unzip chrome-linux64.zip

For the runs in this report, the release browser was stored at:

Text
/home/qwerty/chrome-agent/chrome-linux64/chrome

The source tree used for code verification was a local Chromium 149 checkout. The Skia submodule was initialized with:

Bash
git -C chromium-149 submodule update --init --depth=1 third_party/skia

The trigger itself uses only the attached files. No external media files or additional test corpus are required.

How to Run

Place the attached files in one directory and start the ASAN run script with the downloaded browser path:

Bash
cd pocs/AUD-BLINK_MODULES-130ee005
./run.sh /home/qwerty/chrome-agent/chromium-149.0.7779.3-linux-asan/chrome

The --force-renderer-accessibility flag is required because UpdateElementAccessibility() returns early if ExistingAXObjectCache() is null.

The second attached trigger runs the same code with ASAN quarantine disabled:

Bash
cd pocs/AUD-BLINK_MODULES-130ee005
./run_bof.sh /home/qwerty/chrome-agent/chromium-149.0.7779.3-linux-asan/chrome

The same run.sh launcher was also used with the public release binary:

Bash
cd pocs/AUD-BLINK_MODULES-130ee005
./run.sh /home/qwerty/chrome-agent/chrome-linux64/chrome

Crash Logs

ASAN run with poc.html:

Text
==122148==ERROR: AddressSanitizer: heap-use-after-free on address 0x7261c71a5200
WRITE of size 4 at 0x7261c71a5200 thread T35 (Chrome_InProcRe)
...
0x7261c71a5200 is located 0 bytes inside of 173-byte region [0x7261c71a5200,0x7261c71a52ad)
...
SUMMARY: AddressSanitizer: heap-use-after-free

ASAN run with poc_bof.html and quarantine_size_mb=0:

Text
==122155==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7792f77bf060
WRITE of size 4 at 0x7792f77bf060 thread T35 (Chrome_InProcRe)
...
0x7792f77bf060 is located 72 bytes after 168-byte region [0x7792f77bef70,0x7792f77bf018)
...
SUMMARY: AddressSanitizer: heap-buffer-overflow

Public release run with poc.html:

Text
Received signal 11 SI_KERNEL000000000000
Possibly a General Protection Fault, can be due to a non-canonical address dereference.
...
r14: badbad00badbad00
bx:  badbad00badbad00

Suggested Fix

One straightforward fix is to stop passing the cached current path by reference across a call that may reset the context:

Diff
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc
index 000000000000..000000000000 100644
--- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc
+++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc
@@ -930,7 +930,8 @@ cc::Layer* CanvasRenderingContext2D::CcLayer() const {
 }
 
 void CanvasRenderingContext2D::drawFocusIfNeeded(Element* element) {
-  DrawFocusIfNeededInternal(GetPath(), element);
+  const Path path = GetPath();
+  DrawFocusIfNeededInternal(path, element);
 }
 
 void CanvasRenderingContext2D::drawFocusIfNeeded(Path2D* path2d,
                                                  Element* element) {

Impact analysis

A web page can trigger a use-after-free in the renderer process through the Canvas2D API. The issue is reachable from JavaScript and reproduces as renderer memory corruption without additional user interaction beyond visiting the page.


The cause

What version of Chrome have you found the security issue in?

149.0.7779.0, 148.0.6613.0

Is the security issue related to a crash?

Yes, it is related to a crash.

Choose the type of vulnerability

Memory Corruption (in a sandboxed process)

How would you like to be publicly acknowledged for your report?

Jungwoo Lee (@physicube) and Wongi Lee (@_qwerty_po)

The original report as published on the Chromium issue tracker, by Jungwoo Lee (@physicube) and Wongi Lee (@_qwerty_po). Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, the function passes a reference to the cached current path into a call that can reset the context and free that path, leaving a dangling reference.

Impact

A web page can trigger a use-after-free in the renderer process, leading to memory corruption without additional user interaction beyond visiting the page.

What the attacker needed

Victim visits a malicious page; renderer accessibility enabled

The fix

The fix is to copy the current path into a local variable before passing it to DrawFocusIfNeededInternal, so the reference remains valid even if the context is reset.

How it was found

  1. Create a canvas and get a 2D rendering context.
  2. Resize the canvas to 20000 x 20000.
  3. Build a non-empty current path with beginPath() and rect().
  4. Focus a descendant fallback element inside the canvas.
  5. Call ctx.drawFocusIfNeeded(btn).

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A use-after-free is a bug where a program keeps using memory after it has been freed, which can lead to crashes or worse. Here, a canvas function frees a path object but then still tries to use it, causing memory corruption in the browser's renderer process.

What is Memory corruption?

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

More by Jungwoo Lee

View all

2 more disclosed reports, best first.

More from Google Chrome

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.