From 262cc8936e977ad563fb32b1db19703b924a3ff2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 13 Nov 2020 19:10:04 +0100 Subject: [PATCH] don't leak mimetype for encrypted attachments --- src/matrix/e2ee/attachment.js | 2 +- src/matrix/room/AttachmentUpload.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/matrix/e2ee/attachment.js b/src/matrix/e2ee/attachment.js index 105c16c5..3ead83eb 100644 --- a/src/matrix/e2ee/attachment.js +++ b/src/matrix/e2ee/attachment.js @@ -65,7 +65,7 @@ export async function encryptAttachment(platform, blob) { const ciphertext = await crypto.aes.encryptCTR({jwkKey: key, iv, data: buffer}); const digest = await crypto.digest("SHA-256", ciphertext); return { - blob: platform.createBlob(ciphertext, blob.mimeType), + blob: platform.createBlob(ciphertext, 'application/octet-stream'), info: { v: "v2", key, diff --git a/src/matrix/room/AttachmentUpload.js b/src/matrix/room/AttachmentUpload.js index 5dd957a0..356bb5a7 100644 --- a/src/matrix/room/AttachmentUpload.js +++ b/src/matrix/room/AttachmentUpload.js @@ -98,10 +98,10 @@ export class AttachmentUpload { } let prefix = urlPath.substr(0, urlPath.lastIndexOf("url")); setPath(`${prefix}info.size`, content, this._transferredBlob.size); - setPath(`${prefix}info.mimetype`, content, this._unencryptedBlob.mimeType); + setPath(`${prefix}info.mimetype`, content, this._transferredBlob.mimeType); if (this._isEncrypted) { setPath(`${prefix}file`, content, Object.assign(this._encryptionInfo, { - mimetype: this._unencryptedBlob.mimeType, + mimetype: this._transferredBlob.mimeType, url: this._mxcUrl })); } else {