Memory corruption in V8 (CVE-2026-87489)
The DeoptimizeFunction call uses the default code argument, which is not the executing OSR code, so the OSR code is not marked for deoptimization. When the debugger resumes, the OSR code continues with stale values, leading to a use-after-free or out-of-bounds access if heap state changed during the pause.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 44 days
Note: this issue was posted via CodeMind.
Experimental -- AI-generated report, not reviewed by a human. Filed automatically by airc. An AI agent reviewed the commit and wrote the reproduction below; an orchestrator then re-ran it and observed the failure, so the reproduction is machine-verified. The analysis is model-written and unverified -- treat it as a lead, not a conclusion. Please reassign, downgrade, or close this freely if it is wrong; no justification needed.
Pre-existing defect: reproduces but was NOT introduced by v8@73b4712d0fac (it reproduces on the parent tree too).
Defect. The DeoptimizeFunction call uses the default code argument, which evaluates to function->code(isolate). For OSR-optimized frames, this is not the code object currently executing. Consequently, the actual executing OSR code is not marked for deoptimization, and DeoptimizeMarkedCode skips it. When the debugger resumes, the OSR code continues executing with stale load-eliminated values, leading to a Use-After-Free or Out-Of-Bounds access if heap state was modified during the pause.
Wrote a test that triggers OSR inside a loop, pauses execution via the inspector, and alters array length. It asserts that the OSR code is deoptimized, successfully failing with an un-deoptimized OSR frame.
Reproduction (test/mjsunit/compiler/regress-osr-debug.js).
diff --git a/test/mjsunit/compiler/regress-osr-debug.js b/test/mjsunit/compiler/regress-osr-debug.js
new file mode 100644
index 00000000000..bc5063c093d
--- /dev/null
+++ b/test/mjsunit/compiler/regress-osr-debug.js
@@ -0,0 +1,49 @@
+// Copyright 2026 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --enable-inspector --turbofan
+
+let msgId = 1;
+function cmd(method, params) {
+ return JSON.stringify({id: msgId++, method: method, params: params || {}});
+}
+
+let arr = [1.1, 2.2, 3.3];
+
+let armModify = false;
+
+globalThis.handleInspectorMessage = function() {
+ if (armModify) {
+ arr.length = 1;
+ }
+ send(cmd("Debugger.resume"));
+};
+
+send(cmd("Debugger.enable"));
+const PAUSE = cmd("Debugger.pause");
+
+function hot(arr) {
+ let val;
+ for (let i = 0; i < 20; i++) {
+ if (i === 10) {
+ %OptimizeOsr();
+ }
+ if (i === 15) {
+ armModify = true;
+ send(PAUSE);
+ }
+ if (i > 15) {
+ // If deoptimized, arr[2] is undefined because arr.length was set to 1.
+ // If not deoptimized, arr[2] might be 3.3 because the bounds check is eliminated.
+ val = arr[2];
+ }
+ }
+ return val;
+}
+
+%PrepareFunctionForOptimization(hot);
+let result = hot(arr);
+if (result !== undefined) {
+ throw new Error("Result is " + result + " instead of undefined. OSR frame was not deoptimized!");
+}
Verification. Verified: yes, but PRE-EXISTING -- it fails on the parent commit too, so this commit did not introduce it.
command: out/x64.optdebug/d8 --allow-natives-syntax --enable-inspector --turbofan test/mjsunit/compiler/regress-osr-debug.js
expected: nonzero exit (crash/abort), output matching /OSR frame was not deoptimized!/
actual: exit 1, signature matched
control: on 73b4712d0fac^: exit 1, signature matched -- fails there too (pre-existing)
output (tail):
test/mjsunit/compiler/regress-osr-debug.js:48: Error: Result is 3.3 instead of undefined. OSR frame was not deoptimized!
throw new Error("Result is " + result + " instead of undefined. OSR frame was not deoptimized!");
^
Error: Result is 3.3 instead of undefined. OSR frame was not deoptimized!
at test/mjsunit/compiler/regress-osr-debug.js:48:9
Reviewer evidence. In src/debug/debug.cc:2914, Deoptimizer::DeoptimizeFunction is called with only two arguments. In src/deoptimizer/deoptimizer.cc, this falls back to function->code(isolate). ActivationsFinder::VisitThread checks if it.frame()->GcSafeLookupCode() is marked for deoptimization. Since the OSR code on the stack differs from function->code(isolate), it remains unmarked and is not replaced with a deoptimization trampoline.
filed by airc for v8-73b4712d0fac-src-debug-debug-cc-2914
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 DeoptimizeFunction call uses the default code argument (function->code(isolate)) instead of the currently executing OSR code, so the OSR code is not marked for deoptimization.
Impact
Could lead to a use-after-free or out-of-bounds access if heap state was modified during the pause.
What the attacker needed
Debugger pauses execution; OSR-optimized frame is active; heap state modified during pause
How it was found
- Enable the inspector and set up a loop that triggers OSR optimisation.
- Pause execution via the inspector while the OSR code is running.
- Modify the array length during the pause.
- Resume execution and observe that the OSR code was not deoptimized, returning a stale value.
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.
When a JavaScript engine optimises a loop while it is running, it creates a special version of the code called OSR code. If a debugger pauses the program and changes something like an array's length, the engine should throw away that optimised code so it does not use old assumptions. Here, the engine forgot to throw away the OSR code, so after resuming it could read memory that is no longer valid.
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.