From 5417b583db5f29ab384aaad8d9b9b5446b209ab8 Mon Sep 17 00:00:00 2001 From: WofWca Date: Fri, 5 Jul 2024 18:57:53 +0400 Subject: [PATCH 1/2] fix: webxdc: CSP bypass This doesn't appear to fix an exploitable vulnerability because `host-rules` is already set to disable network access, so "XDC-01-002 WP1" from the Cure53 audit has not been brought back ever since the initial fix. Initially fixed in a9e5242acb Reintroduced in fd1f8ce27b6e6 Related refactor commit 2cd310ec08f8f Also bring back and improve the PDF comment about "XDC-01-005 WP1" --- CHANGELOG.md | 1 + src/main/deltachat/webxdc.ts | 48 +++++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4474721f8..7ce9d0840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Fix the problem of Quit menu item on WebXDC apps closes the whole DC app #3995 - minor performance improvements #3981 - fix chat list items (e.g. Archive) and contacts not showing up sometimes #4004 +- fix CSP bypass in webxdc (not a vulnerability) #4011 diff --git a/src/main/deltachat/webxdc.ts b/src/main/deltachat/webxdc.ts index 4580af074..994dcb4f3 100644 --- a/src/main/deltachat/webxdc.ts +++ b/src/main/deltachat/webxdc.ts @@ -123,16 +123,38 @@ export default class DCWebxdc extends SplitOut { if (!accounts_sessions.includes(accountId)) { accounts_sessions.push(accountId) ses.protocol.handle('webxdc', async request => { - const get_headers = (mime_type: string | undefined) => { + /** + * Make sure to only `return makeResponse()` because it sets headers + * that are important for security, namely `Content-Security-Policy`. + * Failing to set CSP might result in the app being able to create + * an