T09 · Insecure Skill Coding Practices
- Location
scripts/render_html.py:43- Finding
Stored HTML Injection Through an Unescaped Chart Title
- Content
View full analysis
{title} ``` The same unescaped title is also inserted into the page body: ```python``` The title may originate from the user-controlled task in `scripts/generate_chart.py`: ```python chart_title = generate_title_from_task(task) meta_file = output_path / f"{request_id}_meta.json" meta_info = { 'requestId': request_id, 'task': task, 'title': chart_title } meta_file.write_text( json.dumps(meta_info, indent=2, ensure_ascii=False), encoding='utf-8' ) ``` ### Technical Analysis The title is read from a metadata JSON file or supplied through the `--title` command-line option and then interpolated directly into the generated HTML. It is used in both the HTML `` element and an `<h1>` element without context-appropriate HTML escaping. JSON parsing does not sanitize HTML. Consequently, a title containing HTML markup can break out of the intended text context and introduce arbitrary elements or executable script. The automatic title-generation ...[truncated 1739 chars]{title}
AI智能生成的可视化图表
- Remediation
View remediation
{safe_title} ...{safe_title}
``` 3. Keep the raw title and HTML-escaped title as separate variables to prevent accidental reuse in incompatible contexts. 4. Enforce a reasonable title length and reject unexpected control characters. 5. Add a restrictive Content Security Policy to generated pages. For example, after removing inline executable code: ```html ``` 6. Add regression tests with titles containing: - `
