T09 · Insecure Skill Coding Practices
- Location
scripts/reader.py:244- Finding
Unescaped Template Substitution Enables Persistent HTML and JavaScript Injection
- Content
View full analysis
每日读书推荐 - {{book_title}}{{title}}《{{book_title}}》{{book_desc}}—— {{book_author}}《{{book_title}}》{{book_author}}推荐值 {{rating}} | {{reading_count}}人今日阅读去阅读 ``` ### Technical Analysis The renderer reads values from a caller-selected JSON file and performs raw string replacement. It does not apply HTML entity encoding, attribute encoding, CSS-string encoding, or URL validation. The same replacement mechanism is used in several distinct parsing contexts: - HTML text nodes, such as `book_desc` and `book_title` - HTML attributes, such as `book_url` - Inline CSS, such as `cover_url` - The document title Because each context has different escaping requirements, raw replacement allows a value to terminate its intended conte ...[truncated 1810 chars]- Remediation
View remediation
` element instead. 4. Add a restrictive Content Security Policy, for example one that disallows inline scripts, plugins, and unexpected network destinations. 5. Treat fetched book metadata and all LLM-generated or caller-provided JSON fields as untrusted. 6. Add regression tests containing HTML tags, quotes, event handlers, CSS delimiters, and dangerous URL schemes. Verify that they are encoded as text rather than interpreted as markup. ]]>
