T09 · Insecure Skill Coding Practices
- Location
assets/report_template.html:219- Finding
Stored Cross-Site Scripting in Generated Contract Reports
- Content
View full analysis
0) { const lawHtml = laws.map(l => `${l.law || ''} ${l.article || ''}`).join(''); document.getElementById('lawContainer').innerHTML = lawHtml; } else { document.getElementById('lawSection').style.display = 'none'; } ``` The same unsafe pattern is used for overview statistics, score labels, heatmap section names, risk titles and descriptions, original contract clauses, suggested clauses, negotiation strategies, and comparison fields. ### Technical Analysis The template does not apply contextual HTML escaping or sanitization before assigning dynamic data to `innerHTML`. If any populated field contains an element with an event handler, such as an image with an `o ...[truncated 2210 chars]${l.content || ''}- Remediation
View remediation
`, `&`, U+2028, and U+2029. - Ensure script-closing sequences cannot appear literally in generated data. - Prefer placing JSON in a non-executable data element and parsing its `textContent`. 4. Validate enumerated fields such as risk level, priority, grade, and CSS class suffixes against explicit allowlists. 5. Add a restrictive Content Security Policy. After removing inline scripts, use controls similar to: - `default-src 'none'` - `script-src 'self'` - `style-src 'self'` - `img-src 'self' data:` - `connect-src 'none'` - `object-src 'none'` - `base-uri 'none'` - `form-action 'none'` 6. Add regression tests using contract clauses containing HTML tags, event handlers, quotes, template syntax, and script-closing sequences. Verify that every payload is rendered as inert text. ]]>
