T09 · Insecure Skill Coding Practices
- Location
scripts/generate_table_pdf.py:19- Finding
Unescaped User Input Allows HTML and Script Injection
- Content
View full analysis
{title} ``` ```python📊 {title}
{subtitle}
``` The values originate from command-line arguments and are passed directly to the template: ```python parser.add_argument('--title', default='表格', help='表格标题(必需)') parser.add_argument('--subtitle', default='OpenClaw 结构化数据可视化', help='副标题') ``` ```python html_content = generate_html_template(args.title, args.subtitle) ``` ### Technical Analysis The `title` and `subtitle` values are interpolated directly into an HTML document without context-appropriate escaping. An attacker who can influence either command-line argument can terminate the surrounding HTML element and inject arbitrary markup. For example, a crafted title could close the `` element and add a script: ```text ``` Because the documented workflow instructs the Agent to serve and open the resulting file in a browser, injected JavaScript may execute in the local HTTP origin. The injected code could manipulate the generated document, falsify the content exported to PDF, or request other files exposed by the same temporary-directory HTTP server. The vulnerability does not, by itself, grant arbitrary operating-system command execution. Its direct scope is the rendered browser document and resources accessible through the local server origin. ### Attack Path 1. An attacker supplies or influences t ...[truncated 1274 chars]- Remediation
View remediation
{safe_title}''' ``` Additional hardening measures should include: 1. Treat title and subtitle values as plain text, not trusted HTML. 2. If formatted input is required, process it with a strict HTML allowlist sanitizer. 3. Add a restrictive Content Security Policy, such as: ```html ``` 4. Add tests using payloads containing `📊 {safe_title}
{safe_subtitle}
