T09 · Insecure Skill Coding Practices
Error
- Location
- templates/report-template.html:196
- Finding
- Unescaped External Data in Generated HTML Report## Vulnerability Details **File Location**: `templates/report-template.html:196, 226, 231, 248, 255, 262, 281, 287, 329` **Vulnerability Type**: Persistent HTML and script injection **Risk Level**: High ### Vulnerable Code ```html <p>{{STRATEGY_DESCRIPTION}}</p> <div class="funnel-url">{{FUNNEL_URL}}</div> <img src="{{LANDING_SCREENSHOT}}" alt="{{FUNNEL_NAME}} Landing Page"> <source src="{{VIDEO_FILE}}" type="video/mp4"> <div class="ad-card-title">{{AD_TITLE}}</div> <div class="ad-text">{{AD_SCRIPT}}</div> <img src="{{IMAGE_FILE}}" alt="{{AD_TITLE}}"> <div class="ad-card-title">{{AD_TITLE}}</div> {{ADVERTISER_URLS}} ``` ### Technical Analysis The template interpolates placeholders into HTML text nodes, raw HTML regions, and quoted attribute values. According to `SKILL.md`, these values are derived from extracted ads, landing pages, asset filenames, URLs, and model-generated analyses. The project does not require context-sensitive output encoding, HTML sanitization, URL-scheme validation, or filesystem-path validation before substitution. An attacker-controlled value containing HTML metacharacters could terminate its current text or attribute context and introduce new markup. For example, a malicious title or filename containing a quote could escape an `alt` or `src` attribute, while content inserted through `{{ADVERTISER_URLS}}` could be interpreted directly as HTML. Depending on the generated value and browser behavior, this can permit injected elements, event handlers, external resource loads, deceptive interface content, or script execution. The exact exploitability depends on how the unspecified report-generation implementation substitutes values. If it uses a template engine with automatic context-sensitive escaping, the risk may be mitigated. However, neither the supplied template nor the Skill instructions mandate such protection. ### Attack Path 1. An attacker publishes an ad or landing page containing crafted text, URLs, or asset meta ...[truncated 1652 chars]
- Remediation
- ## Remediation Suggestions 1. Generate the report with a mature template engine that enables automatic escaping by default. 2. Apply context-sensitive encoding: - HTML-encode values inserted into text nodes. - Attribute-encode values inserted into quoted attributes. - Do not place untrusted data into raw HTML contexts. 3. Replace `{{ADVERTISER_URLS}}` and similar raw substitutions with structured template loops whose text and attributes are escaped independently. 4. Validate URLs with an allowlist of required schemes, preferably `https:`. Reject dangerous schemes such as `javascript:`, `data:`, and `file:` where they are not explicitly required. 5. Validate media paths as normalized relative paths and verify that their resolved locations remain beneath the intended assets directory. 6. Sanitize any intentionally supported rich HTML with a well-maintained allowlist-based sanitizer. Do not use regular expressions as the sole HTML sanitization control. 7. Add a restrictive Content Security Policy, for example by prohibiting scripts and limiting image and media sources to local files and explicitly required origins. 8. Add security tests using payloads containing quotes, angle brackets, event-handler attributes, closing tags, and dangerous URL schemes in every placeholder. 9. Document escaping and validation as mandatory requirements in `SKILL.md` so implementations cannot safely be interpreted as simple string replacement.
