T09 · Insecure Skill Coding Practices
- Location
assets/framework/engine.js:97- Finding
Stored DOM-Based Cross-Site Scripting Through Imported Course Content
- Content
View full analysis
c.id === courseId)) { COURSE_REGISTRY.push({ id: courseId, name: courseName, desc: '', school: '', term: '' }); } ``` ```javascript let html = `${q.topic} ${diffLabels[q.difficulty] || '?'} ${fsrsInfo}${this.formatText(q.question)}`; if (this.flipped) { html += `
`; } else { html += '答案${this.formatText(q.answer)}点击查看答案 →'; } document.getElementById('card-inner').innerHTML = html; ``` ```javascript formatText(text) { return (text || '').replace(/\\n/g, '
').replace(/\n/g, '
'); } ``` ```javascript list.innerHTML = this.allTopics.map(t => { const tm = this.topicMastery[t]; let scoreClass = 'score-none', scoreText = '未开始'; if (tm && tm.attempts > 0) { const m = tm.mastery; if (m >= 0.7) { scoreCla ...[truncated 2877 chars]- Remediation
View remediation
` elements rather than using `innerHTML`. 3. If controlled rich-text support is required, sanitize content with a maintained allowlist-based sanitizer. Disallow script elements, event-handler attributes, dangerous URLs, SVG, MathML, iframes, and active embedded content. 4. Validate imported JSON against a strict schema, including expected types and maximum lengths for every field. 5. Apply a restrictive Content Security Policy that disallows inline event handlers and limits script execution to trusted bundled resources. CSP should be defense in depth rather than the primary correction. 6. Add regression tests using payloads such as: ```htmllink ``` Verify that these strings are displayed literally and never interpreted as markup. ]]>
