From f3603f08b69a27dd2bdb5df045542e598125d023 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 17 Jan 2022 13:26:03 -0400 Subject: [PATCH] Validate fetch of encrypted backup from gun --- src/routes.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/routes.js b/src/routes.js index ab8ca6c5..c467cbd3 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1955,6 +1955,11 @@ module.exports = async ( const SEA = require('../services/gunDB/Mediator').mySEA const mySecret = require('../services/gunDB/Mediator').getMySecret() const encBackup = await user.get(Key.CHANNELS_BACKUP).then() + if (typeof encBackup !== 'string') { + throw new TypeError( + 'Encrypted backup fetched from gun not an string.' + ) + } const backup = await SEA.decrypt(encBackup, mySecret) logger.info(backup) res.json({ data: backup })