Skip to content

Path-target preflight accepts special files that scan setup later rejects #548

Description

@sylvesterkaczmarek

Summary

Path-target normalization checks that a selected path exists and remains inside the repository, but does not require the target to be a regular file or directory.

On POSIX, a FIFO, Unix-domain socket, or other special filesystem node can therefore pass local SDK/CLI preflight even though the bundled scan scope resolver later accepts only files and directories.

Reproduction / evidence

Current upstream main at 37bf87a692fc72d41f7312cc48808d699d204fba handles each path target in src/targets.ts by:

  1. checking existsSync(candidate);
  2. resolving it with realpath();
  3. checking repository containment;
  4. returning the repository-relative path.

There is no file-type check.

A deterministic POSIX reproduction uses a Unix-domain socket inside a repository directory:

const server = createServer();
await listen(server, socketPath);
await normalizeTarget(repository, [socketPath]);

Current main accepts the socket as a paths target.

The bundled generate_rank_input.py scope resolver later does:

if not scope_path.is_dir() and not scope_path.is_file():
    raise SystemExit(f"Scope path not found: {scope_path}")

so the same target cannot actually be scanned.

The public SDK documentation describes security.preflight() as validating local inputs without starting the runtime, which makes this mismatch observable before scan execution should begin.

Expected behavior

Path-target normalization should accept only canonical paths whose resolved target is a regular file or directory. Special filesystem nodes should fail local preflight with an InvalidTargetError.

Root cause

Existence and containment were validated, but filesystem type was not. The later bundled helper independently enforces the missing invariant.

Suggested fix

After resolving the candidate, stat() the canonical path and require isFile() || isDirectory() before returning the normalized target.

Add a POSIX regression using a Unix-domain socket inside the repository and keep ordinary file/directory path-target coverage unchanged.

Impact

This is a preflight/reliability bug. Invalid local targets can survive the SDK/CLI validation stage and fail only after the scan runtime/setup path is entered, defeating the purpose of local preflight and producing a later, less accurate scope error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions