T09 · Insecure Skill Coding Practices
- Location
scripts/vocab_plan.js:51- Finding
Unescaped Vocabulary Entries Allow Markdown and HTML Content Injection
- Content
View full analysis
l.trim()) .filter((l) => l && !l.startsWith('#')); ``` ```javascript lines.push( `| ${k} | ${learn.length ? learn.join(';') : '—'} | ${review.length ? review.join(';') : '—'} |` ); ``` ### Technical Analysis Vocabulary entries read from the user-selected file are inserted directly into a Markdown table without context-aware escaping. Markdown metacharacters such as `|`, backslashes, link syntax, and raw HTML are preserved. An attacker-controlled entry can therefore alter table structure or introduce links, images, HTML elements, or instruction-like text into the generated document. The issue is an output-injection flaw rather than arbitrary code execution: the script itself does not evaluate vocabulary entries or pass them to a shell. The practical effect depends on the downstream Markdown renderer. Renderers that permit raw HTML or automatically load remote image resources may increase the impact, while renderers that sanitize HTML will reduce it. ### Attack Path 1. An attacker creates or modifies a vocabulary file that the victim is expected to process. 2. The attacker adds an entry containing Markdown table delimiters, a deceptive link, raw HTML, or another crafted payload. 3. The victim runs the documented command with the affected file: ```bash node vocab_plan.js --file words.txt ``` 4. The script reads the crafted entry and interpolates it directly into the Markdown table. 5. The victim or a downstream system renders the generated output. 6. The injected content can disrupt the schedule, display misleading content, present a phishing link, or cause renderer-dependent external resource requests. ### Impact Assessment The v ...[truncated 567 chars]- Remediation
View remediation
`. 4. Neutralize Markdown links and image syntax if clickable or externally loaded content is not required. 5. Consider generating JSON or another structured representation and using a trusted renderer that performs output encoding. 6. Configure downstream Markdown renderers to disable raw HTML and remote resource loading. 7. Add regression tests covering: - Table delimiters - Backslashes - Markdown links and images - Raw HTML - Very long entries - Instruction-like or deceptive content For example, introduce a dedicated escaping function and apply it before both learning and review entries are joined into the table. ]]>
