T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/enhanced_report_generator.py:410
- Finding
- Stored HTML and JavaScript Injection in Enhanced Reports<![CDATA[ ## Vulnerability Details **File Location**: `scripts/enhanced_report_generator.py:410-412, 556-561, 593, 629-670, 697-701, 745, 764-769` **Vulnerability Type**: Stored cross-site scripting and HTML injection **Risk Level**: High ### Vulnerable Code ```python html += f""" <div class="page-analysis"> <h3>📄 Page Analysis: {page_analysis.get('title', 'Unknown')}</h3> <p><strong>Purpose:</strong> {page_analysis.get('purpose', 'Not analyzed')}</p> <p><strong>Navigation:</strong> {', '.join(page_analysis.get('navigation', ['None found']))}</p> """ ``` ```python if observations_list: notes = '; '.join(str(o) for o in observations_list) elif raw_response: notes = f"Response: {raw_response}" elif error_msg: notes = f"Error: {error_msg}" action = step.get('action') or step.get('prompt', '') or 'No action' rationale = step.get('rationale') or step.get('expected_outcome', '') html += f""" <div class="observation"> <div class="observation-header"> <span class="step-name">Step {step_num + 1}: {action_display}</span> </div> {f'<div>Expected: {rationale}</div>' if rationale else ''} <div class="observation-notes {notes_class}"> <strong>{"⚠️ " if is_issue else ""}Observation:</strong> {notes} </div> </div> """ ``` ```python html += f""" <a href="{browser_path}" class="trace-link" target="_blank"> 📹 Recording {global_recording_index}: {display_name} </a> """ ``` ### Technical Analysis The report generator directly interpolates website-derived page titles, navigation text, Nova Act responses, errors, persona fields, test cases, and trace paths into HTML. It does not apply HTML escaping, attribute escaping, URI-scheme validation, or sanitization. These values cross an untrusted-data boundary because they may originate from an attacker-controlled website or crafted results/persona file. An injected value such as an image element with an event handler will become active markup when the ...[truncated 871 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Escape every untrusted text value with `html.escape(value, quote=True)` before interpolation. - Use an auto-escaping template engine such as Jinja2 instead of manually concatenating HTML. - Apply context-specific escaping separately for text nodes and attributes. - Restrict links to approved schemes such as `file`, `https`, or relative paths after canonicalization. - Add a restrictive Content Security Policy that blocks inline scripts and remote connections. - Add regression tests using payloads containing tags, quotes, event handlers, and `javascript:` URIs. ]]>
