T09 · Insecure Skill Coding Practices
- Location
main.py:850- Finding
Destructive Deletion of Unrelated JSON and EMD Files
- Content
View full analysis
Vulnerability Details
File Location:
main.py:850-860
Vulnerability Type: Unrestricted deletion of files based only on extension
Risk Level: HighComplete Code Snippet
python # 7. 清理旧文件 print("\n[7/8] 清理非标准命名文件...") removed = [] for f in os.listdir(base): fp = os.path.join(base, f) if not os.path.isfile(fp): continue if f.endswith('.emd') and f != 'esri_model_definition.emd': os.remove(fp) removed.append(f) elif f.endswith('.json') and f != 'esri_accumulated_stats.json': os.remove(fp) removed.append(f)Technical Analysis
The cleanup logic permanently deletes every top-level
.jsonfile exceptesri_accumulated_stats.jsonand every top-level.emdfile exceptesri_model_definition.emd. It does not verify that a file was generated by this Skill, belongs to a known obsolete output set, or is safe to remove.The deletion occurs automatically after output generation, without user confirmation or backup. Extension alone is not a sufficient ownership or safety check. ArcGIS training directories can contain unrelated configuration, annotation, model-definition, or project files using these extensions.
This behavior is disclosed generally in
SKILL.md:67, but disclosure does not remove the destructive risk.Attack Path
- A user selects a legitimate ArcGIS training directory containing additional
.jsonor.emdassets. - Alternatively, an attacker supplies a prepared training-data directory containing valuable files with those extensions.
- The user runs
python main.py <training-directory>. - The script completes metadata generation and enters the cleanup phase.
- Every non-allowlisted top-level JSON and EMD file is deleted using
os.remove. - Because no backup or recovery mechanism is provided, the affected files may be permanently lost.
Impact Assessment
The script can delete any matching top-level file in the user-selected direc ...[truncated 418 chars]
- A user selects a legitimate ArcGIS training directory containing additional
- Remediation
View remediation
Remediation Suggestions
- Remove the extension-wide cleanup operation.
- Delete files only from an explicit allowlist of obsolete filenames known to be owned by this tool.
- Require affirmative user confirmation before deleting any pre-existing file.
- Move obsolete files to a timestamped backup directory instead of permanently deleting them.
- Produce a dry-run report listing proposed changes before modifying the directory.
- Record file ownership through a manifest generated by the Skill and only clean files listed in that manifest.
- Use case-normalized filename checks if cleanup must support case-insensitive platforms.
