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

Heap buffer overflow in WebML (CVE-2026-8509)

The TFLite STRIDED_SLICE kernel computes output dimensions using float32 arithmetic, which loses precision for values above 2^24, while WebNN validation uses exact integer arithmetic. A web page can exploit this discrepancy via the WebNN slice() API to cause a heap buffer overflow in the GPU process.

c6eed09fc8b174b0f3eebedcceb1e792 Follow

Originally disclosed on Chrome VRP

Bounty$43,000 Critical View original
  • Fix shipped in 57 days

Heap buffer overflow in TFLite StridedSlice via WebNN slice() due to float32 precision loss in output shape computation

Summary

The TFLite STRIDED_SLICE kernel computes output tensor dimensions using float32 arithmetic, which silently loses precision for dimension values exceeding 2^24. The WebNN validation layer computes the same dimensions using exact integer arithmetic, so the graph passes validation while TFLite allocates a smaller output buffer than the data actually written during evaluation. A web page can exploit this discrepancy to trigger a heap buffer overflow in the GPU process through the WebNN slice() API. Affected platforms: Linux, Windows, macOS, ChromeOS (any platform where WebNN uses the TFLite backend).

Bisect

Introducing Commit: 6dfe00ca4114

  • Date: 2018-01-23
  • Author: A. Unique TensorFlower
  • Review: PiperOrigin-RevId: 183020501

This commit added the STRIDED_SLICE kernel to TFLite with the float32 division in ResizeOutputTensor. The bug became web-reachable when Chrome integrated WebNN with the TFLite backend and translated MLGraphBuilder.slice() into the TFLite STRIDED_SLICE op.

Root Cause

When TFLite prepares a STRIDED_SLICE operation, ResizeOutputTensor computes the output dimension along each axis by dividing the slice extent by the stride using float32:

C++
// third_party/tflite/src/tensorflow/lite/kernels/strided_slice.cc
int32_t begin = ::tflite::strided_slice::StridedSliceStartForAxis(
    op_params, effective_input_shape, idx);
int32_t end = ::tflite::strided_slice::StridedSliceEndForAxis(
    op_params, effective_input_shape, idx, begin);

dim_shape = std::ceil((end - begin) / static_cast<float>(stride));

IEEE 754 single-precision floats have a 24-bit significand, so integers above 2^24 (16,777,216) cannot all be represented exactly. When end - begin equals 16,777,217 and stride equals 1, the cast static_cast<float>(stride) produces 1.0f, but the implicit promotion of dim_shape (16,777,217) to float rounds it down to 16,777,216.0f. The std::ceil call has no effect since the value is already integral after rounding. The output tensor is therefore allocated with 16,777,216 elements along that axis instead of 16,777,217.

The reference implementation of StridedSlice does not consult the output shape at all, as the code itself documents:

C++
// third_party/tflite/src/tensorflow/lite/kernels/internal/reference/strided_slice.h
// Note that the output_shape is not used herein.

Instead, it recomputes begin and end from the original integer parameters and iterates over the true range. When the innermost stride is 1, it issues a single memcpy of stop - start elements per outer iteration through SequentialTensorWriter::WriteN:

C++
// third_party/tflite/src/tensorflow/lite/kernels/internal/portable_tensor.h
void WriteN(int position, int len) {
    memcpy(output_ptr_, &input_data_[position], sizeof(T) * len);
    output_ptr_ += len;
}

This writes the correct number of elements into a buffer that is too small.

Chromium's WebNN service translates MLGraphBuilder.slice() into TFLite's STRIDED_SLICE. The WebNN validation layer in ValidateSliceAndInferOutput computes the output shape using exact integer ceiling division:

C++
// services/webnn/public/cpp/graph_validation_utils.cc
uint32_t output_size = attributes.sizes[i] / attributes.strides[i] +
                       (attributes.sizes[i] % attributes.strides[i] != 0);

This produces the correct value of 16,777,217, so the operation passes validation. After TFLite builds the model, a post-build check in GraphImplTflite compares each output tensor's byte count against the WebNN-expected size. However, this check only inspects the graph's final output tensors, not intermediate tensors. By chaining two slice operations, where the first produces the oversized intermediate tensor and the second extracts a small sub-tensor as the graph output, the mismatch on the intermediate tensor goes undetected and the graph builds successfully. When the graph is dispatched, the first slice writes past the end of its allocated arena buffer, corrupting adjacent memory in the GPU process.

Reproduce

Tested at commit 7c89d33808e55 on Linux x86_64. No source modifications required.

Build configuration (out/asan-release/args.gn):

is_asan = true
is_debug = false
dcheck_always_on = false
target_cpu = "x64"
is_component_build = true

Build:

autoninja -C out/asan-release chrome

Serve the PoC and launch Chrome:

python3 -m http.server 8888 &
ASAN_OPTIONS=detect_odr_violation=0 out/asan-release/chrome \
  --no-sandbox \
  --enable-features=WebMachineLearningNeuralNetwork \
  --user-data-dir=/tmp/poc-$(date +%s) \
  http://localhost:8888/poc.html

The GPU process crashes within a few seconds of page load with a heap-buffer-overflow in __asan_memcpy, called from tflite::reference_ops::StridedSlice<unsigned char>.

