T09 · Insecure Skill Coding Practices
- Location
scripts/report_generator.py:208- Finding
Stored HTML and Script Injection Through Unescaped Report Data
- Content
View full analysis
5S管理报告 - {data.get('period', 'N/A')} ``` ```python 报告周期:{data.get('period', 'N/A')} | 区域:{data.get('region', 'N/A')} | ``` ```python {''.join([f''' ''' for i in issues])} ``` ```python {''.join([f'''{i.get('type', '未知类型')} {'已整改' if i.get('status')=='resolved' else '待整改'}{i.get('description', '')}{'''整改期限:{deadline}'''.format(deadline=i.get("deadline", "未设置")) if i.get('status')!='resolved' else ''}''' for imp in improvements])} ``` ### Technical Analysis The report generator reads attacker-influenced fields from JSON and inserts them directly into an HTML document through Python formatted strings. It does not perform HTML escaping, contextual output encoding, or sanitization. Affected values include: - Report period - Region - Issue type - Issue description - Issue deadline - Improvement ...[truncated 2077 chars]{imp.get('item', '')}{imp.get('before', 0):.1f} → {imp.get('after', 0):.1f} +{imp.get('after', 0) - imp.get('before', 0):.1f}{imp.get('date', '')}- Remediation
View remediation
``` This should be defense in depth and must not replace output escaping. 6. Add automated tests using payloads containing angle brackets, quotes, event handlers, and script elements. Confirm that generated reports display the payloads as literal text and do not create executable DOM elements. ]]>
