Out of bounds write in V8 (CVE-2026-14395)
The V8 Irregexp peephole optimizer fails to track jump offsets for kOffsetAfterSequence, so they become stale when preceding bytecodes are shrunk. During JIT tier-up, these stale offsets cause an out-of-bounds write that can zero out jump_targets_ data and lead to wild branches, potentially enabling control flow hijacking and RCE in the renderer.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 54 days
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports without the Chrome Security team. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: V8's Irregexp peephole optimizer fails to track jump offsets for kOffsetAfterSequence, causing them to become stale if preceding bytecodes are shrunk in subsequent optimization passes. During native JIT tier-up, these stale offsets trigger an out-of-bounds write in CodeGenerator::PreVisitBytecodes, which can zero out jump_targets_ data and lead to wild branches.
Affected files:
v8/src/regexp/regexp-code-generator.ccv8/src/regexp/regexp-bytecode-peephole.ccv8/src/regexp/regexp-bytecode-generator.ccv8/src/regexp/regexp-bytecode-generator-inl.h
Estimated timestamp from git blame: 2026-01-08
Root Cause
V8's Irregexp peephole optimizer (v8/src/regexp/regexp-bytecode-peephole.cc) applies templates to shorten bytecodes in a fixpoint loop until no changes occur. For certain optimizations (e.g., B::kSkipUntilOneOfMasked3 and B::kSkipUntilOneOfMasked), the jump target is calculated using EmitOffsetAfterSequence(), which records a kOffsetAfterSequence mapping type.
When emitting the optimization, EmitOptimization writes the target as an absolute PC offset via dst_writer_->OverwriteValue<uint32_t>(pc(), offset). Crucially, unlike standard jump targets handled via EmitArgument(), this raw write bypasses the jump_edges_ map in the BytecodeWriter, which is responsible for tracking all jump targets so they can be adjusted if bytecodes are moved.
The Trigger
If a subsequent pass in the peephole optimizer's fixpoint loop matches a template that shrinks a bytecode sequence located before the SkipUntilOneOfMasked instruction (e.g., replacing a 2-byte sequence with a 1-byte sequence), all following bytecodes shift to lower PC offsets.
When the code is copied to the new buffer via EmitRawBytecodeStream, standard jump edges are adjusted. However, because the kOffsetAfterSequence offset was not added to jump_edges_, it is copied verbatim and becomes stale. Because preceding code was shrunk, this absolute offset now points beyond the final length of the shortened bytecode array.
Potential Impact
To execute RegExps efficiently, V8 tiers up to native JIT compilation after a certain number of executions. The tier-up process instantiates a CodeGenerator (v8/src/regexp/regexp-code-generator.cc).
The CodeGenerator constructor allocates an array of Label objects and a BitVector for jump targets sequentially in a deterministic bump-pointer Zone heap. Due to alignment and the 8-byte size of Label, the start of the jump_targets_ internal data array immediately follows the end of the labels_ array in memory.
CodeGenerator::PreVisitBytecodes extracts jump target offsets from the bytecode to initialize labels:
uint32_t offset = Operands::template Get<operand>(pc, no_gc);
if (!jump_targets_.Contains(offset)) {
jump_targets_.Add(offset);
...
Label* label = &labels_[offset];
new (label) Label();
}
There are no release-build bounds checks on offset. When the stale offset (which is >= ulength) is processed, jump_targets_.Add(offset) performs an out-of-bounds bitwise write, and new (&labels_[offset]) Label() performs an out-of-bounds placement-new.
Because labels_ and jump_targets_ are adjacent in the Zone, &labels_[offset] points directly into the bit storage of jump_targets_. The Label constructor initializes its fields to 0, effectively zeroing out 8 bytes (64 bits) of jump_targets_.
This can erase the bits marking legitimate forward jump targets for other bytecodes. Later, during CodeGenerator::VisitBytecodes(), the compiler will check jump_targets_.Contains(iter_.current_offset()), see a 0, and skip binding the label (__ Bind(&labels_[iter_.current_offset()])).
Consequently, forward branches to that unbound label will remain unresolved. The JIT compiler emits them with intermediate relative link-chain displacements, creating wild branches in the generated machine code. When the RegExp is executed, these wild branches cause the CPU to jump to unintended instructions, allowing a potential attacker to achieve deterministic control flow hijacking and Remote Code Execution (RCE) in the renderer process.
(Note: These are suggested steps based on source code analysis; a working Proof of Concept has not been run.)
Suggested Fix
- Modify
BytecodePeepholeOptimizationto ensure that offsets generated byEmitOffsetAfterSequenceare properly added to thejump_edges_tracking map so they are adjusted during subsequent shrinking passes. - Add release-build bounds checks in
CodeGenerator::PreVisitBytecodes(e.g.,CHECK_LT(offset, bytecode_->ulength().value())) to harden the JIT compiler against corrupted bytecode and prevent out-of-bounds memory accesses.
Evaluated with Chrome root at commit: eca8648a4e1cdfdda68c495a6003059fed641955
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
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 peephole optimizer writes an absolute offset for kOffsetAfterSequence without registering it in jump_edges_, so later shrinking passes do not adjust it, leaving a stale offset that exceeds the bytecode length.
Impact
A stale offset could cause an out-of-bounds write that zeroes jump_targets_ bits, leading to wild branches and potentially deterministic control flow hijacking and RCE in the renderer process; however, no working proof of concept has been run.
What the attacker needed
Ability to run JavaScript in Chrome; RegExp executed enough times to trigger JIT
The fix
The peephole optimizer should add offsets from EmitOffsetAfterSequence to jump_edges_ so they are adjusted during shrinking, and release-build bounds checks should be added in CodeGenerator::PreVisitBytecodes.
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.
V8 is the JavaScript engine in Chrome. When a regular expression runs many times, V8 compiles it to machine code for speed. A bug in an optimisation step leaves a jump address pointing past the end of the bytecode, and when the compiler uses that address it writes outside an array, corrupting data that controls where jumps go. This could let an attacker take over the program.
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.