Glossary · AI security & threats
Malicious code in model output
also: output injection
In short
A model’s text output contains conventional attack code such as cross-site scripting. It becomes dangerous once a browser or downstream system processes the output unchecked. Remedy: treat outputs like external inputs, so check and encode them.
Reference: ISO/IEC 27090:2026, 6.10
What it means
A language model produces text, and text can be code. ISO/IEC 27090:2026 describes in 6.10 how a model’s output can contain conventional attacks such as cross-site scripting. This becomes dangerous as soon as a browser or a downstream system interprets the output as a command: as a script on a web page, a database query, a command line or a formula in a spreadsheet.
Where the malicious code comes from is secondary for defence. It may have been injected through prompt injection, stem from manipulated training data or simply be a model error. The standard draws a clear conclusion: if the training data cannot be trusted, neither can the output. Model outputs are therefore subject to the same rules as any input from outside.
In practice and in the audit
Validate and encode model outputs before further processing, in a way that fits the destination: HTML encoding for display in a browser, parameterised queries for databases, fixed command lists instead of freely generated commands. Do not let a model execute code directly in production systems. If it generates code, that code first runs in an isolated environment and goes through a review.
Outputs processed only later are particularly easy to overlook: an AI text copied into an email template, a summary that flows into a ticket system, a generated spreadsheet that someone opens with formulas. Walk through all the paths of your model outputs once. In an audit against ISO/IEC 27001 this belongs to secure coding (Annex A 8.28) and security testing (A 8.29).
References in standards and law
I cite standards by clause number and in my own words, never verbatim. Legal texts link to EUR-Lex.
- ISO/IEC 27090:2026, 6.10Attack code in model outputs, detection and mitigation.
- ISO/IEC 27001:2022, Annex A 8.28Secure coding.
- ISO/IEC 27001:2022, Annex A 8.29Security testing in development and acceptance.
Frequently asked questions
Is it enough to forbid the model in the prompt from outputting code?
No. A ban in the prompt can be bypassed. Protection arises where the output is processed further: through validation, encoding and fixed limits for everything that gets executed.
Related terms
Further reading in the insights
Matching service
Review of self-built AI software
I review your source code for how model outputs are processed further, before the application reaches customers.
To AI securityAuthor: Lars Zimmermann
Term and explanation in my own words. Researched to the best of my knowledge and reviewed for accuracy.