T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/build_table_registry.py:20- Finding
Unrestricted File Paths Permit Access Outside the Intended Workspace
- Content
View full analysis
list[dict[str, Any]]: if args.records_json: data = json.loads(args.records_json) elif args.records_file: path = Path(args.records_file) if path.suffix.lower() == ".json": data = json.loads(path.read_text(encoding="utf-8")) else: with path.open(newline="", encoding="utf-8") as handle: data = list(csv.DictReader(handle)) ``` ```python def maybe_write_canary(args: argparse.Namespace, registry_path: Path, output_dir: Path) -> bool: if not args.allow_local_canary_sync or not args.profile: return False profile = json.loads(Path(args.profile).read_text(encoding="utf-8")) if profile.get("mode") != "archive_compat": return False if profile.get("local_canary_sync") is not True: return False if str(profile.get("target_dir", "")).rstrip("/") != str(args.output_dir).rstrip("/"): return False canary_dir = Path(args.canary_dir) canary_dir.mkdir(parents=True, exist_ok=True) ``` ```python output_dir = Path(args.output_dir) output_dir.mkdir(parents=True, exist_ok=True) columns, rows = normalize_records(load_records(args)) md_path = output_dir / "customer_review.md" csv_path = output_dir / ".registry_customer_review.csv" write_markdown(md_path, columns, rows) write_csv(csv_path, columns, rows) canary = maybe_write_canary(args, csv_path, output_dir) ``` ### Technical Analysis The script directly converts caller-controlled values from `--records-file`, `--profile`, `--output-dir`, and `--canary-dir` into filesystem paths. It does not establish a trusted workspace root, canonicalize the paths, reject absolute paths, prevent `..` trav ...[truncated 2106 chars]- Remediation
View remediation
