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

Out of bounds read in V8 (CVE-2026-3926)

RegExp.escape decides whether to copy a string as one-byte or two-byte based on the string's map, but a crafted SlicedString can keep a two-byte map while its backing storage becomes one-byte after internalization. This causes an out-of-bounds read when the string is copied as UC16 from one-byte storage.

qymag1c Follow

Originally disclosed on Chrome VRP

Bounty$7,000 Medium View original
  • Fix shipped in 44 days

#VULNERABILITY DETAILS RegExp.escape determines whether to copy the input as one-byte or two-byte based on the string's map (String::IsOneByteRepresentation). A crafted SlicedString can keep a two-byte map while its underlying storage becomes one-byte after internalization/thinning, causing RegExp.escape to read the string as UC16 from one-byte backing storage. This results in an out-of-bounds read.

#VERSION d8 Version: [14.6.0] + [candidate] Operating System: [Ubuntu 24.04 x64]

#Root cause RegExp.escape flattens the input, then branches on IsOneByteRepresentation():

- builtins-regexp.cc:352-388
  - String::Flatten(isolate, str)
  - if (str->IsOneByteRepresentation())
      copy = OwnedCopyOf(str->GetFlatContent().ToOneByteVector())
    else
      copy = OwnedCopyOf(str->GetFlatContent().ToUC16Vector())

IsOneByteRepresentation() is map-based (string shape), not content-based:

- string-inl.h:521-523
  String::IsOneByteRepresentation() -> InstanceTypeChecker::IsOneByteString(map)

When a non-internalized string is internalized, it can become a ThinString that points to a canonical internalized string whose map encoding is one-byte:

- string.cc:155-200
  String::MakeThin uses internalized->IsOneByteRepresentation() to select the
  thin map and rewrites the original to ThinString(actual = internalized)

For sliced strings, the slice keeps its own map (two-byte) even if the parent string becomes thin to a one-byte internalized canonical. This creates a byteness mismatch: map says two-byte, backing storage is one-byte.

#Crash State

=================================================================
==125374==ERROR: AddressSanitizer: use-after-poison on address 0x6e12c0005028 at pc 0x57ee1e60cffb bp 0x7ffcef6cb890 sp 0x7ffcef6cb050
READ of size 40 at 0x6e12c0005028 thread T0
    #0 0x57ee1e60cffa in __asan_memcpy (/home/qy/new2/v8/out/x64.asan/d8+0x13b8ffa) (BuildId: e276665bb2c58cdf)
    #1 0x57ee1eb00b1f in MemCopy src/base/memcopy.h
    #2 0x57ee1eb00b1f in Copy<const unsigned short *, unsigned short *> src/base/algorithm.h:38:3
    #3 0x57ee1eb00b1f in NewByCopying<unsigned short> src/base/vector.h:304:5
    #4 0x57ee1eb00b1f in OwnedCopyOf<unsigned short> src/base/vector.h:386:10
    #5 0x57ee1eb00b1f in OwnedCopyOf<v8::base::Vector<const unsigned short> > src/base/vector.h:395:10
    #6 0x57ee1eb00b1f in v8::internal::Builtin_Impl_RegExpEscape(v8::internal::BuiltinArguments, v8::internal::Isolate*) src/builtins/builtins-regexp.cc:385:14
    #7 0x57ee23415235 in Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit setup-isolate-deserialize.cc
    #8 0x57ee23364829 in Builtins_InterpreterEntryTrampoline setup-isolate-deserialize.cc
    #9 0x57ee233615db in Builtins_JSEntryTrampoline setup-isolate-deserialize.cc
    #10 0x57ee2336132a in Builtins_JSEntry setup-isolate-deserialize.cc
    #11 0x57ee1ed1a126 in Call src/execution/simulator.h:216:12
    #12 0x57ee1ed1a126 in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) src/execution/execution.cc:442:22
    #13 0x57ee1ed1b5a8 in v8::internal::Execution::CallScript(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>) src/execution/execution.cc:542:10
    #14 0x57ee1e936b4b in v8::Script::Run(v8::Local<v8::Context>, v8::Local<v8::Data>) src/api/api.cc:2015:7
    #15 0x57ee1e6780e7 in v8::Shell::ExecuteString(v8::Isolate*, v8::Local<v8::String>, v8::Local<v8::String>, v8::Shell::ReportExceptions, v8::Global<v8::Value>*) src/d8/d8.cc:1037:44
    #16 0x57ee1e6b0549 in v8::SourceGroup::Execute(v8::Isolate*) src/d8/d8.cc:5591:10
    #17 0x57ee1e6bc84d in v8::Shell::RunMainIsolate(v8::Isolate*, bool) src/d8/d8.cc:6599:37
    #18 0x57ee1e6bbc85 in v8::Shell::RunMain(v8::Isolate*, bool) src/d8/d8.cc:6507:18
    #19 0x57ee1e6bf327 in v8::Shell::Main(int, char**) src/d8/d8.cc:7404:18
    #20 0x736220e2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #21 0x736220e2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
    #22 0x57ee1e56d029 in _start (/home/qy/new2/v8/out/x64.asan/d8+0x1319029) (BuildId: e276665bb2c58cdf)

