gchq/CyberChef · error · OperationError

Invalid UUID

Error message

Invalid UUID

What it means

Thrown by AnalyseUUID.run when the uuid library's uuid.version(input) or uuid.parse(input) throws during parsing of the trimmed input string. The operation extracts version metadata and bytes from a UUID, so any value that is not a syntactically valid RFC-4122 UUID (8-4-4-4-12 hex layout) is rejected. Both the parse and the version lookup are wrapped in one try/catch, so the failure is reported uniformly as 'Invalid UUID'.

Source

Thrown at src/core/operations/AnalyseUUID.mjs:53

                value: true
            }
        ];
    }

    /**
     * @param {string} input - Expects a valid UUID string
     * @param {Object[]} args
     * @returns {string}
     */
    run(input, args) {
        input = input.trim();

        let uuidVersion, uuidBytes;
        try {
            uuidVersion = uuid.version(input); // Re-using the uuid library to extract version
            uuidBytes = uuid.parse(input);     // Re-using the uuid library to parse bytes
        } catch (error) {
            throw new OperationError("Invalid UUID");
        }

        const [includeMetadata] = args;
        const dv = new DataView(uuidBytes.buffer, uuidBytes.byteOffset, uuidBytes.byteLength); // Dataview helps handle the multi-byte ints
        const uuidInteger = (dv.getBigUint64(0) << 64n) | dv.getBigUint64(8);

        const sections = [`Version:\n${uuidVersion}`];

        if (includeMetadata) {
            const parser = UUID_PARSERS[uuidVersion];
            const decoded = parser?.(uuidBytes, dv);
            sections.push(formatDecoded(decoded));
        }

        sections.push(`UUID Integer:\n${uuidInteger}`);

        return sections.filter(Boolean).join("\n\n");
    }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Provide the UUID in canonical 8-4-4-4-12 hex form, e.g. 123e4567-e89b-12d3-a456-426614174000.
  2. Remove surrounding braces, 'urn:uuid:' prefixes, or whitespace.
  3. Validate format upstream with a regex before calling AnalyseUUID.

Example fix

// before
chef.analyseUUID("123e4567e89b12d3a456426614174000"); // missing dashes

// after
chef.analyseUUID("123e4567-e89b-12d3-a456-426614174000");
Defensive patterns

Strategy: validation

Validate before calling

const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
function assertUUID(s) {
  const v = String(s).trim();
  if (!UUID_RE.test(v)) throw new Error("Not a valid RFC-4122 UUID");
  return v;
}
assertUUID(input);

Type guard

function isUUID(s) {
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(String(s).trim());
}

Prevention

When it happens

Trigger: Input missing dashes, with wrong dash placement, wrong length, non-hex characters, an empty string, or a URN/braced format the parser rejects (e.g. 'urn:uuid:...' or '{...}' depending on uuid version).

Common situations: User pastes a GUID with spaces or wrong grouping; copies only the first segment; supplies a ULID or other non-UUID identifier; upstream operation truncates the value.

Related errors


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