diff --git a/packages/core/src/utils/crypto.ts b/packages/core/src/utils/crypto.ts index b02b00f1..507ac5f3 100644 --- a/packages/core/src/utils/crypto.ts +++ b/packages/core/src/utils/crypto.ts @@ -114,6 +114,9 @@ export function decryptString(data: string, secretKey?: Buffer): Response { secretKey = Buffer.from(Env.SECRET_KEY, 'hex'); } try { + if (!isEncrypted(data)) { + throw new Error('The data was not in an expected encrypted format'); + } const [_, ivHex, encryptedHex] = decodeURIComponent(data).split(':'); const iv = Buffer.from(ivHex, 'base64'); const encrypted = Buffer.from(encryptedHex, 'base64');