Address 0x6e12c0005028 is a wild pointer inside of access range of size 0x000000000028.
SUMMARY: AddressSanitizer: use-after-poison (/home/qy/new2/v8/out/x64.asan/d8+0x13b8ffa) (BuildId: e276665bb2c58cdf) in __asan_memcpy
Shadow bytes around the buggy address:
  0x6e12c0004d80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004e00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004e80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004f00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004f80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
=>0x6e12c0005000: 00 00 00 00 00[f7]f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005080: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005100: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005180: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005200: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005280: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb

NOTE: the stack trace above identifies the code that *accessed* the poisoned memory.
To identify the code that *poisoned* the memory, try the experimental setting ASAN_OPTIONS=poison_history_size=<size>.
==125374==ABORTING
Received signal 6

==== C stack trace ===============================

out/x64.asan/d8(__interceptor_backtrace+0x46)[0x57ee1e5b4b36]
out/x64.asan/d8(+0x63976c0)[0x57ee235eb6c0]
/lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x736220e45330]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x11c)[0x736220e9eb2c]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x1e)[0x736220e4527e]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xdf)[0x736220e288ff]
out/x64.asan/d8(+0x13dbc5c)[0x57ee1e62fc5c]
out/x64.asan/d8(+0x13da44e)[0x57ee1e62e44e]
out/x64.asan/d8(+0x13c188b)[0x57ee1e61588b]
out/x64.asan/d8(+0x13c366d)[0x57ee1e61766d]
out/x64.asan/d8(__asan_memcpy+0x3ab)[0x57ee1e60d02b]
out/x64.asan/d8(+0x18acb20)[0x57ee1eb00b20]
out/x64.asan/d8(+0x61c1236)[0x57ee23415236]
[end of stack trace]
Aborted

The original report as published on the Chromium issue tracker, by qymag1c. 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. 10 min read.

Context

This is a V8 bug in the implementation of RegExp.escape, the built-in that takes a string and returns a new string with the characters that are special in a regular expression escaped, so the result can be embedded literally in a pattern. The report was filed through the Chrome VRP against the V8 engine, was rated medium severity, and was paid a bounty of 7000.00 USD. It was disclosed on 2026-03-10 and tracked as CVE-2026-3926, with the weakness classified as an out-of-bounds read.

The bug is not in the escaping logic itself but in how RegExp.escape decides the encoding of the string it copies. V8 strings are either one-byte (Latin-1) or two-byte (UC16), and the engine normally tracks this through the string's map. The report shows a case where the map and the actual backing storage disagree, and the copy routine trusts the map.

Setup

The researcher reproduced the issue on a debug build of d8, V8's standalone shell, built with AddressSanitizer. The version recorded in the report is:

Text
d8 Version: [14.6.0] + [candidate]
Operating System: [Ubuntu 24.04 x64]

The crash output references a build at out/x64.asan/d8, which is the ASan configuration of the shell. No browser, extension or special flags are mentioned; the trigger is plain JavaScript executed by the shell.

Finding it

The starting observation is that RegExp.escape chooses between a one-byte and a two-byte copy based on the string's map, via String::IsOneByteRepresentation, rather than on the actual content of the string. For an ordinary string that is fine, because the map and the storage are kept consistent. The researcher then considered SlicedString: a slice keeps its own map while its characters live in the parent's storage. If the parent is later internalised and thinned to a canonical one-byte string, the slice can keep a two-byte map pointing at storage that is now one-byte. That mismatch is the bug: RegExp.escape reads the string as UC16 from one-byte backing storage, producing an out-of-bounds read.

Exploitation

Step 1: understand the copy path in RegExp.escape

The report describes the builtin as first flattening the input and then branching on IsOneByteRepresentation():

Text
- builtins-regexp.cc:352-388
  - String::Flatten(isolate, str)
  - if (str->IsOneByteRepresentation())
      copy = OwnedCopyOf(str->GetFlatContent().ToOneByteVector())
    else
      copy = OwnedCopyOf(str->GetFlatContent().ToUC16Vector())

String::Flatten makes sure the string has contiguous content, but it does not reconcile the map with the encoding of that content. The branch then picks ToOneByteVector() or ToUC16Vector() purely from the map. If the map says two-byte while the flattened content is one-byte, the ToUC16Vector() path reads twice as many bytes as exist.

Step 2: confirm that the check is map-based

The report points at the definition of the predicate:

Text
- string-inl.h:521-523
  String::IsOneByteRepresentation() -> InstanceTypeChecker::IsOneByteString(map)

This is a shape check on the map, not an inspection of the characters. Any code path that can leave a string's map out of step with its storage therefore defeats it.

Step 3: create the mismatch through internalisation and thinning

The mechanism that produces the disagreement is internalisation. When a non-internalised string is internalised, it can be turned into a ThinString that points at a canonical internalised string, and the encoding of that canonical string decides the thin map:

