{"record":{"id":"22cb2885cf85f424","repo":"gchq/CyberChef","slug":"invalid-hexadecimal-input-please-provide-valid-he","errorCode":null,"errorMessage":"Invalid hexadecimal input. Please provide valid hex characters only.","messagePattern":"Invalid hexadecimal input\\. Please provide valid hex characters only\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/DisassembleARM.mjs","lineNumber":83,"sourceCode":"     * @param {Object[]} args\n     * @returns {string}\n     */\n    async run(input, args) {\n        const [\n            architecture,\n            mode,\n            endianness,\n            startAddress,\n            showHex,\n            showPosition\n        ] = args;\n\n        // Remove whitespace from input\n        const hexInput = input.replace(/\\s/g, \"\");\n\n        // Validate hex input\n        if (!/^[0-9a-fA-F]*$/.test(hexInput)) {\n            throw new OperationError(\"Invalid hexadecimal input. Please provide valid hex characters only.\");\n        }\n\n        if (hexInput.length === 0) {\n            return \"\";\n        }\n\n        if (hexInput.length % 2 !== 0) {\n            throw new OperationError(\"Invalid hexadecimal input. Length must be even.\");\n        }\n\n        // Convert hex string to byte array\n        const bytes = [];\n        for (let i = 0; i < hexInput.length; i += 2) {\n            bytes.push(parseInt(hexInput.substr(i, 2), 16));\n        }\n\n        // Determine architecture constant\n        let arch;","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/DisassembleARM.mjs#L65-L101","documentation":"Thrown by Disassemble ARM run() when, after stripping all whitespace from the input, the remaining characters are not all hexadecimal ([0-9a-fA-F]). ARM disassembly expects machine code as a hex string; any non-hex character (letter g-z, punctuation, O/0 confusion producing an O) causes this. The check runs before byte conversion and before length/parity checks.","triggerScenarios":"Input containing characters outside 0-9 a-f A-F after whitespace removal: raw binary pasted as text, a base64 string fed without decoding, a disassembly listing pasted (mnemonics + spaces), 'O' instead of '0', 'l' instead of '1', trailing 'h'/'0x' prefixes, or comment text.","commonSituations":"Pasting a capstone/objdump listing instead of raw hex; forgetting to convert from base64/binary; including '0x' prefixes per instruction; OCR errors (O vs 0); pasting text that includes the architecture name as a label.","solutions":["Strip everything except hex digits (remove '0x' prefixes, comments, mnemonics, addresses).","If the source is base64 or raw binary, run From Base64 or From Binary first to get hex.","Re-extract the bytes with a hexdump tool and paste the continuous hex string.","Replace stray letters (O->0, l->1) before disassembling."],"exampleFix":"// before\n0x: 90 00 00 14   // contains 'x', ':', spaces ok but 'x' invalid\n\n// after\n90000014          // pure hex, whitespace already stripped","handlingStrategy":"validation","validationCode":"function isPureHex(s) {\n    return /^[0-9a-fA-F]*$/.test(String(s).replace(/\\s/g, \"\"));\n}","typeGuard":"/** @returns {boolean} */\nfunction isPureHexString(s) {\n    return typeof s === \"string\" && /^[0-9a-fA-F]*$/.test(s.replace(/\\s/g, \"\"));\n}","tryCatchPattern":"try {\n    out = disassembleArm.run(input, args);\n} catch (e) {\n    if (e instanceof OperationError && /valid hex characters only/.test(e.message)) {\n        // strip 0x prefixes / comments, or decode from base64/binary first\n    } else throw e;\n}","preventionTips":["Feed only continuous hex digits (0-9, a-f).","Remove '0x' prefixes, addresses, mnemonics, and comments from listings before pasting.","If the source is base64 or raw binary, convert to hex first.","Watch for O/0 and l/1 confusions from OCR or copy-paste."],"tags":["disassembly","arm","hex","validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}