{"record":{"id":"c534557a06d9984f","repo":"gchq/CyberChef","slug":"invalid-file-type-c53455","errorCode":null,"errorMessage":"Invalid file type.","messagePattern":"Invalid file type\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/BlurImage.mjs","lineNumber":56,"sourceCode":"            },\n            {\n                name: \"Type\",\n                type: \"option\",\n                value: [\"Fast\", \"Gaussian\"],\n            },\n        ];\n    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {byteArray}\n     */\n    async run(input, args) {\n        const [blurAmount, blurType] = args;\n\n        if (!isImage(input)) {\n            throw new OperationError(\"Invalid file type.\");\n        }\n\n        let image;\n        try {\n            image = await Jimp.read(input);\n        } catch (err) {\n            throw new OperationError(`Error loading image. (${err})`);\n        }\n        try {\n            switch (blurType) {\n                case \"Fast\":\n                    if (isWorkerEnvironment())\n                        self.sendStatusMessage(\"Fast blurring image...\");\n                    image.blur(blurAmount);\n                    break;\n                case \"Gaussian\":\n                    if (isWorkerEnvironment())\n                        self.sendStatusMessage(\"Gaussian blurring image...\");","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/BlurImage.mjs#L38-L74","documentation":"BlurImage runs an isImage() check on the input ArrayBuffer before processing. If the bytes are not recognized as a supported image type it throws 'Invalid file type.' immediately, before Jimp is invoked.","triggerScenarios":"Calling BlurImage.run with an input ArrayBuffer whose magic bytes are not a supported image format (e.g. a text file, PDF, or corrupted header).","commonSituations":"Piping non-image data into the operation; uploading the wrong file; truncated download whose magic bytes are gone; a format isImage() does not recognize.","solutions":["Confirm the input is a supported image (PNG/JPEG/BMP/etc.) by checking magic bytes before invoking.","Re-fetch or re-export the file if it may be truncated.","Route non-image files to the correct operation instead of BlurImage."],"exampleFix":"// before\nBlurImage.run(textBuffer, args)\n// after\nBlurImage.run(pngBuffer, args)","handlingStrategy":"type-guard","validationCode":"if (!isImage(input)) throw new Error('Input is not a supported image');","typeGuard":"function isLikelyImage(buf) { return isImage(buf) !== false; }","tryCatchPattern":"try { blurImage.run(input, args); }\ncatch (e) { if (/Invalid file type/.test(e.message)) { /* route to correct op */ } else throw e; }","preventionTips":["Check magic bytes (PNG/JPEG/BMP/GIF) before invoking.","Validate file type at the upload boundary.","Do not chain arbitrary operations into image operations."],"tags":["image","validation","file-type","blur"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}