Text
- string.cc:155-200
  String::MakeThin uses internalized->IsOneByteRepresentation() to select the
  thin map and rewrites the original to ThinString(actual = internalized)

For a sliced string, the slice keeps its own map, which is two-byte, even when the parent has become thin to a one-byte internalised canonical. The result is the byteness mismatch the report describes: the map says two-byte, the backing storage is one-byte.

Step 4: trigger the read under ASan

Feeding such a crafted SlicedString to RegExp.escape sends execution down the ToUC16Vector() branch and into the copy. Under AddressSanitizer the read is caught immediately:

Text
=================================================================
==125374==ERROR: AddressSanitizer: use-after-poison on address 0x6e12c0005028 at pc 0x57ee1e60cffb bp 0x7ffcef6cb890 sp 0x7ffcef6cb050
READ of size 40 at 0x6e12c0005028 thread T0
    #0 0x57ee1e60cffa in __asan_memcpy (/home/qy/new2/v8/out/x64.asan/d8+0x13b8ffa) (BuildId: e276665bb2c58cdf)
    #1 0x57ee1eb00b1f in MemCopy src/base/memcopy.h
    #2 0x57ee1eb00b1f in Copy<const unsigned short *, unsigned short *> src/base/algorithm.h:38:3
    #3 0x57ee1eb00b1f in NewByCopying<unsigned short> src/base/vector.h:304:5
    #4 0x57ee1eb00b1f in OwnedCopyOf<unsigned short> src/base/vector.h:386:10
    #5 0x57ee1eb00b1f in OwnedCopyOf<v8::base::Vector<const unsigned short> > src/base/vector.h:395:10
    #6 0x57ee1eb00b1f in v8::internal::Builtin_Impl_RegExpEscape(v8::internal::BuiltinArguments, v8::internal::Isolate*) src/builtins/builtins-regexp.cc:385:14
    #7 0x57ee23415235 in [redacted] setup-isolate-deserialize.cc
    #8 0x57ee23364829 in Builtins_InterpreterEntryTrampoline setup-isolate-deserialize.cc
    #9 0x57ee233615db in Builtins_JSEntryTrampoline setup-isolate-deserialize.cc
    #10 0x57ee2336132a in Builtins_JSEntry setup-isolate-deserialize.cc
    #11 0x57ee1ed1a126 in Call src/execution/simulator.h:216:12
    #12 0x57ee1ed1a126 in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) src/execution/execution.cc:442:22
    #13 0x57ee1ed1b5a8 in v8::internal::Execution::CallScript(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>) src/execution/execution.cc:542:10
    #14 0x57ee1e936b4b in v8::Script::Run(v8::Local<v8::Context>, v8::Local<v8::Data>) src/api/api.cc:2015:7
    #15 0x57ee1e6780e7 in v8::Shell::ExecuteString(v8::Isolate*, v8::Local<v8::String>, v8::Local<v8::String>, v8::Shell::ReportExceptions, v8::Global<v8::Value>*) src/d8/d8.cc:1037:44
    #16 0x57ee1e6b0549 in v8::SourceGroup::Execute(v8::Isolate*) src/d8/d8.cc:5591:10
    #17 0x57ee1e6bc84d in v8::Shell::RunMainIsolate(v8::Isolate*, bool) src/d8/d8.cc:6599:37
    #18 0x57ee1e6bbc85 in v8::Shell::RunMain(v8::Isolate*, bool) src/d8/d8.cc:6507:18
    #19 0x57ee1e6bf327 in v8::Shell::Main(int, char**) src/d8/d8.cc:7404:18
    #20 0x736220e2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #21 0x736220e2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
    #22 0x57ee1e56d029 in _start (/home/qy/new2/v8/out/x64.asan/d8+0x1319029) (BuildId: e276665bb2c58cdf)

Address 0x6e12c0005028 is a wild pointer inside of access range of size 0x000000000028.
SUMMARY: AddressSanitizer: use-after-poison (/home/qy/new2/v8/out/x64.asan/d8+0x13b8ffa) (BuildId: e276665bb2c58cdf) in __asan_memcpy
Shadow bytes around the buggy address:
  0x6e12c0004d80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004e00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004e80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004f00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004f80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
=>0x6e12c0005000: 00 00 00 00 00[f7]f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005080: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005100: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005180: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005200: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005280: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb

NOTE: the stack trace above identifies the code that *accessed* the poisoned memory.
To identify the code that *poisoned* the memory, try the experimental setting ASAN_OPTIONS=poison_history_size=<size>.
==125374==ABORTING
Received signal 6

==== C stack trace ===============================

