AI threat catalogueApplication and Integration SecurityProduction
Insecure Output Handling
The application passes an AI model's answers to downstream systems without checks, for example to databases, web pages or command lines. If the output contains malicious code or commands, the system executes them as if they came from a trusted source.
Description
Many AI applications do more than display model answers: they render them as web pages, build database queries from them or run generated program code. Because attackers can steer what the model outputs through their inputs, this gives them indirect access to those downstream systems. Without validation and context-aware encoding of the outputs, classic injection attacks emerge, in which attackers smuggle their own commands into a system: malicious scripts in the browser (XSS), manipulated database commands (SQL injection), and even attacker-supplied code running on the server (remote code execution). The risk grows when the AI application holds more privileges than the person operating it.
Possible impact
A successful attack gives attackers control over parts of the application: they read or alter data, hijack other users' sessions or run their own commands on the servers. For the organisation this means operational disruption, data leakage with notification duties under the GDPR and a loss of customer trust, even though the model itself worked flawlessly.
Example
A maths assistant runs model-generated program code directly on the server to solve calculation tasks. A user phrases the question so that the model produces malicious code; the server executes it and gives the attacker access to the system.
Recommended mitigations (4)
Every mitigation states its control type, effect, implementation level and the reason for the classification.
Treat model output as untrustedOrganizational & process-based
- Effect
- Preventive
- Implementation level
- Application, API & agents, Organization
- Complementary control type
- Technical
- Reason for the classification
- “Treat model output as untrusted” is primarily organizational and process-based: Defined selection, operating, or lifecycle procedures make the control binding and repeatable; complemented by technical implementation.
Output validation and encodingTechnical
- Effect
- Preventive
- Implementation level
- Application, API & agents
- Reason for the classification
- “Output validation and encoding” is primarily technical: System-enforced inspection, transformation, or blocking rules stop or neutralize disallowed content before further processing.
Context-aware sanitizationTechnical
- Effect
- Preventive
- Implementation level
- Application, API & agents
- Reason for the classification
- “Context-aware sanitization” is primarily technical: System-enforced inspection, transformation, or blocking rules stop or neutralize disallowed content before further processing.
Avoid direct execution of model outputTechnical
- Effect
- Preventive
- Implementation level
- Application, API & agents
- Reason for the classification
- “Avoid direct execution of model output” is primarily technical: Safe formats, restrictive defaults, or protective layers reduce unsafe execution paths and exploitable attack surface.
Framework mappings
Verified locations in OWASP, NIST AI RMF, MITRE ATLAS, the EU AI Act and further frameworks. The mappings are taxonomic, not evidence of compliance.
Verified references (8)
Every reference states the framework, the exact location and the publishing organisation.
- OWASP LLM Top 10 LLM05:2025 Improper Output HandlingLLM05:2025 Improper Output Handling, official category page OWASP FoundationOriginal
- NIST AI RMF Section 2.9 Information SecuritySection 2.9, pp. 10–11 National Institute of Standards and Technology (NIST)Original
- MITRE ATLAS AML.T0048 External HarmsATLAS.yaml technique object with id AML.T0048 (pinned release v5.6.0) MITREOriginal
- EU AI Act Article 9(1), 9(2)(a), 9(2)(d) Risk management systemArticle 9(1), 9(2)(a), 9(2)(d), read with Article 9(3) European Union (EUR-Lex)Original
- BSI R16 RCE-Angriffe (Text)Kap. 4, R16, p. 24 Bundesamt für Sicherheit in der Informationstechnik (BSI)Original
- BSI R6 Fehlende Sicherheit von generiertem Code und codeähnlichen Texten (Text)Kap. 4, R6, p. 16 Bundesamt für Sicherheit in der Informationstechnik (BSI)Original
- BIML BIML-LLM inference:8 Unstructured OutputPDF p. 19, [inference:8:unstructured output] Berryville Institute of Machine Learning (BIML)Original
- BIML BIML78 system:9 API EncodingPDF p. 26, [system:9:API encoding] Berryville Institute of Machine Learning (BIML)Original
Related threats
More entries from the topic group Application and Integration Security.
Assess this threat in your own system
The live demo contains all 52 threats of this catalogue, including the EU AI Act and GDPR assessment. The free single modules cover AI risk, the EU AI Act and GDPR. No sign-up; the assessment runs locally in your browser.
Cite this entry
For reports, policies or internal documents; the link leads directly to this entry.
“Insecure Output Handling”. Versatile AI Risk Assessment, AI threat catalogue, as of July 2026. https://www.versatile-ai-risk-assessment.com/en/wissensbasis/threats/insecure-output-handling/