gchq/CyberChef · error · OperationError

Invalid hexadecimal input. Please provide valid hex characte

Error message

Invalid hexadecimal input. Please provide valid hex characters only.

What it means

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.

Source

Thrown at src/core/operations/DisassembleARM.mjs:83

     * @param {Object[]} args
     * @returns {string}
     */
    async run(input, args) {
        const [
            architecture,
            mode,
            endianness,
            startAddress,
            showHex,
            showPosition
        ] = args;

        // Remove whitespace from input
        const hexInput = input.replace(/\s/g, "");

        // Validate hex input
        if (!/^[0-9a-fA-F]*$/.test(hexInput)) {
            throw new OperationError("Invalid hexadecimal input. Please provide valid hex characters only.");
        }

        if (hexInput.length === 0) {
            return "";
        }

        if (hexInput.length % 2 !== 0) {
            throw new OperationError("Invalid hexadecimal input. Length must be even.");
        }

        // Convert hex string to byte array
        const bytes = [];
        for (let i = 0; i < hexInput.length; i += 2) {
            bytes.push(parseInt(hexInput.substr(i, 2), 16));
        }

        // Determine architecture constant
        let arch;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Strip everything except hex digits (remove '0x' prefixes, comments, mnemonics, addresses).
  2. If the source is base64 or raw binary, run From Base64 or From Binary first to get hex.
  3. Re-extract the bytes with a hexdump tool and paste the continuous hex string.
  4. Replace stray letters (O->0, l->1) before disassembling.

Example fix

// before
0x: 90 00 00 14   // contains 'x', ':', spaces ok but 'x' invalid

// after
90000014          // pure hex, whitespace already stripped
Defensive patterns

Strategy: validation

Validate before calling

function isPureHex(s) {
    return /^[0-9a-fA-F]*$/.test(String(s).replace(/\s/g, ""));
}

Type guard

/** @returns {boolean} */
function isPureHexString(s) {
    return typeof s === "string" && /^[0-9a-fA-F]*$/.test(s.replace(/\s/g, ""));
}

Try / catch

try {
    out = disassembleArm.run(input, args);
} catch (e) {
    if (e instanceof OperationError && /valid hex characters only/.test(e.message)) {
        // strip 0x prefixes / comments, or decode from base64/binary first
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/22cb2885cf85f424. Report an issue: GitHub.