=================================================================
==1307355==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7b76f54a68c0 at pc 0x55d111bdcbae bp 0x7b7709aabcf0 sp 0x7b7709aab4b0
WRITE of size 65 at 0x7b76f54a68c0 thread T42 (ThreadPoolForeg)
    #0 0x55d111bdcbad in __asan_memcpy
    #1 0x7f775650a73e in void tflite::reference_ops::StridedSlice<unsigned char>(...) third_party/tflite/src/tensorflow/lite/kernels/internal/portable_tensor.h:130:5
    #2 0x7f7756504ed7 in tflite::ops::builtin::strided_slice::EvalImpl<...>(...) third_party/tflite/src/tensorflow/lite/kernels/internal/reference/strided_slice.h:140:3
    #3 0x7f77565056f9 in tflite::ops::builtin::strided_slice::Eval<...>(...) third_party/tflite/src/tensorflow/lite/kernels/strided_slice.cc:370:10
    #4 0x7f7755f62094 in tflite::Subgraph::InvokeImpl() third_party/tflite/src/tensorflow/lite/core/subgraph.cc
    #5 0x7f7755f6112e in tflite::Subgraph::Invoke() third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1653:17
    #6 0x7f7755f3f6b4 in tflite::impl::Interpreter::Invoke() third_party/tflite/src/tensorflow/lite/core/interpreter.cc:247:48
    #7 0x7f77554ea7bd in webnn::tflite::GraphImplTflite::ComputeResources::DoDispatch(...) services/webnn/tflite/graph_impl_tflite.cc:328:41

0x7b76f54a68c0 is located 0 bytes after 2181038272-byte region [0x7b76734a6800,0x7b76f54a68c0)
allocated by thread T42 (ThreadPoolForeg) here:
    #0 0x55d111bdf772 in aligned_alloc
    #1 0x7f7755f9e814 in tflite::SimpleMemoryArena::Commit(bool*) third_party/tflite/src/tensorflow/lite/simple_memory_arena.cc:111:31
    #2 0x7f7755f14ec8 in tflite::ArenaPlanner::ExecuteAllocations(int, int) third_party/tflite/src/tensorflow/lite/arena_planner.cc:433:32
    #3 0x7f7755f5d87c in tflite::Subgraph::PrepareOpsAndTensors() third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1604:42
    #4 0x7f7755f5beba in tflite::Subgraph::AllocateTensors(...) third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1035:25
    #5 0x7f77554d8722 in webnn::tflite::GraphImplTflite::ComputeResources::Create(...) services/webnn/tflite/graph_impl_tflite.cc:221:34

SUMMARY: AddressSanitizer: heap-buffer-overflow in __asan_memcpy

Full ASAN log is attached as asan.log.

Credit

Please use c6eed09fc8b174b0f3eebedcceb1e792 as the credit for this vulnerability. Thank you.

The original report as published on the Chromium issue tracker, by c6eed09fc8b174b0f3eebedcceb1e792. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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. 9 min read.

Context

This report describes a heap buffer overflow in the TFLite STRIDED_SLICE kernel that becomes reachable from the web through the WebNN slice() API in Chrome. The affected asset is WebML, and the affected platforms are Linux, Windows, macOS and ChromeOS, in other words any platform where WebNN uses the TFLite backend.

WebNN is the browser API that lets a web page describe machine learning graphs. MLGraphBuilder.slice() is the operation that extracts a sub-tensor from an input tensor along each axis, using a size and a stride per axis. Chrome's WebNN service translates that operation into the TFLite STRIDED_SLICE op and evaluates the graph in the GPU process.

The platform records the report as filed through the Chrome VRP, credited to [redacted], rated critical, with a bounty of 43,000.00 USD. The platform facts give the title as "Heap buffer overflow in WebML (CVE-2026-8509)" and the disclosure date as 2026-05-12. The original report itself does not state a CVE number, a CVSS score or a fix.

Setup

The researcher tested at commit 7c89d33808e55 on Linux x86_64 and states that no source modifications were required. The build configuration was written to out/asan-release/args.gn:

Text
is_asan = true
is_debug = false
dcheck_always_on = false
target_cpu = "x64"
is_component_build = true

The build command was:

Bash
autoninja -C out/asan-release chrome

The proof of concept is a single page, poc.html, served from the local machine with Python's http.server. Chrome is launched with the WebNN feature flag enabled, with the sandbox disabled for the test, and with a fresh user data directory per run:

Bash
python3 -m http.server 8888 &
ASAN_OPTIONS=detect_odr_violation=0 out/asan-release/chrome \
  --no-sandbox \
  --enable-features=WebMachineLearningNeuralNetwork \
  --user-data-dir=/tmp/poc-$(date +%s) \
  http://localhost:8888/poc.html

The report does not include the contents of poc.html, so the exact JavaScript that builds the graph is not shown. What the report does describe is the shape of the graph: two chained slice operations, where the first produces an oversized intermediate tensor and the second extracts a small sub-tensor as the graph output.

Finding it

The researcher traced the problem to a difference in arithmetic between two layers that both compute the same output dimensions.

TFLite's ResizeOutputTensor computes the output dimension along each axis by dividing the slice extent by the stride using float32. The WebNN validation layer, in ValidateSliceAndInferOutput, computes the same dimensions using exact integer arithmetic. For dimension values above 2^24 the two disagree: the graph passes WebNN validation, but TFLite allocates a smaller output buffer than the data actually written during evaluation.

The bug became web-reachable when Chrome integrated WebNN with the TFLite backend and translated MLGraphBuilder.slice() into the TFLite STRIDED_SLICE op. The introducing commit is given as 6dfe00ca4114, dated 2018-01-23, authored by A. Unique TensorFlower, with review PiperOrigin-RevId: 183020501. That commit added the STRIDED_SLICE kernel to TFLite with the float32 division in ResizeOutputTensor.

Exploitation

Step 1: Understand the float32 rounding in TFLite

When TFLite prepares a STRIDED_SLICE operation, ResizeOutputTensor computes the output dimension along each axis like this:

C++
// third_party/tflite/src/tensorflow/lite/kernels/strided_slice.cc
int32_t begin = ::tflite::strided_slice::StridedSliceStartForAxis(
    op_params, effective_input_shape, idx);
int32_t end = ::tflite::strided_slice::StridedSliceEndForAxis(
    op_params, effective_input_shape, idx, begin);

dim_shape = std::ceil((end - begin) / static_cast<float>(stride));

