T09 · Insecure Skill Coding Practices
- Location
scripts/generate-html-report.js:301- Finding
Stored HTML Injection in Generated Assessment Reports
- Content
View full analysis
Q${idx + 1} ${d.id} ${name} ${statusText}${isZH ? '原因' : 'Reason'}: ${d.skipReason || 'Required capability not available'}
`; } const criteriaRows = (d.criteria || []).map(c => ` ${c.name} ${(c.weight * 100).toFixed(0)}% ${c.score}/5 ${c.justification || ''} `).join(''); ``` Other unescaped metadata is inserted into the document: ```js return `Q${idx + 1} ${d.id} ${name} ${diff} ×${d.multiplier} ${d.adjScore.toFixed(1)} ${statusText}``` ```js const html = ` ${t.title} — ${data.sessionId} ``` ```js${t.title}
${t.session}: ${ ...[truncated 2986 chars]- Remediation
View remediation
/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } ``` 3. Encode attribute values separately and validate fields such as `lang`, `sessionId`, and dimension IDs against strict allowlists. 4. Validate input against the supplied JSON schema before report generation. Add: - String length limits. - Enumerations for language, status, confidence, level, and dimension IDs. - Numeric ranges for scores, weights, and multipliers. - A restrictive pattern such as `^[A-Za-z0-9_-]+$` for session identifiers. 5. Avoid constructing complex documents through raw template interpolation. A DOM builder or templating system with automatic escaping is preferable. 6. Add a restrictive Content Security Policy to generated reports, for example: ```html ``` 7. Add regression tests for every report string field using payloads containing: - `
