Inappropriate implementation in ServiceWorker (CVE-2026-7963)
A logic error in generated code allows an attacker with an arbitrary memory write primitive to bypass ProtectedMemory mitigations for MojoJS by corrupting a vector of runtime feature strings during Service Worker startup. This exposes window.Mojo to the web context, bypassing context checks and facilitating a renderer sandbox escape.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 39 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A logic error in the generated code for runtime-enabled features allows an attacker with an arbitrary memory write primitive to bypass ProtectedMemory mitigations for MojoJS. By corrupting the forced_enabled_runtime_features vector during Service Worker startup, an attacker can invoke a generated string-to-setter mapping that legitimately unprotects and enables the flag. This exposes window.Mojo to the web context, bypassing context checks and facilitating a renderer sandbox escape.
Affected files:
third_party/blink/renderer/build/scripts/templates/runtime_enabled_features.cc.tmplcontent/renderer/service_worker/embedded_worker_instance_client_impl.ccthird_party/blink/renderer/platform/runtime_enabled_features.json5
Estimated timestamp from git blame: 2024-05-16
Background
ProtectedMemory is designed to prevent data-only attacks from modifying security-critical variables (like is_mojo_js_enabled_) by keeping them in read-only memory pages. They are only briefly made writable during legitimate updates via base::AutoWritableMemory.
Vulnerability Details
A structural flaw exists in how RuntimeEnabledFeaturesBase::SetFeatureEnabledFromString is generated by third_party/blink/renderer/build/scripts/templates/runtime_enabled_features.cc.tmpl.
The generator creates a static kFeatures[] array mapping feature string names to their respective setter functions. Crucially, it includes features marked with is_protected_feature: true. The generated setter for a protected feature (e.g., SetMojoJSEnabled) legitimately uses base::AutoWritableMemory to unprotect, modify, and re-protect the memory.
Because this setter is reachable via a string-indexed lookup, it creates a powerful Data-Oriented Programming (DOP) gadget. If an attacker can control a string passed to WebRuntimeFeatures::EnableFeatureFromString, they can safely toggle ProtectedMemory variables without causing a segmentation fault.
Potential Attack Path
Note: These are suggested steps based on static analysis; our tooling does not currently have the ability to run code to produce a live Proof-of-Concept.
- Obtain Primitives: An attacker exploits a typical renderer vulnerability (e.g., a V8 bug) to gain arbitrary memory read/write capabilities.
- Trigger IPC: The attacker triggers a Service Worker startup sequence, causing the browser to send an
EmbeddedWorkerStartParamsPtrIPC to the renderer. - Corrupt Heap Data: During deserialization, the
params->forced_enabled_runtime_featuresstd::vector<std::string>is allocated on the renderer's heap. While theStartWorkertask is queued, the attacker uses their write primitive to overwrite the vector's backing store to point to a crafted string containing"MojoJS". - Execute Gadget:
EmbeddedWorkerInstanceClientImpl::StartWorkerexecutes and iterates over the corrupted vector, callingblink::WebRuntimeFeatures::EnableFeatureFromString("MojoJS", true). - Bypass ProtectedMemory: The gadget performs a binary search, finds
"MojoJS", and invokesSetMojoJSEnabled(true).base::AutoWritableMemorysafely unprotects the page, sets the globalis_mojo_js_enabled_flag to true, and re-protects it. - Evade Context Checks: The attacker creates a new execution context (e.g., a new
<iframe>). In Blink IDL,Mojouses[ContextEnabled=MojoJS, RuntimeEnabled=MojoJS]. The generated bindings (v8_window.cc) use anORcondition for these attributes. Because the globalRuntimeEnabledflag is now true, the check short-circuits, completely bypassing the strictContextFeatureSettings::CrashIfMojoJSNotAllowed()mitigation. - Sandbox Escape:
window.Mojois exposed to the attacker's JavaScript, allowing them to bind privileged browser interfaces and escape the sandbox.
Suggested Fix
Modify third_party/blink/renderer/build/scripts/templates/runtime_enabled_features.cc.tmpl to explicitly exclude features marked with is_protected_feature: true from the kFeatures[] array used by SetFeatureEnabledFromString (and potentially IsFeatureEnabledFromString). Protected features should not be toggleable via dynamic string lookups.
Evaluated with Chrome root at commit: a9cbf6e8b275fe4147435aa905f3b7f5a656f5f0
Results from 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
The code generator includes protected features in the string-to-setter mapping used by SetFeatureEnabledFromString, allowing them to be toggled via dynamic string lookups.
Impact
This could allow an attacker to expose window.Mojo to the web context, bypassing context checks and facilitating a renderer sandbox escape.
What the attacker needed
Arbitrary memory write primitive; ability to trigger Service Worker startup
The fix
The template should be modified to exclude features marked with is_protected_feature: true from the kFeatures[] array used by SetFeatureEnabledFromString.
How it was found
- Obtain arbitrary memory read/write capabilities via a renderer vulnerability.
- Trigger a Service Worker startup sequence, causing the browser to send an IPC to the renderer.
- Corrupt the heap-allocated vector of forced enabled runtime features to point to a crafted string containing "MojoJS".
- The StartWorker task executes and iterates over the corrupted vector, calling EnableFeatureFromString("MojoJS", true).
- The gadget invokes SetMojoJSEnabled(true), which unprotects, sets, and re-protects the flag.
- Create a new execution context (e.g., an iframe) to expose window.Mojo and escape the sandbox.
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.
This report describes a flaw in how a web browser (Chrome) protects certain internal settings. Normally, a security feature called ProtectedMemory keeps sensitive flags in read-only memory so attackers cannot change them. However, the code that enables features by name includes a way to toggle a protected flag (MojoJS) without crashing, so an attacker who already has memory write access can turn it on and then use a powerful internal interface to escape the browser's sandbox.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.