IEEE 754 single-precision floats have a 24-bit significand, so integers above 2^24 (16,777,216) cannot all be represented exactly. When end - begin equals 16,777,217 and stride equals 1, the cast static_cast<float>(stride) produces 1.0f, but the implicit promotion of dim_shape (16,777,217) to float rounds it down to 16,777,216.0f. The std::ceil call has no effect since the value is already integral after rounding. The output tensor is therefore allocated with 16,777,216 elements along that axis instead of 16,777,217.

Step 2: Note that the reference implementation ignores the output shape

The reference implementation of StridedSlice does not consult the output shape at all, as the code itself documents:

C++
// third_party/tflite/src/tensorflow/lite/kernels/internal/reference/strided_slice.h
// Note that the output_shape is not used herein.

Instead, it recomputes begin and end from the original integer parameters and iterates over the true range. When the innermost stride is 1, it issues a single memcpy of stop - start elements per outer iteration through SequentialTensorWriter::WriteN:

C++
// third_party/tflite/src/tensorflow/lite/kernels/internal/portable_tensor.h
void WriteN(int position, int len) {
    memcpy(output_ptr_, &input_data_[position], sizeof(T) * len);
    output_ptr_ += len;
}

This writes the correct number of elements into a buffer that is too small.

Step 3: Confirm that WebNN validation uses exact integer arithmetic

Chromium's WebNN service translates MLGraphBuilder.slice() into TFLite's STRIDED_SLICE. The WebNN validation layer in ValidateSliceAndInferOutput computes the output shape using exact integer ceiling division:

C++
// services/webnn/public/cpp/graph_validation_utils.cc
uint32_t output_size = attributes.sizes[i] / attributes.strides[i] +
                       (attributes.sizes[i] % attributes.strides[i] != 0);

This produces the correct value of 16,777,217, so the operation passes validation.

Step 4: Bypass the post-build size check with a second slice

After TFLite builds the model, a post-build check in GraphImplTflite compares each output tensor's byte count against the WebNN-expected size. However, this check only inspects the graph's final output tensors, not intermediate tensors. By chaining two slice operations, where the first produces the oversized intermediate tensor and the second extracts a small sub-tensor as the graph output, the mismatch on the intermediate tensor goes undetected and the graph builds successfully.

Step 5: Dispatch the graph and observe the overflow

When the graph is dispatched, the first slice writes past the end of its allocated arena buffer, corrupting adjacent memory in the GPU process. The GPU process crashes within a few seconds of page load with a heap-buffer-overflow in __asan_memcpy, called from tflite::reference_ops::StridedSlice<unsigned char>:

Text
=================================================================
==1307355==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7b76f54a68c0 at pc 0x55d111bdcbae bp 0x7b7709aabcf0 sp 0x7b7709aab4b0
WRITE of size 65 at 0x7b76f54a68c0 thread T42 (ThreadPoolForeg)
    #0 0x55d111bdcbad in __asan_memcpy
    #1 0x7f775650a73e in void tflite::reference_ops::StridedSlice<unsigned char>(...) third_party/tflite/src/tensorflow/lite/kernels/internal/portable_tensor.h:130:5
    #2 0x7f7756504ed7 in tflite::ops::builtin::strided_slice::EvalImpl<...>(...) third_party/tflite/src/tensorflow/lite/kernels/internal/reference/strided_slice.h:140:3
    #3 0x7f77565056f9 in tflite::ops::builtin::strided_slice::Eval<...>(...) third_party/tflite/src/tensorflow/lite/kernels/strided_slice.cc:370:10
    #4 0x7f7755f62094 in tflite::Subgraph::InvokeImpl() third_party/tflite/src/tensorflow/lite/core/subgraph.cc
    #5 0x7f7755f6112e in tflite::Subgraph::Invoke() third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1653:17
    #6 0x7f7755f3f6b4 in tflite::impl::Interpreter::Invoke() third_party/tflite/src/tensorflow/lite/core/interpreter.cc:247:48
    #7 0x7f77554ea7bd in webnn::tflite::GraphImplTflite::ComputeResources::DoDispatch(...) services/webnn/tflite/graph_impl_tflite.cc:328:41

0x7b76f54a68c0 is located 0 bytes after 2181038272-byte region [0x7b76734a6800,0x7b76f54a68c0)
allocated by thread T42 (ThreadPoolForeg) here:
    #0 0x55d111bdf772 in aligned_alloc
    #1 0x7f7755f9e814 in tflite::SimpleMemoryArena::Commit(bool*) third_party/tflite/src/tensorflow/lite/simple_memory_arena.cc:111:31
    #2 0x7f7755f14ec8 in tflite::ArenaPlanner::ExecuteAllocations(int, int) third_party/tflite/src/tensorflow/lite/arena_planner.cc:433:32
    #3 0x7f7755f5d87c in tflite::Subgraph::PrepareOpsAndTensors() third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1604:42
    #4 0x7f7755f5beba in tflite::Subgraph::AllocateTensors(...) third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1035:25
    #5 0x7f77554d8722 in webnn::tflite::GraphImplTflite::ComputeResources::Create(...) services/webnn/tflite/graph_impl_tflite.cc:221:34

SUMMARY: AddressSanitizer: heap-buffer-overflow in __asan_memcpy

The report states that the full ASAN log is attached as asan.log, but the attachment is not reproduced in the text. The trace shows the write happening in the reference StridedSlice implementation, reached through Subgraph::Invoke and Interpreter::Invoke from GraphImplTflite::ComputeResources::DoDispatch, and the buffer being allocated by SimpleMemoryArena::Commit during AllocateTensors.

Root cause

The mistake is an arithmetic mismatch between two components that must agree on tensor sizes. TFLite computes the output extent of a strided slice in float32, which cannot represent every integer above 2^24 exactly, so a slice extent of 16,777,217 with stride 1 is rounded down to 16,777,216 and the output tensor is allocated one element short. The reference kernel does not use the computed output shape; it recomputes the true range from the integer parameters and copies that many elements, so it writes past the end of the allocation.

