T09 · Insecure Skill Coding Practices
- Location
scripts/boat-email-report.py:205- Finding
Unescaped Victron API Data Is Inserted into the Generated HTML Report
- Content
View full analysis
{alarm["name"]}
{alarm["attribute"]}' ``` ### Technical Analysis Values returned by the Victron API, including formatted diagnostic values, inverter state, alarm names, and alarm attributes, are treated as trusted HTML. They are inserted into the report using direct string replacement and f-string ...[truncated 1911 chars]- Remediation
View remediation
' f'{safe_name}
{safe_attribute}' '' ) ``` 2. Use a maintained template engine with automatic HTML escaping, such as Jinja2 with autoescape enabled, instead of repeated string replacement. 3. Validate telemetry against strict expected types: - Convert numeric measurements to `float` before formatting. - Map status fields to an allowlist of recognized values. - Reject or encode unexpected textual values. 4. Avoid inserting external values into CSS or URL contexts unless separately validated for those contexts. 5. Add tests containing payloads such as `` and verify that the output contains encoded text rather than interpreted markup. 6. Apply defense-in-depth sanitization before handing generated HTML to an email delivery system. ]]>
