gchq/CyberChef · error · OperationError

Invalid size

Error message

Invalid size

What it means

Thrown by the SHA3 operation when the parsed size is not one of 224, 256, 384, or 512. The Size argument is a fixed option dropdown (['512','384','256','224']), so through the UI this is unreachable; it only fires when the operation is invoked programmatically with an invalid size.

Source

Thrown at src/core/operations/SHA3.mjs:60

    run(input, args) {
        const size = parseInt(args[0], 10);
        let algo;

        switch (size) {
            case 224:
                algo = JSSHA3.sha3_224;
                break;
            case 384:
                algo = JSSHA3.sha3_384;
                break;
            case 256:
                algo = JSSHA3.sha3_256;
                break;
            case 512:
                algo = JSSHA3.sha3_512;
                break;
            default:
                throw new OperationError("Invalid size");
        }

        return algo(input);
    }

}

export default SHA3;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set Size to one of: 224, 256, 384, or 512.
  2. If sourcing the size dynamically, validate parseInt(args[0]) is in [224,256,384,512] before calling.

Example fix

// before
sha3.run(buf, ["1024"])
// after
sha3.run(buf, ["512"])
Defensive patterns

Strategy: validation

Validate before calling

const VALID_SHA3 = [224, 256, 384, 512];
const size = parseInt(sizeArg, 10);
if (!VALID_SHA3.includes(size)) {
  throw new Error(`SHA3 size must be one of ${VALID_SHA3.join(", ")}`);
}

Type guard

function isSha3Size(v) {
  return [224, 256, 384, 512].includes(parseInt(v, 10));
}

Prevention

When it happens

Trigger: Calling SHA3.run(input, ['1024']) or any args[0] that parseInt to a value outside the supported set. A non-numeric string like 'abc' parseInts to NaN and also hits the default.

Common situations: Node API usage with a hand-built args array; a recipe export from a modified/forked CyberChef that added a size value; integration code that reads size from user input without validation.

Related errors


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