T09 · Insecure Skill Coding Practices
- Location
scripts/generate_report.py:65- Finding
Stored HTML and JavaScript Injection in Generated Reports
- Content
View full analysis
Amazon产品研究报告: {query} ``` ```javascript const RAW_DATA = {data_json}; (function() { const grid = document.getElementById('productGrid'); const products = RAW_DATA.products || []; products.forEach(p => { const card = document.createElement('div'); card.className = 'product-card'; card.innerHTML = `${p.title}${'⭐'.repeat(Math.round(p.rating || 0))} ${p.rating}${p.price || 'N/A'}${(p.total_reviews || 0).toLocaleString()} 条评论查看详情 → `; grid.appendChild(card); }); })(); ``` ```javascript document.getElementById('kwSummary').innerHTML = kd.summary || ''; document.getElementById('vocSummary').innerHTML = ...[truncated 2736 chars]- Remediation
View remediation
` element and parse its `textContent`. 3. Before embedding JSON in HTML, escape at least `<`, `>`, `&`, U+2028, and U+2029. For example, replace `<` with `\u003c`. 4. Apply HTML attribute escaping to direct template substitutions such as the query and market. 5. Validate all URLs with `urllib.parse.urlparse()` and allow only expected HTTPS origins. Reject `javascript:`, `data:`, `file:`, and unexpected hosts. 6. Validate LLM responses against a strict schema with type, size, and character constraints. 7. Add a restrictive Content Security Policy that disallows inline scripts and limits network connections, images, and scripts to approved sources. 8. Add regression tests containing payloads in queries, titles, reviews, summaries, URLs, and all LLM-generated fields. ]]>