out/x64.asan/d8(__interceptor_backtrace+0x46)[0x57ee1e5b4b36]
out/x64.asan/d8(+0x63976c0)[0x57ee235eb6c0]
/lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x736220e45330]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x11c)[0x736220e9eb2c]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x1e)[0x736220e4527e]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xdf)[0x736220e288ff]
out/x64.asan/d8(+0x13dbc5c)[0x57ee1e62fc5c]
out/x64.asan/d8(+0x13da44e)[0x57ee1e62e44e]
out/x64.asan/d8(+0x13c188b)[0x57ee1e61588b]
out/x64.asan/d8(+0x13c366d)[0x57ee1e61766d]
out/x64.asan/d8(__asan_memcpy+0x3ab)[0x57ee1e60d02b]
out/x64.asan/d8(+0x18acb20)[0x57ee1eb00b20]
out/x64.asan/d8(+0x61c1236)[0x57ee23415236]
[end of stack trace]
Aborted

The top frames are the important part. __asan_memcpy is called from MemCopy, which is reached through Copy<const unsigned short *, unsigned short *>, NewByCopying<unsigned short>, OwnedCopyOf<unsigned short> and finally Builtin_Impl_RegExpEscape at builtins-regexp.cc:385. The unsigned short type in those frames is the UC16 path, confirming that the two-byte branch was taken. The faulting access is a READ of size 40 at an address ASan reports as a wild pointer inside an access range of size 0x28, with the shadow bytes showing the region as poisoned (f7, poisoned by user). The process aborts with signal 6.

Root cause

The mistake is a byteness decision made from metadata rather than from the data. RegExp.escape flattens the input and then asks IsOneByteRepresentation(), which resolves to InstanceTypeChecker::IsOneByteString(map). That answer describes the string's shape, not the encoding of the bytes it actually points at.

Internalisation breaks the invariant the check relies on. String::MakeThin chooses the thin map from internalized->IsOneByteRepresentation() and rewrites the original string to a ThinString whose actual is the canonical internalised string. A SlicedString created before that point keeps its own two-byte map even though its parent now resolves to a one-byte canonical string. The slice therefore presents a two-byte map over one-byte storage, and the ToUC16Vector() copy reads past the end of the real data.

The existing defence, the map-based encoding check, is exactly what fails here: it is consistent with the string's declared shape but not with its storage after thinning. The report does not describe any other mitigation that was in place.

Impact

The report classifies the issue as an out-of-bounds read. In the demonstrated case the over-read is caught by AddressSanitizer and aborts the process. The report does not describe a path from the over-read to memory disclosure or code execution, and does not state which contexts (renderer, browser process, embedders) are reachable. The practical effect shown is a crash of the engine when RegExp.escape is called on a crafted sliced string whose parent has been internalised to a one-byte canonical string.

Fix

The change that follows from the root cause is to make the encoding decision from the flattened content rather than from the map, or to ensure that a SlicedString cannot retain a map whose encoding disagrees with its parent's storage after thinning.

Variants to test

  1. Other builtins that branch on IsOneByteRepresentation() after flattening. A positive result is a copy routine that takes the UC16 path on a string whose storage is one-byte, visible as an ASan over-read in the copy frames.
  2. Other string shapes that carry their own map while sharing a parent's storage, such as slices taken before internalisation. A positive result is the same map/storage mismatch after the parent is thinned.
  3. Sequences that force internalisation between slice creation and use, for example through property keys or other canonicalising operations. A positive result is a slice whose map still reports two-byte while the canonical parent is one-byte.
  4. Any API that copies string content based on a shape check rather than the content itself. A positive result is a read whose length exceeds the backing store, caught by ASan or by a length mismatch in the copied result.

Hunting notes

This kind of bug hides where engine code trusts string metadata after an operation that can change the underlying representation. The signals are calls to IsOneByteRepresentation() or InstanceTypeChecker::IsOneByteString that are followed by a copy or a length computation, especially after String::Flatten, and any code that handles SlicedString, ThinString or internalisation. The researcher showed impact with an ASan report containing the copy frames and the builtin frame in the stack.

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

What happened, in plain words

Every modern browser contains a JavaScript engine: the piece of software that reads the JavaScript code on a web page and actually runs it. In Chrome that engine is called V8. V8 is also used on its own by developers, through a small command-line program called d8, which runs JavaScript without any browser window around it.

V8 has a built-in function called RegExp.escape. A regular expression (often shortened to "regex") is a pattern used to search text, and some characters in it, such as . or *, have a special meaning. RegExp.escape takes a piece of ordinary text and returns a new string in which those special characters are neutralised, so the text can be dropped into a pattern and matched literally. To do that, it has to make a copy of the text.

Inside V8, text is stored in one of two ways. If every character fits in a single byte (roughly, plain Western letters and digits), the string is stored as "one-byte". Otherwise each character takes two bytes, and the string is "two-byte". Each string also carries a small label, called a map, that says what kind of string it is, including which of the two encodings it uses.

The bug is that RegExp.escape decides how to copy the text by reading that label instead of looking at the actual bytes. Normally the label and the bytes always agree, so this is harmless. The researcher found a sequence of internal V8 operations after which they no longer agree: the label says two-byte, but the bytes in memory are one-byte. RegExp.escape then copies twice as much data as exists, reading past the end of the real text. Reading memory you are not supposed to read is called an out-of-bounds read.

