Heap buffer overflow in WebML (CVE-2026-8531)
A graph optimiser in the XNNPACK library rewrites a broadcasted binary operation into a unary reduce_mean without checking that the constant's rank does not exceed the reduced tensor's rank, so the broadcasted shape is silently dropped. A later convolution reshape then treats the lower-rank tensor as four-dimensional NHWC data, producing an undersized buffer and a heap buffer overflow.
- Fix shipped in 2 months
Summary
optimize_common_subgraphs_scaled_sum_to_mean rewrites a broadcasted binary op into a unary reduce_mean without verifying that the singleton constant's rank doesn't exceed the reduced tensor's rank, silently dropping broadcasting semantics so that downstream convolution reshapes produce an undersized buffer and the heap-buffer-overflow.
Details
The WebNN trigger is straightforward: reduceSum(input, {axes:[0,1], keepDimensions:false}) produces a lower-rank tensor, and a following div or mul by a constant shaped [1,1,1,1] is still valid because Blink broadcasts the reduction result back up to rank 4. For the attached PoCs, the reduction result is logically [16,8], while the binary output seen by WebNN/TFLite is [1,1,16,8].
The rewrite in optimize_common_subgraphs_scaled_sum_to_mean treats any static one-element tensor as scalar-like and replaces the binary node with a unary reduce, but it never checks whether the binary op was relying on higher-rank broadcasting:
struct xnn_value* reduce_value = &subgraph->values[node->inputs[0]];
struct xnn_value* arg_value = &subgraph->values[node->inputs[1]];
if (xnn_shape_multiply_all_dims(&arg_value->shape) != 1 ||
!xnn_value_is_static(arg_value->allocation_type)) {
if (xnn_shape_multiply_all_dims(&reduce_value->shape) == 1 &&
xnn_value_is_static(reduce_value->allocation_type)) {
swap_value_pointers(&reduce_value, &arg_value);
} else {
return xnn_status_success;
}
}
...
XNN_RETURN_IF_ERROR(xnn_define_static_reduce_v2(
subgraph,
reduce_node_type == xnn_node_type_static_sum
? xnn_reduce_mean
: xnn_reduce_mean_squared,
num_reduction_axes, reduction_axes, input_value->id,
output_id, reduce_node->flags),
"Failed to create new `Mean` or `Mean Squared` node.");
This is the similar bug class (of issue 483445078 probably) that was fixed for minimum / maximum to clamp: optimize_common_subgraphs_min_max_to_clamp now explicitly rejects rewrites when arg_value->shape.num_dims > input_value->shape.num_dims, but scaled_sum_to_mean still lacks that guard.
Once the binary output ID has been rebound to a unary reduce node, reshape_reduce_operator recomputes the output shape solely from the reduction axes and input dimensions, so it drops the higher-rank broadcasted shape that the original binary operator exported:
size_t num_skip_axis = 0;
for (size_t input_idx = 0; input_idx < input_num_dims; ++input_idx) {
bool is_axis = false;
...
if (!is_axis) {
output_value->shape.dim[input_idx - num_skip_axis] = input_dims[input_idx];
}
}
output_value->shape.num_dims = input_num_dims - num_skip_axis;
const size_t new_size = xnn_runtime_tensor_get_size(output_value);
The spatial consumers then trust that reused value as if it were still NHWC. reshape_convolution_operator reads dim[0..2] unconditionally and forces a 4D output shape:
const size_t batch_size = values[input_id].shape.dim[0];
const size_t input_height = values[input_id].shape.dim[1];
const size_t input_width = values[input_id].shape.dim[2];
...
output_value->shape.dim[0] = batch_size;
output_value->shape.dim[1] = output_height;
output_value->shape.dim[2] = output_width;
output_value->shape.dim[3] = output_pixel_stride;
output_value->shape.num_dims = 4;
Finally, the conv/deconv reshape logic interprets that lower-rank value as 4D NHWC and cause the heap-buffer-overflow in xnn_f32_igemm_minmax_ukernel_10x8__fma3_broadcast.
Bisection
This issue is introduced by the commit https://source.chromium.org/chromium/_/chromium/external/github.com/google/XNNPACK/+/27c1929b344882a6dfb95771ef8ab662f1ad010e, which introduce the incorrect implementation of optimize_common_subgraphs_scaled_sum_to_mean function.
Reproduction
Run chrome from https://storage.googleapis.com/chromium-browser-asan/linux-release/asan-linux-release-1598914.zip with the following command:
./chrome --enable-features=ExperimentalWebMachineLearningNeuralNetwork,WebMachineLearningNeuralNetwork --no-sandbox poc.html
You would observe the heap-buffer-overflow in asan.txt
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 scaled_sum_to_mean rewrite treats any static one-element tensor as scalar-like and replaces the binary node with a unary reduce without rejecting cases where the constant's rank exceeds the reduced tensor's rank, unlike the equivalent min/max-to-clamp rewrite which has that guard.
Impact
A crafted WebNN graph could cause a heap buffer overflow in the browser's inference kernel, which may crash the renderer and, in principle, allow memory corruption.
What the attacker needed
Chrome with experimental WebNN features enabled; Victim loads an attacker-supplied page
The fix
The rewrite should reject the optimisation when the constant's rank exceeds the reduced tensor's rank, as the min/max-to-clamp rewrite already does.
How it was found
- Build a WebNN graph where reduceSum with axes [0,1] and keepDimensions false produces a lower-rank tensor.
- Follow it with a div or mul by a constant shaped [1,1,1,1] so Blink broadcasts the result back to rank 4.
- Run Chrome with the experimental WebNN features enabled and load the page.
- Observe the heap-buffer-overflow reported by ASan.
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 neural-network library tries to make a calculation faster by swapping one operation for a simpler one. It forgets to check that the shapes of the data still line up, so a later step reads more memory than was allocated and crashes or corrupts memory. This is a memory-safety bug in the browser's machine-learning code.
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.