T09 · Insecure Skill Coding Practices
- Location
git_update.py:154- Finding
Local modifications can be silently overwritten during an update
- Content
View full analysis
dict: updater = skill_updater_dir(skill_path) orig_dir = originals_dir(skill_path) p_path = patch_path(skill_path) os.makedirs(orig_dir, exist_ok=True) current_files = {} for root, dirs, files in os.walk(skill_path): dirs[:] = [d for d in dirs if not d.startswith(".") or d == UPDATER_DIR] for fname in files: if fname.startswith("."): continue full = os.path.join(root, fname) rel = os.path.relpath(full, skill_path) if rel.startswith(UPDATER_DIR): continue try: with open(full, "r", encoding="utf-8", errors="ignore") as f: current_files[rel] = f.read() except Exception: pass for rel, content in current_files.items(): orig_full = os.path.join(orig_dir, rel) os.makedirs(os.path.dirname(orig_full), exist_ok=True) with open(orig_full, "w", encoding="utf-8") as f: f.write(content) patch_lines = [] for rel in sorted(current_files.keys()): orig_rel = os.path.join(UPDATER_DIR, ORIGINALS_DIR, rel) code, diff_out, _ = run( ["diff", "-u", orig_rel, rel], cwd=skill_path ) if diff_out.strip(): patch_lines.append(diff_out) ``` The affected update flow subsequently invokes the remote updater: ```python if not has_mod: mod_info = save_modifications(path) has_mod = mod_info["has_mods"] if not dry_run: code, out, err = do_update(slug) ``` ### Technical Analysis The `.skill-updater/originals/` directory is intended to contain an immutable baseline representing the files before local modifications. However, `s ...[truncated 2132 chars]- Remediation
View remediation