The report was filed through the Chrome VRP, Google's Vulnerability Reward Program for Chrome, against the V8 engine. It was rated medium severity and paid a bounty of 7000.00 USD. It was disclosed on 2026-03-10 and tracked as CVE-2026-3926, with the weakness classified as an out-of-bounds read.

Context

The bug is not in the escaping logic itself. The characters are escaped correctly. The problem is in how RegExp.escape decides the encoding of the string it copies. V8 strings are either one-byte (Latin-1) or two-byte (UC16), and the engine normally tracks this through the string's map. The report shows a case where the map and the actual backing storage disagree, and the copy routine trusts the map.

A few words that come up throughout:

  • Map: a small internal record attached to every object in V8 that describes its shape and type. Think of the label on a jar: it tells you what is inside without you opening it.
  • Backing storage: the actual block of memory where the characters live. The label and the contents are two separate things.
  • Built-in: a function that ships with the engine and is implemented in V8's own C++ code rather than in JavaScript.

Setup

The researcher reproduced the issue on a debug build of d8, V8's standalone shell, built with AddressSanitizer. AddressSanitizer, usually shortened to ASan, is a tool added to a program at compile time that watches every memory access and stops the program the moment it touches memory it should not. It is like a smoke alarm for memory bugs: it does not prevent the fire, but it makes it impossible to miss.

The version recorded in the report is:

Text
d8 Version: [14.6.0] + [candidate]
Operating System: [Ubuntu 24.04 x64]

Line by line:

  1. d8 Version: [14.6.0] + [candidate] states which build of the shell was used. [candidate] marks it as a candidate build rather than a final release.
  2. Operating System: [Ubuntu 24.04 x64] states the machine it ran on: Ubuntu 24.04, a Linux distribution, on a 64-bit processor.

The crash output references a build at out/x64.asan/d8, which is the ASan configuration of the shell. No browser, extension or special flags are mentioned; the trigger is plain JavaScript executed by the shell.

Finding it

The starting observation is that RegExp.escape chooses between a one-byte and a two-byte copy based on the string's map, via String::IsOneByteRepresentation, rather than on the actual content of the string. For an ordinary string that is fine, because the map and the storage are kept consistent.

The researcher then considered SlicedString. A slice is a string that does not own its characters: it is a window onto part of a parent string. It keeps its own map while its characters live in the parent's storage. A useful comparison is a bookmark placed in a book: the bookmark records where to look, but the words stay in the book, and if the book is replaced with a different edition, the bookmark still points at the old page number.

If the parent is later internalised and thinned to a canonical one-byte string, the slice can keep a two-byte map pointing at storage that is now one-byte. Two more terms are needed here:

  • Internalisation: V8 keeps a single shared copy of strings that are used as identifiers, such as property names. Making a string internal means replacing it with that shared copy so that comparisons become cheap.
  • Thinning: instead of physically rewriting the old string, V8 can turn it into a ThinString, a small forwarding stub that points at the canonical internalised copy. It is like replacing a note with a sign saying "see the master copy over there".

That mismatch is the bug: RegExp.escape reads the string as UC16 from one-byte backing storage, producing an out-of-bounds read.

Exploitation

Step 1: understand the copy path in RegExp.escape

The report describes the builtin as first flattening the input and then branching on IsOneByteRepresentation():

Text
- builtins-regexp.cc:352-388
  - String::Flatten(isolate, str)
  - if (str->IsOneByteRepresentation())
      copy = OwnedCopyOf(str->GetFlatContent().ToOneByteVector())
    else
      copy = OwnedCopyOf(str->GetFlatContent().ToUC16Vector())

Line by line:

  1. - builtins-regexp.cc:352-388 is the location in V8's source code: the file builtins-regexp.cc, lines 352 to 388. Source locations like this are given so that anyone can open the same file and follow along.
  2. String::Flatten(isolate, str) makes sure the string has contiguous content. A string can be stored in pieces, for example as a slice of a parent or as a chain of joined fragments; flattening gathers the characters into one straight run so they can be copied in one go. It does not reconcile the map with the encoding of that content.
  3. if (str->IsOneByteRepresentation()) asks the string whether it is one-byte. As the next step shows, this question is answered from the map.
  4. copy = OwnedCopyOf(str->GetFlatContent().ToOneByteVector()) is the one-byte branch: take the flattened content as a sequence of single bytes and make an owned copy of it.
  5. copy = OwnedCopyOf(str->GetFlatContent().ToUC16Vector()) is the two-byte branch: take the same flattened content, but interpret it as a sequence of two-byte characters, and copy that.

The branch picks ToOneByteVector() or ToUC16Vector() purely from the map. If the map says two-byte while the flattened content is one-byte, the ToUC16Vector() path reads twice as many bytes as exist. This is the exact point where a label is trusted to describe data.

Step 2: confirm that the check is map-based

The report points at the definition of the predicate:

