Inappropriate implementation in Keyboard (CVE-2026-11122)
The KeyboardLayout singleton caches a ScriptPromiseResolver without checking the caller's V8 context, so a malicious page can obtain a promise created in an extension's isolated world. This could allow the page to execute arbitrary script in the isolated world context (UXSS).
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.
Overview: The navigator.keyboard.getLayoutMap() implementation caches a ScriptPromiseResolver without verifying the caller's V8 Context. This allows a malicious page to obtain a reference to a v8::Promise created in an extension's isolated world, potentially leading to arbitrary script execution in the isolated world context (UXSS).
Affected files:
third_party/blink/renderer/modules/keyboard/keyboard_layout.ccthird_party/blink/renderer/modules/keyboard/keyboard_layout.hthird_party/blink/renderer/modules/keyboard/keyboard.cc
Estimated timestamp from git blame: 2024-03-26
Summary
KeyboardLayout is a per-LocalDOMWindow singleton (owned by Keyboard, a Supplement to Navigator) that caches a ScriptPromiseResolver while a Mojo call to the browser process is in flight. Because this singleton is shared across different v8::Contexts (e.g., the page's main world and an extension's isolated world), it can leak a v8::Promise from one world to another.
A malicious page can exploit this to gain access to an extension's isolated world context if the extension calls navigator.keyboard.getLayoutMap(). Since native v8::Promise objects do not trigger cross-world access checks when passed between contexts in the same isolate, the page can use prototype walking to reach the isolated world's Function constructor and execute arbitrary script.
Technical Details
In third_party/blink/renderer/modules/keyboard/keyboard_layout.cc, the GetKeyboardLayoutMap method handles requests for the keyboard layout map:
ScriptPromise<KeyboardLayoutMap> KeyboardLayout::GetKeyboardLayoutMap(
ScriptState* script_state,
ExceptionState& exception_state) {
if (script_promise_resolver_) {
return script_promise_resolver_->Promise();
}
// ... Mojo request initiated ...
script_promise_resolver_ =
MakeGarbageCollected<ScriptPromiseResolver<KeyboardLayoutMap>>(
script_state, exception_state.GetContext());
// ...
}
The script_promise_resolver_ is cached as a member variable. If a second call to getLayoutMap() occurs while a Mojo request is pending, the method returns the promise from the existing resolver.
However, ScriptPromiseResolver initializes its underlying v8::Promise in the ScriptState (V8 Context) of the caller that first triggered its creation. If an extension's content script calls getLayoutMap() first, script_promise_resolver_ holds a promise belonging to the extension's isolated world. If the page then calls getLayoutMap() before the Mojo response is processed, it receives the exact same v8::Promise object because the method lacks any check to ensure the caller's ScriptState matches the cached resolver's ScriptState.
Blink returns ScriptPromise objects to V8 by extracting the raw v8::Promise (via .V8Promise()), bypassing wrapper-based isolation. Because the page now holds a reference to an object from the isolated world, it can navigate the prototype chain to access the isolated world's Function constructor:
leaked_promise.constructor.constructor('...arbitrary script...')()
Potential Attack Scenario
Note: These are suggested steps based on code analysis; a working proof-of-concept has not yet been executed in a live environment.
- A victim visits a malicious website and has an extension installed that calls
navigator.keyboard.getLayoutMap()in response to a DOM event (e.g., akeydownlistener in a content script). - The malicious page's main script synchronously triggers the event:
document.dispatchEvent(new KeyboardEvent('keydown')). EventTarget::DispatchEventprocesses listeners synchronously, switching to the content script's isolated world to invoke its listener.- The content script calls
getLayoutMap(), creating the cachedScriptPromiseResolverbound to its isolated world. - The synchronous dispatch finishes, returning control to the malicious main-world script.
- In the same microtask (before the asynchronous Mojo response can clear the cached resolver), the main page calls
navigator.keyboard.getLayoutMap(). - The page receives the isolated-world
v8::Promiseand uses it to execute script in the isolated world, granting access to extension privileges (e.g.,chrome.runtime).
Suggested Fix
Do not cache a single ScriptPromiseResolver across different contexts. Either:
- Maintain a list/queue of
ScriptPromiseResolverobjects (one for each pending call) and resolve them all when the Mojo request completes. - Add a check to verify that the
script_statepassed intoGetKeyboardLayoutMapmatches theScriptStateof the currently cachedscript_promise_resolver_. If it does not match, either create a separate request or reject the new promise.
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
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 KeyboardLayout singleton caches a single ScriptPromiseResolver across different V8 contexts without verifying that the caller's ScriptState matches the cached resolver's ScriptState.
Impact
A malicious page could execute arbitrary script in an extension's isolated world, gaining access to extension privileges such as chrome.runtime; however, the report notes that a working proof-of-concept has not yet been executed.
What the attacker needed
Victim has an extension that calls getLayoutMap(); victim visits a malicious website; extension calls getLayoutMap() on a DOM event
The fix
The code should not cache a single ScriptPromiseResolver across contexts; instead it should maintain a queue of resolvers or check that the caller's ScriptState matches the cached resolver's ScriptState.
How it was found
- A victim visits a malicious website and has an extension that calls navigator.keyboard.getLayoutMap() in response to a DOM event.
- The malicious page synchronously triggers the event.
- Event dispatch switches to the content script's isolated world and invokes its listener.
- The content script calls getLayoutMap(), creating a cached resolver bound to its isolated world.
- Control returns to the main-world script, which calls getLayoutMap() in the same microtask.
- The page receives the isolated-world promise and uses it to execute script in the isolated world.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A browser extension runs its code in a separate 'world' to keep it isolated from the web page. This bug lets a web page get a reference to an object from that isolated world, which can then be used to run code with the extension's privileges.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.