T09 · Insecure Skill Coding Practices
- Location
scripts/sync_tra.py:157- Finding
Existing Traditional article can be overwritten without enforced approval
- Content
View full analysis
Vulnerability Details
File Location:
scripts/sync_tra.py:157-180
Vulnerability Type: Missing executable overwrite-approval control
Risk Level: MediumVulnerable code:
python ap.add_argument("source", help="path to the <YYMMDD-slug>-zh-hans.md Simplified article") ap.add_argument("--check", action="store_true", help="report drift; do not write") args = ap.parse_args() src = Path(args.source) if not src.is_file(): sys.exit(f"source not found: {src}") src_text, src_out, twin, twin_out = build(src) lint = lint_traditional(twin_out) if args.check: problems: list[str] = [] if read(src) != src_out: problems.append(f"{src.name}: cross-link missing, stale, or needs normalizing") if not twin.is_file(): problems.append(f"{twin.name}: missing") elif read(twin) != twin_out: problems.append(f"{twin.name}: out of sync with {src.name}") if problems: print("FAIL: not in sync") for p in problems: print(" -", p) report_lint(lint) return 1 print(f"OK: {src.name} and {twin.name} are in sync") report_lint(lint) return 0 wrote: list[str] = [] if read(src) != src_out: src.write_text(src_out, encoding="utf-8") wrote.append(src.name) twin.write_text(twin_out, encoding="utf-8") wrote.append(twin.name)Technical Analysis
SKILL.mdrequires explicit user approval before writing and specifically directs the Agent to stop and ask before overwriting an existing-zh-hant.mdfile. The executable implementation does not enforce this gate.The only write-related option is
--check. When that flag is absent,twin.write_text(twin_out, encoding="utf-8")replaces the generated twin regardless of whether it already exists. There is no interactive prompt, explicit--overwriteflag, approval token, or refusal-on-existence behavior.The script may also modify the source article to insert or normalize its cross-link. Consequently, direct or mist ...[truncated 1440 chars]
- Remediation
View remediation
Remediation Suggestions
- Refuse to write the twin when it already exists unless an explicit
--overwriteor--forceflag is supplied. - Make write intent explicit, such as requiring
--write, while retaining--checkas a non-mutating mode. - If interactive execution is supported, display the exact source and destination paths and require confirmation before replacement.
- Ensure non-interactive Agent workflows pass an explicit overwrite authorization flag only after receiving user approval.
- Consider atomic replacement using a temporary file in the destination directory followed by
os.replace. - Optionally create a backup before approved replacement to reduce accidental data-loss risk.
- Apply the same explicit write authorization policy to modifications of the Simplified source file.
- Refuse to write the twin when it already exists unless an explicit