Text
- string-inl.h:521-523
  String::IsOneByteRepresentation() -> InstanceTypeChecker::IsOneByteString(map)

Line by line:

  1. - string-inl.h:521-523 is the source location: file string-inl.h, lines 521 to 523.
  2. String::IsOneByteRepresentation() -> InstanceTypeChecker::IsOneByteString(map) shows that the question "is this string one-byte?" is answered by handing the string's map to a checker. This is a shape check on the map, not an inspection of the characters. Any code path that can leave a string's map out of step with its storage therefore defeats it. The step matters because it proves the weakness is structural: the check cannot notice a mismatch even in principle.

Step 3: create the mismatch through internalisation and thinning

The mechanism that produces the disagreement is internalisation. When a non-internalised string is internalised, it can be turned into a ThinString that points at a canonical internalised string, and the encoding of that canonical string decides the thin map:

Text
- string.cc:155-200
  String::MakeThin uses internalized->IsOneByteRepresentation() to select the
  thin map and rewrites the original to ThinString(actual = internalized)

Line by line:

  1. - string.cc:155-200 is the source location: file string.cc, lines 155 to 200.
  2. String::MakeThin uses internalized->IsOneByteRepresentation() to select the thin map means the forwarding stub's label is chosen from the encoding of the canonical copy it points at. If the canonical copy is one-byte, the stub is labelled one-byte.
  3. and rewrites the original to ThinString(actual = internalized) means the original string object is changed in place into a stub whose actual field is the canonical copy. Anyone still holding the original now transparently reaches the canonical string.

For a sliced string, the slice keeps its own map, which is two-byte, even when the parent has become thin to a one-byte internalised canonical. The result is the byteness mismatch the report describes: the map says two-byte, the backing storage is one-byte. Internalisation changes a string's storage without rewriting every object that refers to it, which is the condition needed to separate label from data.

Step 4: trigger the read under ASan

Feeding such a crafted SlicedString to RegExp.escape sends execution down the ToUC16Vector() branch and into the copy. Under AddressSanitizer the read is caught immediately:

Text
=================================================================
==125374==ERROR: AddressSanitizer: use-after-poison on address 0x6e12c0005028 at pc 0x57ee1e60cffb bp 0x7ffcef6cb890 sp 0x7ffcef6cb050
READ of size 40 at 0x6e12c0005028 thread T0
    #0 0x57ee1e60cffa in __asan_memcpy (/home/qy/new2/v8/out/x64.asan/d8+0x13b8ffa) (BuildId: e276665bb2c58cdf)
    #1 0x57ee1eb00b1f in MemCopy src/base/memcopy.h
    #2 0x57ee1eb00b1f in Copy<const unsigned short *, unsigned short *> src/base/algorithm.h:38:3
    #3 0x57ee1eb00b1f in NewByCopying<unsigned short> src/base/vector.h:304:5
    #4 0x57ee1eb00b1f in OwnedCopyOf<unsigned short> src/base/vector.h:386:10
    #5 0x57ee1eb00b1f in OwnedCopyOf<v8::base::Vector<const unsigned short> > src/base/vector.h:395:10
    #6 0x57ee1eb00b1f in v8::internal::Builtin_Impl_RegExpEscape(v8::internal::BuiltinArguments, v8::internal::Isolate*) src/builtins/builtins-regexp.cc:385:14
    #7 0x57ee23415235 in [redacted] setup-isolate-deserialize.cc
    #8 0x57ee23364829 in Builtins_InterpreterEntryTrampoline setup-isolate-deserialize.cc
    #9 0x57ee233615db in Builtins_JSEntryTrampoline setup-isolate-deserialize.cc
    #10 0x57ee2336132a in Builtins_JSEntry setup-isolate-deserialize.cc
    #11 0x57ee1ed1a126 in Call src/execution/simulator.h:216:12
    #12 0x57ee1ed1a126 in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) src/execution/execution.cc:442:22
    #13 0x57ee1ed1b5a8 in v8::internal::Execution::CallScript(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>) src/execution/execution.cc:542:10
    #14 0x57ee1e936b4b in v8::Script::Run(v8::Local<v8::Context>, v8::Local<v8::Data>) src/api/api.cc:2015:7
    #15 0x57ee1e6780e7 in v8::Shell::ExecuteString(v8::Isolate*, v8::Local<v8::String>, v8::Local<v8::String>, v8::Shell::ReportExceptions, v8::Global<v8::Value>*) src/d8/d8.cc:1037:44
    #16 0x57ee1e6b0549 in v8::SourceGroup::Execute(v8::Isolate*) src/d8/d8.cc:5591:10
    #17 0x57ee1e6bc84d in v8::Shell::RunMainIsolate(v8::Isolate*, bool) src/d8/d8.cc:6599:37
    #18 0x57ee1e6bbc85 in v8::Shell::RunMain(v8::Isolate*, bool) src/d8/d8.cc:6507:18
    #19 0x57ee1e6bf327 in v8::Shell::Main(int, char**) src/d8/d8.cc:7404:18
    #20 0x736220e2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #21 0x736220e2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
    #22 0x57ee1e56d029 in _start (/home/qy/new2/v8/out/x64.asan/d8+0x1319029) (BuildId: e276665bb2c58cdf)

