T09 · Insecure Skill Coding Practices
- Location
scripts/generate_report.py:431- Finding
Stored HTML and JavaScript Injection Through an Unescaped Verdict
- Content
View full analysis
{verdict} ``` The `verdict` value is supplied through the `--verdict` command-line argument and is interpolated directly into the generated HTML document without HTML escaping or sanitization. ### Technical Analysis The report generator constructs the complete document through a Python formatted string. The attacker-controlled `verdict` value is inserted into an HTML element as raw markup. Consequently, HTML metacharacters such as `<`, `>`, `"`, and `'` retain their syntactic meaning. For example, a verdict containing an event-handler payload can introduce a new HTML element whose JavaScript executes when the report is opened: ```text``` The same underlying issue also affects other profile values inserted into the template without contextual escaping, including custom gender and condition values. The vulnerability is stored rather than reflected because the payload is written into the generated report and remains there until the report is deleted or regenerated. ### Attack Path 1. An attacker supplies a crafted verdict or persuades the user or an AI Agent to pass it through the `--verdict` option. 2. `generate_report.py` interpolates the value into the HTML template without escaping it. 3. The generated report is delivered to or opened by the user. 4. The browser interprets the injected value as active HTML. 5. An event handler or injected script executes in the report's browser context. 6. The payload can read or modify the report DOM, access the health data embedded in JavaScript variables, falsify displayed medical conclusions, or transmit accessible report data to an external endpoint. ### Impact Assessment ...[truncated 565 chars]
- Remediation
View remediation
`. 4. Prefer a template engine with automatic escaping enabled rather than constructing the entire page with an f-string. 5. Add a restrictive Content Security Policy. Where possible, move inline JavaScript into a local static file and disallow inline event handlers. 6. Add regression tests with payloads containing `` sequences. ]]>