WebNN's own validation uses exact integer ceiling division and therefore accepts the operation. The only remaining guard described in the report is the post-build byte count check in GraphImplTflite, and it only covers the graph's final output tensors. Chaining a second slice that returns a small sub-tensor as the graph output leaves the oversized intermediate tensor unchecked, so the graph builds and dispatches.

The report does not say whether any other defence, such as a size limit on tensors or a check inside the TFLite kernel, was present or considered.

Impact

A web page can trigger a heap buffer overflow in the GPU process through the WebNN slice() API. The overflow is a write past the end of an arena buffer, corrupting adjacent memory in the GPU process. The report demonstrates this as a crash under AddressSanitizer; it does not demonstrate control flow hijack or any other outcome beyond the memory corruption and the crash. The conditions are that WebNN is available and using the TFLite backend, and that the page can build a graph with a slice extent of 16,777,217 and stride 1, chained with a second slice so that the mismatch is not caught by the post-build check.

Fix

The original report does not describe a fix, a patch or a changed commit. It only identifies the float32 division in ResizeOutputTensor as the source of the wrong allocation size and the final-output-only scope of the GraphImplTflite check as the reason the mismatch survives. The report identifies the float32 division in ResizeOutputTensor and the final-output-only scope of the GraphImplTflite check as the causes, but does not state what should change. The report does not state which of these was implemented.

Variants to test

  1. Other TFLite kernels that compute output shapes with float arithmetic. A positive result is a kernel whose allocated output size differs from the size the reference implementation writes, visible as an ASAN heap-buffer-overflow or as a size mismatch in a debug build.
  2. Other WebNN operations translated to TFLite ops with shape inference, such as reshape, transpose or pooling. A positive result is a graph that passes WebNN validation but whose TFLite tensor allocation is smaller than the data written at dispatch.
  3. Dimension values just above 2^24 with different strides. A positive result is a rounded allocation combined with a reference path that copies the exact range, producing a write past the allocation.
  4. Chained operations where the oversized tensor is intermediate rather than final. A positive result is a graph that builds despite a size mismatch on an intermediate tensor, showing the post-build check only covers final outputs.
  5. Other backends that consume the same WebNN graph description. A positive result is the same validation-versus-execution disagreement on a backend other than TFLite.

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. 23 min read.

What happened, in plain words

A security researcher found a way for an ordinary web page to crash part of the Chrome browser, and to write past the end of a reserved block of memory, just by loading that page. The page uses a browser feature called WebNN, which lets websites ask the browser to run machine learning calculations. Chrome hands those calculations to a library called TFLite, which is Google's engine for running small machine learning models.

The problem is a disagreement about arithmetic. Two parts of the system calculate how big a result should be, and for very large numbers they get slightly different answers. One part uses a fast but slightly imprecise kind of number (called float32), and the other uses exact whole numbers. The exact one says the result needs 16,777,217 items. The imprecise one rounds that down to 16,777,216. So the system reserves space for one item fewer than it then writes into. Writing one item past the end of reserved space is called a heap buffer overflow, and it is a classic memory safety bug: it can crash the program, and in the worst case it can let an attacker influence what the program does next.

The researcher demonstrated this with a test page that makes the GPU process (the part of Chrome that handles graphics and some heavy computation) crash within a few seconds. The report was filed through Google's Chrome Vulnerability Reward Program (VRP), the scheme that pays people for finding and reporting security bugs. The platform records a bounty of 43,000.00 USD, a severity of critical, and a disclosure date of 2026-05-12. The original report itself does not mention a CVE number, a CVSS score or a fix; the CVE number in the title comes from the platform's records.

This beginner's version walks through the same material as the technical write-up, in the same order, explaining every term from scratch.

Context

This section sets the scene: what the product is, what the feature is, and who is affected.

The product and the feature. Chrome is a web browser. WebNN ("Web Neural Network") is a browser API. An API is a defined set of commands that one piece of software offers to another; think of it as a restaurant menu: the menu lists what you can order and how to order it, without telling you what happens in the kitchen. WebNN's menu lets a web page describe a machine learning graph. A graph here means a recipe of calculations: take this data, apply this operation, feed the result into that operation. The browser then runs the recipe, often on special hardware such as a graphics card.

One item on that menu is MLGraphBuilder.slice(). A slice takes a big block of data (called a tensor, which is just a grid of numbers) and cuts out a smaller piece of it, a bit like cutting a rectangular slice out of a large sheet cake. You tell it how big a piece to take and how far to step between the items you keep; that step is called the stride. A stride of 1 means "take every item". A stride of 2 means "take every second item".

The engine underneath. Chrome does not implement every machine learning operation itself. It translates the web page's recipe into operations understood by TFLite, a library from the TensorFlow project for running models on small devices. The specific TFLite operation used here is called STRIDED_SLICE. Chrome runs this work in the GPU process, a separate process from the page itself. Processes are isolated from each other by the operating system, which is one of the browser's main defences: if one process crashes, the rest of the browser can survive.

Who is affected. The report lists Linux, Windows, macOS and ChromeOS, in other words any platform where WebNN uses the TFLite backend. A backend is the underlying implementation that actually does the work; think of it as the kitchen behind the menu.

The report's metadata. The report was filed through the Chrome VRP and credited to [redacted], which is a pseudonymous identifier rather than a person's name. The platform facts give the title as "Heap buffer overflow in WebML (CVE-2026-8509)" and the disclosure date as 2026-05-12. The original report itself does not state a CVE number, a CVSS score or a fix.

Setup

This section describes how the researcher prepared a test environment. The point of a setup like this is to make the bug easy to see and to reproduce: a special build of Chrome that notices memory errors, a simple web server on the same machine, and a test page.

The build configuration. The researcher tested at commit 7c89d33808e55 on Linux x86_64. A commit is a saved snapshot of a code repository, identified by a long string of letters and digits; it is like a version number that points at one exact state of the source code. x86_64 is the common 64-bit processor family used in most desktop computers. The build configuration was written to a file called out/asan-release/args.gn:

