T09 · Insecure Skill Coding Practices
- Location
scripts/ai-ethics-check.py:385- Finding
Stored HTML Injection Through Unescaped Cloud-Controlled Report Fields
- Content
View full analysis
= 80 else "#ff9800" if score >= 60 else "#f44336" rows = "" current_cat = "" for r in items: if r.get("category_name") != current_cat: current_cat = r.get("category_name", "") rows += f'{current_cat}\n' icon = "✅" if r.get("passed") else "❌" cls = "pass" if r.get("passed") else "fail" rec = r.get("recommendation") or "继续保持" rows += f"""{icon}{r.get('name')}{r.get('legal_ref') or ''}{cls.upper()}{rec}\n""" ``` ### Technical Analysis The HTML report renderer inserts dynamic values directly into HTML without context-appropriate escaping. The affected values include: - `category_name` - `name` - `legal_ref` - `recommendation` These fields can originate from the remote rules endpoint or cloud evaluation response. The application parses remote JSON and later passes response items into `render_html()`. Because the values are interpolated into markup without `html.escape()` or equivalent sanitization, a malicious value such as an element with an event handler can terminate the expected table-cell context and introduce arbitrary HTML. The vulnerability does not require remote Python code execution. Exploitation requires control over, or compromise of, the pinned `compliancehub.cn` service or its response path. The fixed HTTPS endpoint and default certificate verification reduce exposure to ordinary network interception, but they do not protect against a compromised server, backend data store, or operator account. Other server-provided values rende ...[truncated 1709 chars]- Remediation
View remediation
``` This is defense in depth and must not replace output escaping. 5. Add regression tests using payloads containing `<`, `>`, `"`, `'`, event-handler attributes, script elements, and external resource tags. Verify that the generated report contains encoded text rather than executable markup. ]]>
