T09 · Insecure Skill Coding Practices
- Location
python_report_style_factor_backtest.py:515- Finding
Stored HTML Injection Through Unescaped Report Metadata
- Content
View full analysis
{REPORT_TITLE} body {{ font-family: Arial, Helvetica, sans-serif; line-height: 1.6; margin: 28px auto; max-width: 1100px; color: #222; }} h1, h2, h3 {{ color: #1f4e79; }} table {{ border-collapse: collapse; width: 100%; margin: 12px 0 20px 0; }} th, td {{ border: 1px solid #d9d9d9; padding: 8px 10px; text-align: right; }} th:first-child, td:first-child {{ text-align: left; }} .card {{ background: #f8fbff; border: 1px solid #dbe5f1; border-radius: 10px; padding: 14px 18px; margin: 12px 0; }} .small {{ color: #666; font-size: 13px; }}{REPORT_TITLE}
研究问题与核心结论
研究问题:{RESEARCH_QUESTION}
因子逻辑:{FACTOR_NARRATIVE}
本报告自动按照金工研报的典型展示链路输出:因子定义、有效性检验、分层收益、组合回测、风险与可实施性。
样本与回测设定
- 目标下载股票数:{summary['target_download_stocks']}
- 实际成功下载股票数:{summary['actual_download_stocks']}
- 下载失败或历史长度不足数量:{summary['failed_or_short_history']}
- 回测区间:{summary['date_start']} 至 {summary['date_end']}
- 调仓频率:周频
- 持仓数:Top {TOP_N}
- 分组数:{QUANTILES}
- 基准:{BENCHMARK}
- 成本假设:单边 {TCOST_ONE_WAY:.2%}
候选池说明:{UNIVERSE_NOTE}
''' wit ...[truncated 2025 chars]图表展示
{''.join(image_blocks)}- Remediation
View remediation
` content. 3. Prefer a template engine configured with automatic HTML escaping rather than constructing the document with an f-string. 4. If limited formatting is intentionally supported, sanitize input with a strict allowlist that rejects scripts, event attributes, iframes, unsafe URLs, SVG, and similar active content. 5. Add a restrictive Content Security Policy to the generated report, for example one that denies scripts and remote connections when the report requires only inline images and CSS. 6. Add tests using payloads containing tags, quotes, event handlers, and encoded markup to verify that the output displays them as text rather than interpreting them as HTML. ]]>