Address 0x6e12c0005028 is a wild pointer inside of access range of size 0x000000000028.
SUMMARY: AddressSanitizer: use-after-poison (/home/qy/new2/v8/out/x64.asan/d8+0x13b8ffa) (BuildId: e276665bb2c58cdf) in __asan_memcpy
Shadow bytes around the buggy address:
  0x6e12c0004d80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004e00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004e80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004f00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0004f80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
=>0x6e12c0005000: 00 00 00 00 00[f7]f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005080: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005100: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005180: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005200: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x6e12c0005280: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb

NOTE: the stack trace above identifies the code that *accessed* the poisoned memory.
To identify the code that *poisoned* the memory, try the experimental setting ASAN_OPTIONS=poison_history_size=<size>.
==125374==ABORTING
Received signal 6

==== C stack trace ===============================

out/x64.asan/d8(__interceptor_backtrace+0x46)[0x57ee1e5b4b36]
out/x64.asan/d8(+0x63976c0)[0x57ee235eb6c0]
/lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x736220e45330]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x11c)[0x736220e9eb2c]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x1e)[0x736220e4527e]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xdf)[0x736220e288ff]
out/x64.asan/d8(+0x13dbc5c)[0x57ee1e62fc5c]
out/x64.asan/d8(+0x13da44e)[0x57ee1e62e44e]
out/x64.asan/d8(+0x13c188b)[0x57ee1e61588b]
out/x64.asan/d8(+0x13c366d)[0x57ee1e61766d]
out/x64.asan/d8(__asan_memcpy+0x3ab)[0x57ee1e60d02b]
out/x64.asan/d8(+0x18acb20)[0x57ee1eb00b20]
out/x64.asan/d8(+0x61c1236)[0x57ee23415236]
[end of stack trace]
Aborted

This is a crash report, and it is long, so it helps to know what each part is before reading it:

  1. The first line, ==125374==ERROR: AddressSanitizer: use-after-poison on address 0x6e12c0005028 ..., is ASan announcing that the program touched memory marked as off-limits. The number 125374 is the process ID. use-after-poison is ASan's name for touching memory it had deliberately marked as poisoned, meaning "not yours to read".
  2. READ of size 40 at 0x6e12c0005028 thread T0 says the program tried to read 40 bytes starting at that address, on the main thread.
  3. The numbered lines beginning with #0, #1 and so on are the stack trace: the chain of function calls that led to the fault, newest first. #0 is where the fault happened, and each higher number is the function that called it.
  4. Address 0x6e12c0005028 is a wild pointer inside of access range of size 0x000000000028. is ASan's summary of the address: it does not belong to a live object the program is allowed to use.
  5. SUMMARY: AddressSanitizer: use-after-poison ... in __asan_memcpy repeats the finding in one line, naming the function where it happened.
  6. The Shadow bytes around the buggy address block is ASan's internal bookkeeping. ASan reserves one byte of "shadow" memory for every eight bytes of real memory, recording whether each region is safe to use. The f7 values mean "poisoned by user", and the => line marks the exact spot that was read.
  7. The Shadow byte legend explains what each shadow value means, for example 00 for addressable memory and fd for memory that has been freed.
  8. The NOTE explains that the trace shows which code read the poisoned memory, not which code poisoned it, and mentions an experimental setting for tracking the latter.
  9. ==125374==ABORTING and Received signal 6 mean ASan stopped the process. Signal 6 is the standard abort signal on Linux.
  10. The second, shorter C stack trace is V8's own handler printing the call chain again before the process dies.

The top frames are the important part. __asan_memcpy is called from MemCopy, which is reached through Copy<const unsigned short *, unsigned short *>, NewByCopying<unsigned short>, OwnedCopyOf<unsigned short> and finally Builtin_Impl_RegExpEscape at builtins-regexp.cc:385. memcpy is the standard low-level routine for copying a block of bytes, and the __asan_ prefix means it is ASan's instrumented version that checks the range before copying. The unsigned short type in those frames is the UC16 path, confirming that the two-byte branch was taken. The faulting access is a READ of size 40 at an address ASan reports as a wild pointer inside an access range of size 0x28, with the shadow bytes showing the region as poisoned (f7, poisoned by user). The process aborts with signal 6.

Root cause

The mistake is a byteness decision made from metadata rather than from the data. RegExp.escape flattens the input and then asks IsOneByteRepresentation(), which resolves to InstanceTypeChecker::IsOneByteString(map). That answer describes the string's shape, not the encoding of the bytes it actually points at.

Internalisation breaks the invariant the check relies on. String::MakeThin chooses the thin map from internalized->IsOneByteRepresentation() and rewrites the original string to a ThinString whose actual is the canonical internalised string. A SlicedString created before that point keeps its own two-byte map even though its parent now resolves to a one-byte canonical string. The slice therefore presents a two-byte map over one-byte storage, and the ToUC16Vector() copy reads past the end of the real data.

