T09 · Insecure Skill Coding Practices
- Location
generate.sh:4- Finding
Unsanitized User Input Allows HTML and JavaScript Injection in Generated Pages
- Content
View full analysis
${PRODUCT} ``` ```html${PRODUCT}
${TAGLINE}
Get StartedWhy ${PRODUCT}?
``` ```html⚡ Fast
${DESC}
© ${YEAR} ${PRODUCT}. All rights reserved.
``` ### Technical Analysis The script treats its three command-line arguments as trusted text and interpolates them directly into an HTML heredoc. It does not encode HTML metacharacters such as `&`, `<`, `>`, `"`, and `'`. An attacker who can control any of these arguments can terminate the intended text node or element and inject arbitrary HTML. For example, a description containing: ```html``` would be emitted as executable markup rather than displayed as text. When the generated page is opened in a browser, the injected event handler executes. A script element or other active HTML content could similarly be introduced. This is an HTML-generation vulnerability rather than shell command injection. Shell syntax contained inside an already supplied argument is not re-evaluated as shell code by parameter expa ...[truncated 1477 chars]
- Remediation
View remediation
`, `"`, and `'` in `PRODUCT`, `TAGLINE`, and `DESC`. 3. Apply encoding at output time and according to the destination context. The current inputs are used in HTML text and title content; future use in attributes, URLs, CSS, or JavaScript would require different context-specific encoding. 4. Validate input lengths and reject control characters or content outside the expected product-text format where appropriate. 5. Add regression tests using payloads such as `
