T09 · Insecure Skill Coding Practices
- Location
scripts/supplier_perf.py:109- Finding
Unescaped User-Controlled Values Permit Markdown Report Injection
- Content
View full analysis
- Remediation
View remediation
str: text = str(value) text = text.replace("\r", " ").replace("\n", " ") text = text.replace("\\", "\\\\") text = text.replace("|", "\\|") text = text.replace("<", "<").replace(">", ">") return text ``` 2. Apply the function to every user-controlled string before inserting it into Markdown, including names, countries, units, specifications, dates, buyer names, supplier names, and purchase-order identifiers. 3. Use stricter output-specific handling: - Remove line breaks from table-cell values. - Escape pipe characters in tables. - Disable raw HTML in the Markdown renderer. - Reject dangerous URL schemes if user-controlled links are ever supported. 4. Prefer structured JSON when passing results between software components or AI Agents. Render Markdown only at the final presentation boundary. 5. Add regression tests using values containing pipes, newlines, links, images, HTML, and instruction-like text. 6. Clearly label user-provided text as untrusted when reports are supplied to downstream AI systems. ]]>
