T09 · Insecure Skill Coding Practices
- Location
scripts/doctor.sh:366- Finding
High-Risk Registry Reinitialization Bypasses the Approval Gate
- Content
View full analysis
Tuple[Dict[str, Any], List[str], str | None]: p = Path(path).expanduser() notes = ["registry corrupted: initialized empty v2"] backup_path = None if p.exists(): broken = f"{p}.broken-{_timestamp_suffix()}" shutil.copy2(p, broken) notes.append(f"corrupted backup saved: {broken}") reg = _empty_registry() backup_path = save_registry(str(p), reg, make_backup=True) ``` `scripts/registry_lib.py:260-266`: ```python try: with p.open("r", encoding="utf-8") as f: payload = json.load(f) except Exception: reg, notes, backup = _handle_corruption(str(p)) return LoadResult(registry=reg, migrated=True, migration_notes=notes, backup_path=backup) ``` ### Technical Analysis The doctor command identifies registry reinitialization after JSON corruption as a high-risk action. When `doctor --fix` is invoked without `--yes`, the action is added to `actions_blocked`, which should prevent it from being performed. However, after evaluating the risk gate, the command unconditionally invokes `load_registry()`. If the registry contains malformed JSON, `load_registry()` catches the parsing exception and calls `_handle_corruption()`. That function copies the corrupt file to a backup and then overwrites the active ...[truncated 2456 chars]- Remediation
View remediation
