T09 · Insecure Skill Coding Practices
- Location
TOOLS/wardrobe_analysis_tool.py:140- Finding
Unsanitized Model-Generated HTML Is Persisted and Delivered to Users
- Content
View full analysis
start_idx = html_content.find("") if start_idx != -1: html_content = html_content[start_idx:] current_date = datetime.now().strftime("%Y-%m-%d") filename = f"{current_date}个人电子衣橱看板.html" filepath = os.path.join(self.dashboard_dir, filename) try: with open(filepath, "w", encoding="utf-8") as f: f.write(html_content.strip()) ``` The affected workflow is explicitly reachable through: - `smart_wardrobe_analysis.md:31-38,45-47`, which requires the Agent to save and deliver the generated dashboard. - `PROMPT/wardrobe_analysis_prompt.md:12,35`, which permits Chart.js or native HTML but does not prohibit remote resources or executable scripts. ### Technical Analysis `save_html_dashboard()` treats the language model's response as trusted HTML. It removes Markdown fences and optionally discards content preceding ``, but it performs no security validation or sanitization. The method does not reject or neutralize: - Executable `- Remediation
View remediation
... ``` 4. **Prohibit remote resources.** - Bundle visualization libraries locally or replace them with static CSS/SVG generated by trusted code. - Reject all external `src`, `href`, CSS `url()`, and similar resource references. 5. **Apply a restrictive Content Security Policy.** - Use a policy such as `default-src 'none'`. - Add only the minimum directives needed for embedded styles and local images. - Do not enable arbitrary inline or remote JavaScript. 6. **Validate before delivery.** - Parse the finished dashboard and fail closed if prohibited tags, attributes, protocols, or remote origins are present. - Record validation failures without sending the unsafe file to the user. ]]>
