T09 · Insecure Skill Coding Practices
- Location
scripts/pdd_analyzer.py:889- Finding
Unsanitized Remote HTML Is Written to Locally Opened Reports
- Content
View full analysis
str: """将完整 HTML 报告写到本地文件,返回路径(供 stdout 指引) token 优化:stdout 不回传 HTML+SVG(SVG 对 LLM 无意义,~7-13K token 纯浪费), 改回传 report markdown(~2K token);HTML 写文件供浏览器/IDE 渲染查看。 """ CONFIG_DIR.mkdir(parents=True, exist_ok=True) ts = pd.Timestamp.now().strftime("%Y%m%d_%H%M%S") path = CONFIG_DIR / f"report_{ts}.html" path.write_text(html, encoding="utf-8") return str(path) ``` ### Technical Analysis The `report_html` value originates from the remote paid API response. The renderer assigns this value directly to `html`, combines it with warning markup, and places it into a complete HTML document without applying an HTML allowlist sanitizer. The generated report is saved under `~/.pdd_skill/`, and the user is explicitly instructed to open it in a browser or IDE. If the analysis service, its infrastructure, or the response-generation pipeline is compromised, the response can contain active content such as: - `- Remediation
View remediation
``` 7. Add automated security tests containing scripts, event handlers, iframes, external images, unsafe links, and malformed markup. Verify that generated reports contain no active content. 8. Consider rendering reports as Markdown or plain text by default and making HTML generation an explicit option. ]]>
