Skip to the content
AI and Cybersecurity Learning and Practice Center Test automation Open the Learning Center

WeaknessASC-2026-0017Major weakness

Improper handling of model output (XSS, SQL and command injection)

HighMitigated

Applications pass model output into HTML, SQL, shell commands, templates or eval as if it were trusted. Anyone who can influence the model, directly or through content it reads, can then inject into those sinks. A terminal is a sink too: output carrying ANSI escape codes can change what a command-line tool's terminal shows or does.

How to detect it

  • Model output reaches innerHTML, a SQL string, a shell, eval or a template without encoding
  • Generated markdown is rendered with raw HTML enabled
  • Model output printed to a terminal without encoding control characters

How to resolve it

  • Treat model output as untrusted user input at every sink
  • Use parameterized queries, argument arrays instead of shell strings, and context-aware output encoding
  • Render markdown with raw HTML disabled and sanitize the result
  • Never pass model output to eval, exec or dynamic imports
  • Encode or strip ANSI control characters before printing model output to a terminal

How to investigate

  1. Search application logs for model outputs containing script tags, SQL keywords or shell metacharacters
  2. Review the code paths where output is used and add encoding at each sink

Sources

Open it in the Learning Center's vulnerability database