Text
is_asan = true
is_debug = false
dcheck_always_on = false
target_cpu = "x64"
is_component_build = true

Line by line:

  1. is_asan = true turns on AddressSanitizer. AddressSanitizer, usually shortened to ASAN, is a tool built into the program that watches memory accesses. When the program reads or writes outside the memory it reserved, ASAN stops it and prints a detailed report. It is like putting a thin electric fence around every block of reserved memory: touching the fence sets off an alarm.
  2. is_debug = false builds an optimised, non-debug version. Debug builds contain extra checks and run slowly; the researcher wants behaviour close to what real users get.
  3. dcheck_always_on = false turns off a class of internal consistency checks (called DCHECKs) that would otherwise slow things down or fire in situations that are not the bug being studied.
  4. target_cpu = "x64" says to build for 64-bit x86 processors.
  5. is_component_build = true builds Chrome as many separate shared libraries rather than one huge program. This makes builds faster, which matters when you are iterating on a test.

The build command.

Bash
autoninja -C out/asan-release chrome

Line by line:

  1. autoninja is a build tool that reads the configuration and runs the compiler. It is a wrapper around Ninja, a fast build system.
  2. -C out/asan-release tells it to work in the directory out/asan-release, which is where the configuration above was written. The name is a convention: "out" for build output, "asan" for AddressSanitizer, "release" for an optimised build.
  3. chrome is the target to build, meaning the browser executable.

Serving the test page and launching Chrome. The proof of concept is a single page, poc.html, served over plain HTTP from the local machine. "Proof of concept" means a minimal demonstration that the bug is real, not a polished attack. Serving it from the local machine means the page is loaded from localhost, the computer itself, rather than from the internet.

Bash
python3 -m http.server 8888 &
ASAN_OPTIONS=detect_odr_violation=0 out/asan-release/chrome \
  --no-sandbox \
  --enable-features=WebMachineLearningNeuralNetwork \
  --user-data-dir=/tmp/poc-$(date +%s) \
  http://localhost:8888/poc.html

Line by line:

  1. python3 -m http.server 8888 & starts a tiny web server using Python's built-in http.server module, listening on port 8888. A port is a numbered door on a computer that a particular service listens at; port 8888 is a common choice for ad hoc testing. The trailing & puts the server in the background so the next command can run in the same terminal.
  2. ASAN_OPTIONS=detect_odr_violation=0 sets an environment variable that configures AddressSanitizer. An environment variable is a named setting passed to a program when it starts. Here it disables one particular ASAN check (ODR violation detection) that can produce noise in component builds; it does not affect the bug being studied.
  3. out/asan-release/chrome is the browser executable that was just built.
  4. --no-sandbox disables Chrome's sandbox for this test. The sandbox is a security mechanism that restricts what a process is allowed to do, so that a compromised process cannot easily harm the rest of the system. The report does not explain why the sandbox was disabled for this test.
  5. --enable-features=WebMachineLearningNeuralNetwork turns on the WebNN feature, which may be behind a flag (a switch that enables experimental features) in the build being tested.
  6. --user-data-dir=/tmp/poc-$(date +%s) gives Chrome a fresh profile directory each run. The $(date +%s) part inserts the current time in seconds, so every run gets a unique folder. This avoids leftover state from previous runs affecting the result.
  7. http://localhost:8888/poc.html is the page to open: the test page served by the Python server.

The report does not include the contents of poc.html, so the exact JavaScript that builds the graph is not shown. What the report does describe is the shape of the graph: two chained slice operations, where the first produces an oversized intermediate tensor and the second extracts a small sub-tensor as the graph output. "Chained" means the output of one operation is fed into the next. "Intermediate" means a value produced inside the graph but not handed back to the page; the "graph output" is the final result the page receives.

Finding it

The researcher traced the problem to a difference in arithmetic between two layers that both compute the same output dimensions. This is the heart of the bug: two components that must agree on a number, using two different methods to calculate it.

TFLite's ResizeOutputTensor computes the output dimension along each axis by dividing the slice extent by the stride using float32. Float32 is a way of storing numbers in 32 bits, the same format used by many programming languages for "single precision" decimals. It is fast and compact, but it cannot represent every whole number exactly once the numbers get large. The WebNN validation layer, in ValidateSliceAndInferOutput, computes the same dimensions using exact integer arithmetic. Validation means checking a request before doing the work, like a bouncer checking ID at the door. For dimension values above 2^24 the two disagree: the graph passes WebNN validation, but TFLite allocates a smaller output buffer than the data actually written during evaluation. A buffer is a reserved block of memory; allocating it means asking the operating system for that block.

2^24 is 16,777,216. Why that number? Float32 stores a number as a sign, an exponent and a fraction. The significand has 24 bits of precision, so integers above 2^24 cannot all be represented exactly. Above that, some whole numbers have no exact representation and get rounded to the nearest one that does. It is like a ruler whose markings stop being fine enough for very large measurements, so some whole numbers have to be rounded to the nearest one it can show.

The bug became web-reachable when Chrome integrated WebNN with the TFLite backend and translated MLGraphBuilder.slice() into the TFLite STRIDED_SLICE op. "Web-reachable" means a web page can trigger it, which turns a library bug into a browser security issue. The introducing commit is given as 6dfe00ca4114, dated 2018-01-23, authored by A. Unique TensorFlower, with review PiperOrigin-RevId: 183020501. That commit added the STRIDED_SLICE kernel to TFLite with the float32 division in ResizeOutputTensor. A kernel here means the piece of code that performs one operation. The commit is from 2018; the report says the bug became web-reachable when Chrome integrated WebNN with the TFLite backend.

Exploitation

This section walks through the five steps the researcher used to understand and trigger the bug. "Exploitation" here means turning the bug into an observable effect, in this case a crash.

Step 1: Understand the float32 rounding in TFLite

