← All reports

Support "message_serialization": "structured_clone" for extension messaging

Component: WebKit Web Extensions | e8d9b34

Source/WebKit/Shared/Extensions/WebExtensionContextParameters.serialization.in

double manifestVersion;
+ bool usesStructuredCloneMessageSerialization;

Source/WebKit/Shared/Extensions/WebExtensionContextParameters.h

double manifestVersion { 0 };
+ bool usesStructuredCloneMessageSerialization { false };

Source/WebKit/CMakeLists.txt

+ Shared/Extensions/WebExtensionMessage.serialization.in

Web extension APIs run in WebContent processes (background, content scripts, popups), and the UIProcess brokers messaging between them: the sender's process calls an IPC handler such as runtimeSendMessage, tabsSendMessage or portPostMessage, and the UIProcess forwards to the target's WebExtensionContextProxy. Until now the payload was always a JSON string, which is inert text. SerializedScriptValue is the structured-clone wire format postMessage uses; it can carry typed arrays, Maps, Blobs and other complex objects and is deserialized into live JS objects on the receiving side.

This commit adds a message_serialization manifest key. With structured_clone, runtime.sendMessage, tabs.sendMessage and Port.postMessage serialize with SerializedScriptValue. Messages and replies travel as a new WebExtensionMessage IPC type holding either a JSON string or a SerializedScriptValue, and receivers accept both. Replies become std::optional, and an invalid manifest value records InvalidManifestEntry and falls back to JSON. Web pages and native apps have no manifest to opt in, so those paths stay JSON.

Extensions can now pass ArrayBuffer, Map, Date and Blob across contexts without base64 chunking. Structured-clone payloads, including Blob references, now cross WebContent to UIProcess to WebContent through a new IPC variant type.

The new variant is a deserialization and relay path reachable by a compromised sender: