{"record":{"id":"df40b25676e2f9fb","repo":"gchq/CyberChef","slug":"invalid-input-enter-either-a-cidr-range-e-g-10","errorCode":null,"errorMessage":"Invalid input.\n\nEnter either a CIDR range (e.g. 10.0.0.0/24) or a hyphenated range (e.g. 10.0.0.0 - 10.0.1.0). IPv6 also supported.","messagePattern":"Invalid input\\.\n\nEnter either a CIDR range \\(e\\.g\\. 10\\.0\\.0\\.0/24\\) or a hyphenated range \\(e\\.g\\. 10\\.0\\.0\\.0 - 10\\.0\\.1\\.0\\)\\. IPv6 also supported\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ParseIPRange.mjs","lineNumber":82,"sourceCode":"            ipv6CidrRegex = /^\\s*(((?=.*::)(?!.*::.+::)(::)?([\\dA-F]{1,4}:(:|\\b)|){5}|([\\dA-F]{1,4}:){6})((([\\dA-F]{1,4}((?!\\4)::|:\\b|(?![\\dA-F])))|(?!\\3\\4)){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4}))\\/(\\d\\d?\\d?)\\s*$/i,\n            ipv6RangeRegex = /^\\s*(((?=.*::)(?!.*::[^-]+::)(::)?([\\dA-F]{1,4}:(:|\\b)|){5}|([\\dA-F]{1,4}:){6})((([\\dA-F]{1,4}((?!\\4)::|:\\b|(?![\\dA-F])))|(?!\\3\\4)){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4}))\\s*-\\s*(((?=.*::)(?!.*::.+::)(::)?([\\dA-F]{1,4}:(:|\\b)|){5}|([\\dA-F]{1,4}:){6})((([\\dA-F]{1,4}((?!\\17)::|:\\b|(?![\\dA-F])))|(?!\\16\\17)){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4}))\\s*$/i,\n            ipv6ListRegex = /^\\s*((((?=.*::)(?!.*::.+::)(::)?([\\dA-F]{1,4}:(:|\\b)|){5}|([\\dA-F]{1,4}:){6})((([\\dA-F]{1,4}((?!\\4)::|:\\b|(?![\\dA-F])))|(?!\\3\\4)){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4}))(\\/(\\d\\d?\\d?))?(\\n|$)(\\n*))+\\s*$/i;\n        let match;\n\n        if ((match = ipv4CidrRegex.exec(input))) {\n            return ipv4CidrRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);\n        } else if ((match = ipv4RangeRegex.exec(input))) {\n            return ipv4HyphenatedRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);\n        } else if ((match = ipv4ListRegex.exec(input))) {\n            return ipv4ListedRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);\n        } else if ((match = ipv6CidrRegex.exec(input))) {\n            return ipv6CidrRange(match, includeNetworkInfo);\n        } else if ((match = ipv6RangeRegex.exec(input))) {\n            return ipv6HyphenatedRange(match, includeNetworkInfo);\n        } else if ((match = ipv6ListRegex.exec(input))) {\n            return ipv6ListedRange(match, includeNetworkInfo);\n        } else {\n            throw new OperationError(\"Invalid input.\\n\\nEnter either a CIDR range (e.g. 10.0.0.0/24) or a hyphenated range (e.g. 10.0.0.0 - 10.0.1.0). IPv6 also supported.\");\n        }\n    }\n\n}\n\n\nexport default ParseIPRange;\n","sourceCodeStart":64,"sourceCodeEnd":90,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ParseIPRange.mjs#L64-L90","documentation":"The Parse IP Range operation tries six regex patterns (IPv4 CIDR, IPv4 hyphenated, IPv4 list, IPv6 CIDR, IPv6 hyphenated, IPv6 list) against the input. If none match, the input does not conform to any supported IP range format.","triggerScenarios":"Input contains typos in IP addresses (e.g., 10.0.0.256/24 with an octet > 255). Unsupported separators (commas instead of newlines in a list). Mixed IPv4 and IPv6 in a single range expression. CIDR prefix out of range (e.g., /33 for IPv4). Leading/trailing junk text around the address.","commonSituations":"User enters a comma-separated list of IPs (only newline-separated lists are supported). User enters a single IP without a range qualifier. User mixes formats. User pastes with surrounding whitespace or quotes that break the anchored regexes.","solutions":["Use a supported format: CIDR (10.0.0.0/24), hyphenated range (10.0.0.0-10.0.1.0), or newline-separated list","For IP lists, separate entries with newlines, not commas","Trim surrounding whitespace and quotes from the input","Ensure octets are 0-255 and CIDR prefixes are valid (0-32 for IPv4, 0-128 for IPv6)"],"exampleFix":"// before: \"10.0.0.0/24, 10.0.1.0/24\" (commas not supported)\n// after:  \"10.0.0.0/24\\n10.0.1.0/24\" (newline-separated list)","handlingStrategy":"validation","validationCode":"// Pre-check: does the input match any supported IP range format?\nconst patterns = [\n  /^\\s*((?:\\d{1,3}\\.){3}\\d{1,3})\\/(\\d\\d?)\\s*$/,                    // IPv4 CIDR\n  /^\\s*((?:\\d{1,3}\\.){3}\\d{1,3})\\s*-\\s*((?:\\d{1,3}\\.){3}\\d{1,3})\\s*$/, // IPv4 range\n];\nif (!patterns.some(re => re.test(input))) {\n  throw new Error(\"Input does not match a supported IP range format.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = chef.parseIPRange(input, [true, true, false]);\n} catch (e) {\n  if (/Invalid input/i.test(e.message)) {\n    console.error(\"Use CIDR (10.0.0.0/24), hyphenated (10.0.0.0-10.0.1.0), or newline-separated list\");\n  } else { throw e; }\n}","preventionTips":["Use newline separators for IP lists, not commas","Ensure octets are 0-255 and CIDR prefixes are within range","Trim whitespace and quotes from the input"],"tags":["ip","network","parsing","regex","validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}