gchq/CyberChef · error · OperationError
Invalid input format. Please enter the permissions in either
Error message
Invalid input format. Please enter the permissions in either octal (e.g. 755) or textual (e.g. drwxr-xr-x) format.
What it means
Parse UNIX file permissions accepts two formats: octal (1-4 digits 0-7, e.g. 755) or textual (1-10 chars from the set d,l,p,c,b,D,r,w,x,s,S,t,T,-, e.g. drwxr-xr-x). If the input starts with neither pattern it falls through to the else branch and throws. The matching uses search()===0, so the recognized pattern must appear at the very start of the (optionally whitespace-padded) input.
Source
Thrown at src/core/operations/ParseUNIXFilePermissions.mjs:181
if (textual.length > 7) perms.ro = textual[7] === "r";
if (textual.length > 8) perms.wo = textual[8] === "w";
if (textual.length > 9) {
switch (textual[9]) {
case "x":
perms.eo = true;
break;
case "t":
perms.eo = true;
perms.sb = true;
break;
case "T":
perms.sb = true;
break;
}
}
} else {
throw new OperationError("Invalid input format.\nPlease enter the permissions in either octal (e.g. 755) or textual (e.g. drwxr-xr-x) format.");
}
output += "Textual representation: " + permsToStr(perms);
output += "\nOctal representation: " + permsToOctal(perms);
// File type
if (textual) {
output += "\nFile type: " + ftFromPerms(perms);
}
// setuid, setgid
if (perms.su) {
output += "\nThe setuid flag is set";
}
if (perms.sg) {
output += "\nThe setgid flag is set";
}
View on GitHub (pinned to 4290ea7539)
Solutions
- Enter octal digits 0-7 only (1 to 4 digits), e.g. 755 or 4755.
- Enter a textual permission string using only d l p c b D r w x s S t T - characters, e.g. drwxr-xr-x.
- Trim surrounding prose/columns from an ls -l output and keep only the 10-character permission field.
- Remove BOM/non-breaking spaces and confirm UTF-8 without leading whitespace beyond what the regex allows.
Example fix
// before: pasted full ls line
run("drwxr-xr-x 2 root root 4096");
// after: permission field only
run("drwxr-xr-x"); Defensive patterns
Strategy: validation
Validate before calling
function looksLikePerms(s) {
return /^\s*[0-7]{1,4}\s*$/.test(s) || /^\s*[dlpcbDrwxsStT-]{1,10}\s*$/.test(s);
}
if (!looksLikePerms(input)) throw new Error("Input is not octal or textual UNIX permissions");
return parseUnixFilePermissions.run(input, []); Type guard
function isUnixPermissionString(s) {
return /^\s*[0-7]{1,4}\s*$/.test(s) || /^\s*[dlpcbDrwxsStT-]{1,10}\s*$/.test(s);
} Try / catch
try {
return parseUnixFilePermissions.run(input, []);
} catch (e) {
if (e.message.startsWith("Invalid input format")) {
// show the accepted formats to the user
}
throw e;
} Prevention
- Extract only the permission column from ls -l output.
- Use octal digits 0-7 only for octal mode.
- Avoid 8/9 digits and spaces inside the permission field.
When it happens
Trigger: Input like 'hello', '999' (8/9 are not octal digits), 'rwxrwx' with an invalid character, an embedded space such as 'drwx r-xr-x', an empty string, or data whose first characters are outside both the [0-7] and [dlpcbDrwxsStT-] sets.
Common situations: Pasting an ls -l line including owner/size columns instead of just the permission column; copying a Windows ACL string; trailing BOM or non-breaking spaces; typo'd symbolic permission.
Related errors
- Error: Invalid Base64 input length (${data.length}). Cannot
- Error: Base64 padding character (${pad}) not used in the cor
- Error: Base64 not padded to a multiple of 4.
- Error: Base64 input contains non-alphabet char(s)
- Invalid value
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/6d6d80401a1f1f38.
Report an issue: GitHub.