The existing defence, the map-based encoding check, is exactly what fails here: it is consistent with the string's declared shape but not with its storage after thinning. The report does not describe any other mitigation that was in place.

Impact

The report classifies the issue as an out-of-bounds read. In the demonstrated case the over-read is caught by AddressSanitizer and aborts the process. The report does not describe a path from the over-read to memory disclosure or code execution, and does not state which contexts (renderer, browser process, embedders) are reachable. The practical effect shown is a crash of the engine when RegExp.escape is called on a crafted sliced string whose parent has been internalised to a one-byte canonical string.

Fix

The change that follows from the root cause is to make the encoding decision from the flattened content rather than from the map, or to ensure that a SlicedString cannot retain a map whose encoding disagrees with its parent's storage after thinning.

Variants to test

  1. Other builtins that branch on IsOneByteRepresentation() after flattening. A positive result is a copy routine that takes the UC16 path on a string whose storage is one-byte, visible as an ASan over-read in the copy frames.
  2. Other string shapes that carry their own map while sharing a parent's storage, such as slices taken before internalisation. A positive result is the same map/storage mismatch after the parent is thinned.
  3. Sequences that force internalisation between slice creation and use, for example through property keys or other canonicalising operations. A positive result is a slice whose map still reports two-byte while the canonical parent is one-byte.
  4. Any API that copies string content based on a shape check rather than the content itself. A positive result is a read whose length exceeds the backing store, caught by ASan or by a length mismatch in the copied result.

Hunting notes

This kind of bug hides where engine code trusts string metadata after an operation that can change the underlying representation. The signals are calls to IsOneByteRepresentation() or InstanceTypeChecker::IsOneByteString that are followed by a copy or a length computation, especially after String::Flatten, and any code that handles SlicedString, ThinString or internalisation. The researcher showed impact by producing a deterministic ASan report with the copy frames and the builtin frame in the stack, which is the evidence a VRP needs for an engine memory-safety issue.

Glossary

  • AddressSanitizer (ASan): a tool built into a program during compilation that watches memory accesses and stops the program when it reads or writes memory it should not.
  • Backing storage: the actual block of memory holding a string's characters, as opposed to the metadata describing it.
  • Bounty: a payment made by a company to a researcher who reports a valid security bug.
  • Built-in: a function implemented inside the engine itself rather than in JavaScript code.
  • Byte: the basic unit of computer memory, eight bits, enough to hold one simple character.
  • Canonical string: the single shared copy of a string that V8 keeps for internalised strings.
  • Chrome VRP: Google's Vulnerability Reward Program for Chrome, the scheme through which Chrome security bugs are reported and rewarded.
  • CVE: Common Vulnerabilities and Exposures, a public identifier assigned to a specific security flaw so people can refer to it unambiguously.
  • d8: V8's standalone command-line shell, which runs JavaScript without a browser.
  • Debug build: a version of a program compiled with extra checks and information to help find bugs.
  • Flatten: to gather a string's characters into one contiguous run in memory so they can be processed in one go.
  • Internalisation: replacing a string with a single shared canonical copy, so that comparing two such strings is cheap.
  • Invariant: a condition that is supposed to always hold true; here, that a string's map matches its storage.
  • Latin-1: a character encoding in which each character fits in one byte.
  • Map: a small internal record attached to a V8 object describing its shape and type, including a string's encoding.
  • Medium severity: a rating on a scale of how serious a bug is, sitting between low and high.
  • memcpy: a standard low-level routine that copies a block of bytes from one place to another.
  • Metadata: data that describes other data, such as a label saying what a string contains, rather than the contents themselves.
  • Out-of-bounds read: reading memory outside the region a program is supposed to access.
  • Process ID: the number the operating system uses to identify a running program.
  • RegExp.escape: a JavaScript built-in that returns a copy of a string with regular-expression special characters escaped.
  • Regular expression (regex): a pattern language for matching text, in which some characters have special meanings.
  • Renderer: the part of a browser that runs a web page's code, kept separate from the rest of the browser for safety.
  • Shadow memory: ASan's bookkeeping memory, one byte for every eight bytes of real memory, recording which regions are safe to use.
  • Signal 6: the standard Linux signal used to abort a process.
  • SlicedString: a V8 string that is a window onto part of a parent string, sharing the parent's storage.
  • Stack trace: the list of function calls that led to a particular point in a program, newest first.
  • ThinString: a small forwarding stub that V8 puts in place of a string after internalisation, pointing at the canonical copy.
  • Thread: one sequence of instructions executing inside a program; a program can have several running at once.
  • UC16: a character encoding in which each character takes two bytes.
  • Use-after-poison: ASan's message for touching memory it has marked as off-limits.
  • V8: the JavaScript engine inside Chrome, also usable on its own.
  • Wild pointer: an address that does not belong to any live object the program is allowed to use.

More by qymag1c

View all

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