Repository navigation
Description
[Bug]: the loopx check directory boundary scan skips all text outside a seven-suffix allow-list
Preflight
- I searched existing issues and discussions for this behavior. I searched open and closed issues and open PRs for
loopx check,scan-path,public boundary,boundary scan suffix,DEFAULT_SCAN_SUFFIXESandloopx/contract.py. I found the closed credential-shape reports [Bug]: the presentation public-boundary scan certifies unlabeled GitHub, AWS, Slack, Google, Stripe, npm, PyPI and JWT credentials as public-safe #7727/[Bug]: the presentation public-boundary scan certifies unlabeled OpenAI and Anthropic API keys as public-safe #7799 and the sibling presentation-packaging suffix gap [Bug]: static presentation packaging certifies text assets outside its eight-suffix allow-list without scanning them #9405/fix(presentation): scan every static-site text asset and fail closed on unreviewable text #9406 (different owner: static-site packaging). No report or PR covers directory text selection inloopx check. - This report is not an unpatched security vulnerability: it is a local public-boundary correctness defect reproduced with synthetic token shapes and a prepared fix, following the public disclosure pattern already used for [Bug]: the presentation public-boundary scan certifies unlabeled GitHub, AWS, Slack, Google, Stripe, npm, PyPI and JWT credentials as public-safe #7727, [Bug]: the presentation public-boundary scan certifies unlabeled OpenAI and Anthropic API keys as public-safe #7799 and [Bug]: static presentation packaging certifies text assets outside its eight-suffix allow-list without scanning them #9405.
- The report contains no credentials or private material: only a synthetic token shape and
<tmp>placeholders.
Issue origin: Observed or reproduced in a real environment.
Impact / 影响
loopx check --scan-path <directory> is the repository's documented pre-publication boundary gate: CONTRIBUTING's safe-contribution section, the full check series in AGENTS.md (loopx check --scan-path loopx/ --scan-path tests/ --scan-path examples/ --scan-path docs/), and docs/public-private-boundary.md all rely on it. Directory candidates are selected by _resolve_scannable_file in loopx/contract.py with a seven-entry suffix allow-list (.md, .py, .toml, .json, .yaml, .yml, .sh). Every other file is dropped before it is opened, and the command still prints public boundary scan clean: N files with no skipped count and no warning.
At 216757852 (LoopX 2.4.1), 2,745 of the 8,647 tracked files (31.7%) decode as UTF-8 text yet are excluded: 1,564 .ts, 470 .mjs, 292 .tsx, 92 .svg, 68 .css, 66 .html, 64 .txt, 12 .js, 38 extensionless, and the rest. Within the documented four-root scan, 1,081 tracked text files are skipped: 440 under loopx/ (436 of them TypeScript), 444 under tests/, 150 under examples/, 47 under docs/. That contradicts docs/public-private-boundary.md:259-261, which states a git-tracked file "enters the public boundary and is scanned like any other publishable file".
The same bytes receive opposite verdicts depending on the input shape. A synthetic provider token in notes.txt is invisible when the operator scans its directory and is rejected when the operator names the file directly. For a real credential the consequence is publication, and disclosure is irreversible until rotation. This is silent: the clean receipt does not say that 31.7% of the selected tree was never opened.
Minimal reproduction / 最小复现
On upstream/main 216757852 (LoopX 2.4.1), from a source checkout with uv sync --extra test:
tmp="$(mktemp -d)"
printf '# clean\n' > "$tmp/README.md"
python - "$tmp" <<'PY'
from pathlib import Path
import sys
root = Path(sys.argv[1])
token = "ghp_" + "A" * 36
(root / "notes.txt").write_text(f"token: {token}\n", encoding="utf-8")
PY
loopx check --scan-path "$tmp"
loopx check --scan-path "$tmp/notes.txt"Replacing loopx check with uv run --extra test loopx check works the same from the checkout.
The token above is a synthetic shape; no live credential is used. A generated .ts module or index.html carrying the same token behaves identically to notes.txt.
Expected behavior
A directory passed to --scan-path is a request to review the outgoing text under that path. Every non-binary text file under it — whatever its suffix and including extensionless files such as LICENSE or Makefile — should be read with the active leak rules. Binary media should stay skipped. A file that cannot be decoded should be reported unreadable (fail closed), never passed as clean. The verdict for the same bytes must not depend on whether the operator named the file or its directory.
Actual behavior
_resolve_scannable_file asks whether the suffix is in the seven-entry allow-list. A file that fails that test returns None before any read; iter_scan_files never yields it, scan_public_boundary never counts it, and the report prints a clean boundary receipt. Naming the same file directly takes a separate path in iter_scan_files (explicit file → always returned) and produces notes.txt:1: credential. The selector is a policy decision about file types, not a property of the content, so the gap persists for every run.
Why this is high importance / 重要性论证
- Affected surface:
loopx checkis the one command the repository tells contributors and agents to run before publishing docs, examples and code. Its clean receipt is treated as the boundary evidence. - Who pays: every operator or agent following CONTRIBUTING/AGENTS.md over a directory — including the repository's own four-root command — and every reader of a published artifact that carries a leaked token, private path or private document link. The 436 skipped TypeScript files under
loopx/are shipped runtime source, not fixtures. - Severity: the failure mode is a false negative on a security boundary. A leaked provider token is unrecoverable after publication except by rotation, and the receipt is silent about the skip, so nobody knows to re-check.
- Persistent and worsening: the policy applies to every run and every host. The TypeScript migration keeps adding
.tsfiles that this gate will never read; the count grows with normal development. - Evidence: the two-command reproduction above shows the same token silently passed for the directory and rejected for the file. The tracked-file census and the four-root counts are reproducible from
git ls-filesat the named commit.
Root cause
loopx/contract.py selected directory candidates with DEFAULT_SCAN_SUFFIXES, a seven-entry allow-list chosen when the scanner handled a smaller tree. It was never widened as the repository added .ts, .tsx, .mjs, .html, .txt, .svg and extensionless text files, and its failure mode is a silent skip rather than an error. iter_scan_files's explicit-file path and the directory path therefore disagree about the same file.
Fix / boundary
Replace the suffix allow-list with a deny-list of known binary media suffixes and read every other candidate as strict UTF-8. An unlisted suffix that cannot be decoded is reported unreadable (fail closed), so an incomplete deny-list cannot become a silent skip. Symlink eligibility continues to follow the resolved target, never the alias name; the .local.json name rule is unchanged. The change is limited to BINARY_MEDIA_SUFFIXES, _is_binary_media_path, _resolve_scannable_file, one enumeration test updated from the retired allow-list semantics to binary media, and two expectations that named pyvenv.cfg as unscannable.
Boundary / 边界
The sibling suffix allow-list in the presentation packaging path is a different owner and remains out of scope (#9405/#9406). Binary media remains skipped, and no report field changes for a clean scan. The credential pattern and its blocking cases are unchanged; the reference classifier additionally recognizes a bare ${ template expression as a runtime value (a literal token cannot start with ${). Two workbench fixtures that the wider scan now reaches were normalized in the PR: the fake-Codex payload emits null for an agent-approved review, and one app-link fixture uses a reserved example host. The repository's documented four-root scan at the fix head reads 5,567 files instead of 4,485 and still reports zero blocking hits; the bare default scan is also green after those normalizations.
Environment
- LoopX version or commit:
2.4.1/216757852 - Host or runtime surface: not host-specific (
loopx checkCLI); reproduced on Windows 11 with Python 3.14, and the POSIX-only enumeration tests run on Linux - LoopX area: control plane (runtime contract check)
Sanitized diagnostics
Base, directory scan (isolated runtime home so the unrelated registry warning does not dominate):
- ok: `True`
- summary: errors=0, warnings=2, checks=3
- public boundary scan clean: 1 files
The same command with the file named directly:
- ok: `False`
- Errors
- notes.txt:1: credential
Fix head, directory scan: ok: False, notes.txt:1: credential, scanned_files=2 for the two-file directory. The documented four-root scan at the fix head: ok: True, scanned_files=5,567, zero blocking hits, 67 credential-reference warnings (55 at base, all non-blocking pre-existing references in code and docs). The bare default scan (--scan-root .): base ok: true, 0 errors, 122 warnings, 5,306 scanned files; fix head ok: true, 0 errors, 309 warnings, 8,056 scanned files; the three source constructs it first surfaced are handled as described in the PR.
Additional context
The closed reports #7727 and #7799 fixed missing credential shapes in the same module; this report is about which files reach the shape rules at all, so the two changes are independent. The presentation-packaging gap #9405 covers the same class of bug in a different publisher and does not touch loopx check.
Activity
[-][Bug]: the \loopx check\ directory boundary scan skips all text outside a seven-suffix allow-list[/-][+][Bug]: the `loopx check` directory boundary scan skips all text outside a seven-suffix allow-list[/+]