When TFLite prepares a STRIDED_SLICE operation, ResizeOutputTensor computes the output dimension along each axis like this:

C++
// third_party/tflite/src/tensorflow/lite/kernels/strided_slice.cc
int32_t begin = ::tflite::strided_slice::StridedSliceStartForAxis(
    op_params, effective_input_shape, idx);
int32_t end = ::tflite::strided_slice::StridedSliceEndForAxis(
    op_params, effective_input_shape, idx, begin);

dim_shape = std::ceil((end - begin) / static_cast<float>(stride));

Line by line:

  1. The first line is a comment giving the file path, so a reader can find the code in the source tree.
  2. int32_t begin = ... declares a whole number called begin, of type int32_t (a 32-bit signed integer), and sets it to the result of StridedSliceStartForAxis. That function works out where the slice starts on the axis being processed. op_params holds the operation's parameters, effective_input_shape is the shape of the input data, and idx is which axis (dimension) is being handled.
  3. int32_t end = ... does the same for where the slice ends, passing begin because the end may depend on the start.
  4. dim_shape = std::ceil((end - begin) / static_cast<float>(stride)); is the key line. end - begin is how many items the slice covers. static_cast<float>(stride) converts the stride to a float32. The division is therefore done in float32, not in exact integers. std::ceil rounds up to the next whole number, which is the correct way to compute how many items fit when you step by stride. The result is stored in dim_shape, the computed output dimension.

IEEE 754 single-precision floats have a 24-bit significand, so integers above 2^24 (16,777,216) cannot all be represented exactly. The significand is the part of a floating point number that holds its significant digits. When end - begin equals 16,777,217 and stride equals 1, the cast static_cast<float>(stride) produces 1.0f, but the implicit promotion of dim_shape (16,777,217) to float rounds it down to 16,777,216.0f. "Implicit promotion" means the language automatically converts a value to float because the other side of the division is a float. The std::ceil call has no effect since the value is already integral after rounding. The output tensor is therefore allocated with 16,777,216 elements along that axis instead of 16,777,217. One element too few.

Step 2: Note that the reference implementation ignores the output shape

The reference implementation of StridedSlice does not consult the output shape at all, as the code itself documents:

C++
// third_party/tflite/src/tensorflow/lite/kernels/internal/reference/strided_slice.h
// Note that the output_shape is not used herein.

Line by line:

  1. The first line is a comment with the file path.
  2. The second line is a comment saying, in plain words, that the output shape is not used in this code. A "reference implementation" is a simple, obviously correct version of an operation, used as the standard that optimised versions must match. Here it means the code that actually copies the data does not look at the possibly-wrong size that was computed earlier.

Instead, it recomputes begin and end from the original integer parameters and iterates over the true range. When the innermost stride is 1, it issues a single memcpy of stop - start elements per outer iteration through SequentialTensorWriter::WriteN:

C++
// third_party/tflite/src/tensorflow/lite/kernels/internal/portable_tensor.h
void WriteN(int position, int len) {
    memcpy(output_ptr_, &input_data_[position], sizeof(T) * len);
    output_ptr_ += len;
}

Line by line:

  1. void WriteN(int position, int len) { defines a function called WriteN that takes a starting position and a length, and returns nothing (void).
  2. memcpy(output_ptr_, &input_data_[position], sizeof(T) * len); copies len items from the input data into the output buffer. memcpy is a standard C library function that copies a block of bytes from one place in memory to another; it does no bounds checking, which is why it is fast and why it is dangerous when the size is wrong. output_ptr_ points at where to write, &input_data_[position] points at where to read from, and sizeof(T) * len is the number of bytes to copy (sizeof(T) is the size of one element, len the number of elements).
  3. output_ptr_ += len; moves the write pointer forward by len elements, so the next call writes after this one.
  4. } closes the function.

This writes the correct number of elements into a buffer that is too small. The copy function trusts the length it is given; it does not know that the buffer was reserved with one element fewer.

Step 3: Confirm that WebNN validation uses exact integer arithmetic

Chromium's WebNN service translates MLGraphBuilder.slice() into TFLite's STRIDED_SLICE. The WebNN validation layer in ValidateSliceAndInferOutput computes the output shape using exact integer ceiling division:

C++
// services/webnn/public/cpp/graph_validation_utils.cc
uint32_t output_size = attributes.sizes[i] / attributes.strides[i] +
                       (attributes.sizes[i] % attributes.strides[i] != 0);

Line by line:

  1. uint32_t output_size = ... declares an unsigned 32-bit integer to hold the computed output size.
  2. attributes.sizes[i] / attributes.strides[i] is integer division: how many whole strides fit into the size. Integer division throws away any remainder, so this is a rounded-down count.
  3. (attributes.sizes[i] % attributes.strides[i] != 0) adds 1 if there is a remainder. % is the modulo operator, which gives the remainder of a division. The expression != 0 is true (1) when the remainder is not zero, and false (0) otherwise. Adding 1 when there is a remainder is exactly how you round up in integer arithmetic.

This produces the correct value of 16,777,217, so the operation passes validation. The bouncer checks the ID with exact arithmetic and lets the request through, unaware that the kitchen will use a different, lossy method.

Step 4: Bypass the post-build size check with a second slice

After TFLite builds the model, a post-build check in GraphImplTflite compares each output tensor's byte count against the WebNN-expected size. A post-build check is a sanity check run after the model has been assembled, like a final inspection before a product ships. However, this check only inspects the graph's final output tensors, not intermediate tensors. By chaining two slice operations, where the first produces the oversized intermediate tensor and the second extracts a small sub-tensor as the graph output, the mismatch on the intermediate tensor goes undetected and the graph builds successfully. The second slice returns a small sub-tensor as the graph output, so the check on final outputs passes while the oversized intermediate tensor goes unchecked.

Step 5: Dispatch the graph and observe the overflow

