gchq/CyberChef · error · OperationError
Invalid input format.
Error message
Invalid input format.
What it means
The Parse SSH Host Key operation's convertKeyToBinary method accepts 'Auto', 'Hex', or 'Base64' as the input format. After auto-detection resolves to a concrete format, only 'Hex' and 'Base64' are handled. This else-branch fires for any unrecognized format string. Since the UI dropdown constrains to three options, this only triggers with programmatic or hand-edited recipes.
Source
Thrown at src/core/operations/ParseSSHHostKey.mjs:107
* @returns {byteArray}
*/
convertKeyToBinary(inputKey, inputFormat) {
const keyPattern = new RegExp(/^(?:ssh|ecdsa-sha2)\S+\s+(\S*)/),
keyMatch = inputKey.match(keyPattern);
if (keyMatch) {
inputKey = keyMatch[1];
}
if (inputFormat === "Auto") {
inputFormat = this.detectKeyFormat(inputKey);
}
if (inputFormat === "Hex") {
return fromHex(inputKey);
} else if (inputFormat === "Base64") {
return fromBase64(inputKey, null, "byteArray");
} else {
throw new OperationError("Invalid input format.");
}
}
/**
* Detects if the key is base64 or hex encoded
*
* @param {string} inputKey
* @returns {string}
*/
detectKeyFormat(inputKey) {
const hexPattern = new RegExp(/^(?:[\dA-Fa-f]{2}[ ,;:]?)+$/);
const b64Pattern = new RegExp(/^\s*(?:[A-Za-z\d+/]{4})+(?:[A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?\s*$/);
if (hexPattern.test(inputKey)) {
return "Hex";
} else if (b64Pattern.test(inputKey)) {
return "Base64";View on GitHub (pinned to 4290ea7539)
Solutions
- Set the 'Input Format' argument to 'Auto', 'Base64', or 'Hex'
- Validate the format argument programmatically before recipe execution
Defensive patterns
Strategy: validation
Validate before calling
const VALID_FORMATS = ["Auto", "Base64", "Hex"];
if (!VALID_FORMATS.includes(args[0])) {
throw new Error(`Input format must be one of: ${VALID_FORMATS.join(", ")}`);
} Type guard
function isSshKeyFormat(v) {
return v === "Auto" || v === "Base64" || v === "Hex";
} Prevention
- Validate format arguments programmatically against the allowed values before recipe execution
When it happens
Trigger: args[0] (inputFormat) is a string that is not 'Auto', 'Hex', or 'Base64' and does not resolve to either after detection. Occurs with a typo in a programmatically constructed recipe, or a hand-edited recipe JSON with an invalid format value.
Common situations: Recipe JSON is hand-edited with a misspelled format value. Recipe is built programmatically with an unvalidated format string. Recipe is copied from a different version or tool.
Related errors
- Invalid input format selected.
- Unrecognised input format.
- Unable to detect input key format.
- Unrecognised input format.
- Unsupported QR code format.
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/05f91d5730f8255e.
Report an issue: GitHub.