T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:139- Finding
Stored HTML and Script Injection Through Unescaped Prototype Content
- Content
View full analysis
${name}
Content for ${name} section.
HTML } ``` ```bash cat < ${name} ${theme_vars} * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; } a { transition: color 0.2s; } a:hover { color: var(--primary); } button { transition: background 0.2s; } button:hover { background: var(--primary-hover) !important; } ${body} HTMLDOC ``` ```bash button) local label="${title:-Click Me}" local bg_color="#4a90d9" [[ "$variant" == "secondary" ]] && bg_color="#6c757d" [[ "$variant" == "danger" ]] && bg_color="#dc3545" [[ "$variant" == "success" ]] && bg_color="#28a745" html="${label}" ;; modal) title="${title:-Modal Title}" body_text="${body_text:-Modal content goes here.}" IFS=',' read -ra actions <<< "${actions_str:-cancel,confirm}" local action_buttons="" for action in "${actions[@]}"; do action="$(echo "$action" | xargs)" local abg="#4 ...[truncated 2929 chars]- Remediation
View remediation
`, `"`, and `'`. 2. Apply escaping to every value inserted into HTML text or attribute contexts, including names, titles, body text, section names, labels, and actions. 3. Do not use one generic escaping routine for all contexts; HTML text, HTML attributes, CSS, URLs, and JavaScript strings require different handling. 4. If rich HTML is intentionally supported in component bodies, process it through a proven allowlist-based HTML sanitizer rather than writing it directly. 5. Remove inline JavaScript event handlers where practical and attach behavior from static scripts. 6. Add a restrictive Content Security Policy to generated documents, preferably disallowing inline scripts and inline event handlers. 7. Add regression tests using payloads containing closing tags, event handlers, quotes, and script elements, and verify that they are rendered as text rather than executed. ]]>
