T09 · Insecure Skill Coding Practices
- Location
generate_ppt.py:39- Finding
Stored HTML Injection in Generated Presentations
- Content
View full analysis
{}".format(title)] for idx, para in enumerate(paragraphs): html_parts.append(f" ") html_parts.append("") with open(output_path, 'w', encoding='utf-8') as f: f.write('\n'.join(html_parts)) print(f'HTML slide deck saved to {output_path}') ``` ### Technical Analysis The `--title` and `--text` command-line values are directly interpolated into an HTML document without context-appropriate encoding. The `Slide {idx+1}
text {para}text ` element does not make its contents safe: an attacker can close it and introduce arbitrary HTML or JavaScript. For example, attacker-controlled text containing the following payload would create an executable script in the generated presentation: ```html
text ``` The title is also vulnerable because it is inserted directly into the `` element and can be escaped with a payload containing ``. ### Attack Path 1. An attacker supplies or influences the title or body text used to generate a presentation. 2. The Skill is invoked with `--html`. 3. `export_html()` writes the attacker-controlled value directly into the output document. 4. A user opens the generated HTML presentation in a browser. 5. The injected markup or JavaScript executes in the generated page's browser context. ### Impact Assessment Successful exploitation allows arbitrary JavaScript to execute in the presentation page. The attacker could: - Replace or manipulate the displayed presentation. - Create deceptive login f ...[truncated 465 chars]
- Remediation
View remediation
", "", "", f"{safe_title}", ] for idx, para in enumerate(paragraphs): safe_para = escape(para, quote=True) html_parts.append( f"" f" " ) html_parts.append("") with open(output_path, "w", encoding="utf-8") as f: f.write("\n".join(html_parts)) ``` Alternatively, use Jinja2 with HTML autoescaping explicitly enabled. Add regression tests covering closing tags, event-handler attributes, encoded payloads, and `Slide {idx + 1}
text {safe_para}