When the graph is dispatched, the first slice writes past the end of its allocated arena buffer, corrupting adjacent memory in the GPU process. "Dispatching" means actually running the graph. An arena is a single large block of memory that a program carves up into smaller pieces for efficiency; an arena buffer is one of those pieces. Writing past its end means the extra data lands in memory that belongs to something else, which is the corruption. The GPU process crashes within a few seconds of page load with a heap-buffer-overflow in __asan_memcpy, called from tflite::reference_ops::StridedSlice<unsigned char>:

Text
=================================================================
==1307355==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7b76f54a68c0 at pc 0x55d111bdcbae bp 0x7b7709aabcf0 sp 0x7b7709aab4b0
WRITE of size 65 at 0x7b76f54a68c0 thread T42 (ThreadPoolForeg)
    #0 0x55d111bdcbad in __asan_memcpy
    #1 0x7f775650a73e in void tflite::reference_ops::StridedSlice<unsigned char>(...) third_party/tflite/src/tensorflow/lite/kernels/internal/portable_tensor.h:130:5
    #2 0x7f7756504ed7 in tflite::ops::builtin::strided_slice::EvalImpl<...>(...) third_party/tflite/src/tensorflow/lite/kernels/internal/reference/strided_slice.h:140:3
    #3 0x7f77565056f9 in tflite::ops::builtin::strided_slice::Eval<...>(...) third_party/tflite/src/tensorflow/lite/kernels/strided_slice.cc:370:10
    #4 0x7f7755f62094 in tflite::Subgraph::InvokeImpl() third_party/tflite/src/tensorflow/lite/core/subgraph.cc
    #5 0x7f7755f6112e in tflite::Subgraph::Invoke() third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1653:17
    #6 0x7f7755f3f6b4 in tflite::impl::Interpreter::Invoke() third_party/tflite/src/tensorflow/lite/core/interpreter.cc:247:48
    #7 0x7f77554ea7bd in webnn::tflite::GraphImplTflite::ComputeResources::DoDispatch(...) services/webnn/tflite/graph_impl_tflite.cc:328:41

0x7b76f54a68c0 is located 0 bytes after 2181038272-byte region [0x7b76734a6800,0x7b76f54a68c0)
allocated by thread T42 (ThreadPoolForeg) here:
    #0 0x55d111bdf772 in aligned_alloc
    #1 0x7f7755f9e814 in tflite::SimpleMemoryArena::Commit(bool*) third_party/tflite/src/tensorflow/lite/simple_memory_arena.cc:111:31
    #2 0x7f7755f14ec8 in tflite::ArenaPlanner::ExecuteAllocations(int, int) third_party/tflite/src/tensorflow/lite/arena_planner.cc:433:32
    #3 0x7f7755f5d87c in tflite::Subgraph::PrepareOpsAndTensors() third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1604:42
    #4 0x7f7755f5beba in tflite::Subgraph::AllocateTensors(...) third_party/tflite/src/tensorflow/lite/core/subgraph.cc:1035:25
    #5 0x7f77554d8722 in webnn::tflite::GraphImplTflite::ComputeResources::Create(...) services/webnn/tflite/graph_impl_tflite.cc:221:34

SUMMARY: AddressSanitizer: heap-buffer-overflow in __asan_memcpy

Line by line:

  1. The line of equals signs is a visual separator printed by ASAN.
  2. ==1307355==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7b76f54a68c0 ... is the headline. 1307355 is the process ID, a number the operating system gives each running program. The address is the memory location where the bad access happened. pc, bp and sp are processor registers: the program counter (where the code is executing), the base pointer and the stack pointer. They are diagnostic details for developers.
  3. WRITE of size 65 at 0x7b76f54a68c0 thread T42 (ThreadPoolForeg) says the program tried to write 65 bytes to that address, on a worker thread named ThreadPoolForeg (a thread from a pool of background workers). A thread is a unit of execution inside a process; a thread pool is a set of reusable workers.
  4. The numbered lines starting with #0, #1 and so on are the call stack: the chain of function calls that led to the error, with #0 being the innermost. #0 is __asan_memcpy, the ASAN-instrumented version of the memory copy function. #1 is the reference StridedSlice implementation in portable_tensor.h. #2 and #3 are the TFLite strided slice evaluation code. #4 to #6 are TFLite's subgraph and interpreter machinery. #7 is Chrome's WebNN TFLite graph dispatch code. Reading from bottom to top tells the story: Chrome asked TFLite to run the graph, TFLite ran the slice, the slice called memcpy, and memcpy wrote out of bounds.
  5. 0x7b76f54a68c0 is located 0 bytes after 2181038272-byte region [0x7b76734a6800,0x7b76f54a68c0) describes the reserved block: it started at one address and ended at another, and the bad write landed exactly at the first byte after its end. The size is given in bytes.
  6. The second stack, under allocated by thread T42 ... here:, shows where that block was reserved. #0 is aligned_alloc, the standard function that reserves memory with a requested alignment. #1 is SimpleMemoryArena::Commit, which hands out memory from the arena. #2 is the arena planner. #3 and #4 are TFLite's tensor allocation steps. #5 is Chrome's WebNN graph creation. So the block was reserved during graph setup, and the overflow happened later during dispatch.
  7. SUMMARY: AddressSanitizer: heap-buffer-overflow in __asan_memcpy is ASAN's one-line conclusion.

The report states that the full ASAN log is attached as asan.log, but the attachment is not reproduced in the text. The trace shows the write happening in the reference StridedSlice implementation, reached through Subgraph::Invoke and Interpreter::Invoke from GraphImplTflite::ComputeResources::DoDispatch, and the buffer being allocated by SimpleMemoryArena::Commit during AllocateTensors.

Root cause

The mistake is an arithmetic mismatch between two components that must agree on tensor sizes. TFLite computes the output extent of a strided slice in float32, which cannot represent every integer above 2^24 exactly, so a slice extent of 16,777,217 with stride 1 is rounded down to 16,777,216 and the output tensor is allocated one element short. The reference kernel does not use the computed output shape; it recomputes the true range from the integer parameters and copies that many elements, so it writes past the end of the allocation.

