affaan-m/ECC · error · Error

Arguments must not contain NUL bytes.

Error message

Arguments must not contain NUL bytes.

What it means

validateArgv iterates every argument token after the executable and rejects any containing a NUL (\0) byte. Same rationale as the cwd and executable NUL checks: NULs can truncate argv at the OS boundary and enable injection. Called from parseArgs after validateExecutable.

Source

Thrown at skills/terminal-opener/scripts/open-terminal.js:76

  const firstSeparatorIndex = separatorIndexes.length > 0 ? Math.min(...separatorIndexes) : -1;
  const resemblesExecutablePath = isAbsolutePath(value)
    || (firstSeparatorIndex >= 0 && (whitespaceIndex < 0 || firstSeparatorIndex < whitespaceIndex));

  if (whitespaceIndex >= 0 && !resemblesExecutablePath) {
    throw new Error(
      'Executable must be one argv entry, not an interpolated shell command string.'
    );
  }
  if (!resemblesExecutablePath && /[;&|<>`$]/.test(value)) {
    throw new Error(
      'Executable must be one argv entry, not an interpolated shell command string.'
    );
  }
}

function validateArgv(argv) {
  for (const argument of argv) {
    if (argument.includes('\0')) throw new Error('Arguments must not contain NUL bytes.');
  }
}

function readValue(argv, index, option) {
  const value = argv[index + 1];
  if (value === undefined || value.startsWith('--')) {
    throw new Error(`Missing value for ${option}.`);
  }
  return value;
}

function parseArgs(argv, context = {}) {
  const env = context.env || process.env;
  const initialTerminal = env.ECC_TERMINAL || DEFAULT_TERMINAL;
  const initialCwd = context.cwd || process.cwd();
  const options = {
    argv: [],
    cwd: initialCwd,

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Strip NUL bytes from each argument before passing.
  2. Validate arguments sourced from untrusted input.

Example fix

// before
const args = rawUserArgs; // may contain \0
parseArgs(['--', 'echo', ...args]);

// after
const args = rawUserArgs.map(a => a.replace(/\0/g, ''));
parseArgs(['--', 'echo', ...args]);
Defensive patterns

Strategy: validation

Validate before calling

function sanitizeArgv(argv) {
  return argv.map(arg => {
    if (typeof arg !== 'string' || arg.includes('\0')) {
      throw new Error('Argument contains a NUL byte or is not a string');
    }
    return arg;
  });
}

Prevention

When it happens

Trigger: Any element of options.argv (the tokens after the executable) contains \0. parseArgs calls validateArgv near the end of parsing.

Common situations: Binary or corrupted argument values; untrusted input forwarded into an argument; a fixture containing raw bytes.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/3e28f5f6337e3f8c. Report an issue: GitHub.