loop-engineering icon indicating copy to clipboard operation
loop-engineering copied to clipboard

loop-gate: missing --paths value can incorrectly return ALLOWED

Open lhy-dcf opened this issue 3 weeks ago • 0 comments

Proposed Title

loop-gate: missing --paths value can incorrectly return ALLOWED

Problem

The CLI consumes the next argv token as the value of --paths without checking whether it is another option. An incomplete invocation such as:

loop-gate check --action commit --paths --json

evaluates the literal string --json as a changed path and exits 0 with ALLOWED [ok], rather than reporting missing paths. The JSON switch is also swallowed. --gate-file, --help, and -h are similarly accepted as paths.

Reproduction

Use a valid gate.yaml with a denylist such as auth/**. From its directory, run the command above with the built CLI. No real changed-file path is provided, yet the gate clears it. A normal --paths auth/login.ts --json control correctly escalates with exit 2; trailing --paths without another token already errors, so the defect is the option/value boundary, not the policy checks.

Expected: exit 1 with a missing --paths value diagnostic and no allowed decision on stdout. This is a caller-controlled CLI input-validation defect, not evidence that an attacker can bypass a correctly invoked policy check.

Bounded Fix and Validation

Reject absent/option-looking tokens at the --paths parser boundary. Preserve policy/schema/glob behavior; option-like real filenames can be unambiguously passed as ./--json.

Four real CLI regressions fail before the fix (exit 0 instead of 1); a positive ./--json case succeeds. Full baseline: 32/32. After the fix, CLI tests pass 16/16 and full npm test passes 37/37 with none skipped. Windows/Node 22.16.0 only. No issue is published and no CI result is claimed.

lhy-dcf avatar Nov 08 '26 10:11 lhy-dcf