T09 · Insecure Skill Coding Practices
- Location
SKILL.md:38- Finding
Unescaped Repository Content Can Cause HTML and Script Injection
- Content
View full analysis
` tool or sent directly to the user's browser to open. HTML structure: - Single file with no external dependencies (all CSS/JS inline) ``` ```markdown ### Scenario 1: PR Review Summary The user provides a PR diff or Git output, and the generated HTML contains: 1. **PR title and description** — a one-sentence TL;DR 2. **Risk map** — list the risk level by file 3. **Per-file diff** — syntax-highlighted diff with risk labels 4. **Review recommendations** — tell reviewers where to focus ``` ```markdown ### Scenario 3: Code Walkthrough The user provides code files or module paths, and the generated output contains: 1. **Request path** — data flow from entry to exit 2. **Step-by-step code** — expandable source blocks and annotations 3. **Trust boundaries** — mark security boundaries and external dependencies ``` ```markdown ## Notes - All CSS and JavaScript must be inline, with no external resources - Diff colors must use the GitHub dark-theme color scheme - Only three risk labels may be used - The mobile layout must be readable - If the diff is too long, show only key changed lines ``` The document does not require HTML escaping, context-sensitive output encoding, sanitization, or safe DOM insertion for repository-controlled content. ### Technical Analysis The skill is explicitly designed to place user-provided or repository-controlled data—including PR titles, file paths, diffs, annotations, and source code—inside a browser-opened HTML document ...[truncated 3385 chars]- Remediation
View remediation
`, `"`, and `'` before inserting untrusted content into generated markup. 3. Require untrusted content to be inserted through text-only DOM APIs such as `textContent`; prohibit `innerHTML`, `outerHTML`, `insertAdjacentHTML`, and raw template interpolation for such values. 4. Never place untrusted input in inline JavaScript, CSS, event-handler attributes, URL attributes, element names, or attribute names. 5. Prefer a report with no JavaScript. If interactivity is necessary, use fixed static code that does not construct executable code or markup from repository data. 6. Add a restrictive Content Security Policy, preferably: ```html ``` 7. If fixed JavaScript is required, move it away from inline handlers, authorize it with a generated nonce or hash, and continue to prohibit evaluation functions such as `eval` and `new Function`. 8. Add regression tests using payloads containing closing tags, script elements, event handlers, SVG markup, quotes, ampersands, and malicious URL schemes. 9. Recommend opening reports in an isolated, unauthenticated origin or sandboxed browser context rather than an authenticated internal application origin. 10. Add a mandatory instruction similar to: ```markdown Treat all user, Git, and repository content as untrusted text. HTML-encode it before insertion. Never interpolate it as raw HTML or place it in script, style, event-handler, or URL contexts. Use textContent for dynamic values. ``` ]]>
