Support `SharedArrayBuffer` (`crossOriginIsolated`)

This was discussed a little in a private chat. I researched whether we can do it.

The following patch enables it on Desktop:

Desktop patch
diff --git a/packages/target-electron/src/deltachat/webxdc.ts b/packages/target-electron/src/deltachat/webxdc.ts
index 212162d4d..1d67dfa39 100644
--- a/packages/target-electron/src/deltachat/webxdc.ts
+++ b/packages/target-electron/src/deltachat/webxdc.ts
@@ -1068,6 +1068,10 @@ const makeResponse = ({
   if (mime_type) {
     headers.append('content-type', mime_type)
   }
+
+  headers.append('Cross-Origin-Opener-Policy', 'same-origin')
+  headers.append('Cross-Origin-Embedder-Policy', 'require-corp')
+
   return new Response(body, {
     ...responseInit,
     headers,

In theory these headers are supposed to put more restrictions on the web page (i.e. ensure better cross-origin isolation), which allows to use more powerful features. So one might think that adding these headers is basically a no-brainer.

However, one thing that needs to be kept in mind and investigated is the fact that WebXDC promises no exfiltration which is what makes it different from regular websites. More concretely, we need to keep in mind that malicious app instances in different chats might try to communicate via e.g. timing side-channels.

One idea is to put this behind a permission.
And possibly also disallow running other WebXDC apps at the same time to disable covert communication. But that might not be enough as I guess a malicious website running in the browser could also part take in the exfiltration process.

Wow I didn’t expect anyone to reply actually, thanks!

Indeed this is a bit complicated. The idea of adding permissions to WebXDC doesn’t go against the “no exfiltration” idea in general, but this particular one would.

Um I’m not getting it. Malicious site? Running where? In a browser (not Delta Chat)? Because us setting the headers in Delta Chat would not affect that whatsoever.

See WebXDC threat model? I guess, but IMO in one sentence: an app might be malicious, and people who you chat with might be malicious. At least that’s what I personally would like to have handled by our WebXDC implementation.