WebNN's own validation uses exact integer ceiling division and therefore accepts the operation. The only remaining guard described in the report is the post-build byte count check in GraphImplTflite, and it only covers the graph's final output tensors. Chaining a second slice that returns a small sub-tensor as the graph output leaves the oversized intermediate tensor unchecked, so the graph builds and dispatches.

The report does not say whether any other defence, such as a size limit on tensors or a check inside the TFLite kernel, was present or considered.

Impact

A web page can trigger a heap buffer overflow in the GPU process through the WebNN slice() API. The overflow is a write past the end of an arena buffer, corrupting adjacent memory in the GPU process. The report demonstrates this as a crash under AddressSanitizer; it does not demonstrate control flow hijack or any other outcome beyond the memory corruption and the crash. "Control flow hijack" means making the program execute attacker-chosen code instead of its own; that is the worst-case consequence of memory corruption, but it is not shown here. The conditions are that WebNN is available and using the TFLite backend, and that the page can build a graph with a slice whose extent exceeds 2^24 with a stride that triggers the rounding, chained with a second slice so that the mismatch is not caught by the post-build check.

Fix

The original report does not describe a fix, a patch or a changed commit. It only identifies the float32 division in ResizeOutputTensor as the source of the wrong allocation size and the final-output-only scope of the GraphImplTflite check as the reason the mismatch survives. What should change, based on the report's own analysis, is that the output dimension computation should use exact integer arithmetic rather than float32, and the post-build size check should cover intermediate tensors as well as final outputs.

Variants to test

These are follow-up ideas: other places where the same kind of mistake might exist. For each, the report describes what a positive result would look like.

  1. Other TFLite kernels that compute output shapes with float arithmetic. A positive result is a kernel whose allocated output size differs from the size the reference implementation writes, visible as an ASAN heap-buffer-overflow or as a size mismatch in a debug build.
  2. Other WebNN operations translated to TFLite ops with shape inference, such as reshape, transpose or pooling. Shape inference means working out the size of the result from the size of the input. A positive result is a graph that passes WebNN validation but whose TFLite tensor allocation is smaller than the data written at dispatch.
  3. Dimension values just above 2^24 with different strides. A positive result is a rounded allocation combined with a reference path that copies the exact range, producing a write past the allocation.
  4. Chained operations where the oversized tensor is intermediate rather than final. A positive result is a graph that builds despite a size mismatch on an intermediate tensor, showing the post-build check only covers final outputs.
  5. Other backends that consume the same WebNN graph description. A positive result is the same validation-versus-execution disagreement on a backend other than TFLite.

Glossary

  • API: a defined set of commands one piece of software offers to another, like a menu of allowed requests.
  • AddressSanitizer (ASAN): a tool built into a program that detects out-of-bounds memory accesses and prints a detailed report.
  • Arena: a single large block of memory that a program divides into smaller pieces for efficiency.
  • Backend: the underlying implementation that actually performs a task, such as TFLite for WebNN.
  • Buffer: a reserved block of memory used to hold data.
  • Build configuration: a file of settings that controls how a program is compiled.
  • Call stack: the chain of function calls that led to a particular point in a program.
  • Commit: a saved snapshot of a code repository, identified by a unique string.
  • Control flow hijack: making a program run attacker-chosen code instead of its own; the worst-case result of memory corruption.
  • CVE: a public identifier for a known security vulnerability.
  • CVSS: a scoring system for rating the severity of vulnerabilities.
  • DCHECK: an internal consistency check in Chromium, usually enabled only in debug builds.
  • Dispatch: actually running a prepared graph of operations.
  • Environment variable: a named setting passed to a program when it starts.
  • Float32: a 32-bit floating point number format with about 24 bits of precision, unable to represent every integer above 2^24 exactly.
  • GPU process: the separate browser process that handles graphics and some heavy computation.
  • Graph: a recipe of calculations, where the output of one operation feeds into the next.
  • Heap buffer overflow: writing past the end of a block of reserved memory, corrupting adjacent memory.
  • HTTP: the protocol browsers use to fetch web pages.
  • Integer arithmetic: arithmetic on whole numbers, which is exact within its range.
  • Intermediate tensor: a value produced inside a graph but not returned to the caller.
  • Kernel: the piece of code that performs one operation in a machine learning library.
  • localhost: the name for the computer itself, used when a program talks to a service on the same machine.
  • memcpy: a standard C function that copies a block of bytes from one memory location to another without bounds checking.
  • MLGraphBuilder.slice(): the WebNN API operation that extracts a sub-tensor from an input tensor.
  • Port: a numbered door on a computer where a service listens.
  • Post-build check: a sanity check run after a model has been assembled.
  • Process: a running program with its own isolated memory.
  • Proof of concept (PoC): a minimal demonstration that a bug is real.
  • Reference implementation: a simple, obviously correct version of an operation used as the standard for others to match.
  • Sandbox: a security mechanism that restricts what a process is allowed to do.
  • Severity: a rating of how serious a vulnerability is.
  • Shape inference: working out the size of a result from the size of the input.
  • Slice: an operation that cuts a smaller piece out of a larger block of data.
  • Stride: the step size between items when taking a slice; a stride of 1 takes every item.
  • STRIDED_SLICE: the TFLite operation that performs a slice with a stride.
  • Tensor: a grid of numbers, the basic data unit in machine learning.
  • TFLite: Google's library for running machine learning models on small devices.
  • Thread: a unit of execution inside a process.
  • Thread pool: a set of reusable worker threads.
  • Validation: checking a request before doing the work, like a bouncer checking ID.
  • WebNN: the browser API that lets web pages describe machine learning graphs.
  • Web-reachable: able to be triggered by a web page.
  • x86_64: the common 64-bit processor family used in most desktop computers.

More by c6eed09fc8b174b0f3eebedcceb1e792

View all

52 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.