T09 · Insecure Skill Coding Practices
- Location
references/html-template.md:108- Finding
Unescaped User-Controlled Content in Generated HTML Reports
- Content
View full analysis
Grade: [Grade] | Subject: [Subject] | Analysis Date: [Date]
Analysis Type: [Single-question analysis / Full-paper analysis / Variant generation / Error classification]
Paper Name: [Paper Name] | Maximum Score: [Maximum Score]
``` ```htmlQuestion 1 In-Depth Analysis
1. Core Ability Assessed
[Describe the actual assessed ability and its subject-specific requirements]
2. Possible Problems Revealed by the Student's Incorrect Answer
1. Knowledge mastery [Analysis]
2. Conceptual misunderstanding [Analysis]< ...[truncated 3652 chars]
- Remediation
View remediation
` → `>` - `"` → `"` - `'` → `'` 2. Explicitly classify the following as untrusted: - Pasted questions and answers - OCR or multimodal extraction results - Paper names and filenames - Student names and teacher notes - Generated text that quotes user-provided material 3. Prohibit raw user HTML. Question and answer content must be rendered as text, preferably inside escaped ``, `
text `, or `
` elements. 4. Add a restrictive Content Security Policy to the document head: ```html ``` 5. Do not allow arbitrary URLs from user content. If links are necessary, permit only explicitly validated `https:` URLs and reject `javascript:`, `data:`, and other active schemes. 6. If report generation is implemented programmatically, use a template engine with automatic HTML escaping enabled. Avoid string concatenation and unsafe rendering APIs such as `innerHTML`. 7. Add security regression tests using at least these payload classes: ```htmlOpen
``` 8. Verify generated reports by opening them in an automated browser test and asserting that: - Payloads appear only as visible text. - No script or event handler executes. - No unauthorized network request occurs. - All six required report sections remain structurally intact. ]]>
