T09 · Insecure Skill Coding Practices
- Location
scripts/html_report.py:120- Finding
Unescaped Profile Data Permits Active-Content Injection in Generated HTML Reports
- Content
View full analysis
🥗 个性化饮食方案
Based on the Chinese Dietary Guidelines 2022 and AI recommendations | {profile.get('goal', 'Healthy diet')} plan
``` The resulting document is then written directly to the selected output file: ```python with open(output_path, "w", encoding="utf-8") as f: f.write(html) return output_path ``` A profile can be loaded from a caller-controlled JSON file: ```python if args.profile and os.path.exists(args.profile): with open(args.profile, "r", encoding="utf-8") as f: profile = json.load(f) else: profile = engine.build_profile({ "age": 30, "gender": "Male", "height": 175, "weight": 70, "goal": args.goal, "activity_level": "Moderate activity" }) plan = engine.generate_meal_plan(profile, days=7) path = generate_meal_plan_report(profile, plan, output) ``` Other report fields are interpolated using the same unsafe pattern: ```python items_str = "、".join(s["items"]) meals_html += f"""""" items_str = "、".join(meal["items"]) meals_html += f"""🍪 {s['name']}{items_str}{s['estimated_kcal']}kcal | Protein {s['protein_g']}g""" ``` ### Technical Analysis Dynamic values are inserted into HTML text ...[truncated 2458 chars]{emoji} {label} ({meal['name']}){items_str}{meal['estimated_kcal']}kcal | Protein {meal['protein_g']}g | ⏱{meal['prep_time_min']}min | {meal['target_pct']}- Remediation
View remediation
``` This provides defense in depth but does not replace output encoding. 6. Add regression tests using payloads containing `
