OWASP LLM05, improper output handling, is the failure to validate and encode model output before it reaches another system. It maps to the compliance duties you already have for injection prevention, secure development, least privilege and monitoring. The fix is old: treat the model as an untrusted user.
What does OWASP say LLM05 is?
OWASP describes it as the failure to properly validate, sanitize and handle LLM outputs before they reach downstream components. Because a prompt can influence what the model produces, this gives users indirect access to functionality they should not have. Consequences it names include XSS, CSRF, SSRF, privilege escalation and remote code execution.
Its examples are concrete: model output passed into a shell or an eval style function, generated JavaScript or Markdown rendered in a browser, model written SQL run without parameterization, output used to build file paths, and generated text dropped into email templates without escaping.
None of that is exotic. It is the same class of bug we have fought for twenty years, now with a text generator as the source of the input.
What does OWASP recommend?
- Treat the model as an untrusted user, apply zero trust principles and validate responses before they reach backend functions.
- Follow OWASP ASVS guidance for input validation and sanitization.
- Encode model output before returning it to users.
- Use output encoding that matches the destination, such as HTML encoding for web content or SQL escaping for queries.
- Use parameterized queries or prepared statements for database operations involving model output.
- Enforce strict Content Security Policies.
- Deploy logging and monitoring to detect unusual output patterns.
How does that map to compliance frameworks?
We will not cite clause numbers we have not verified. The mapping below is by duty, and you should find the exact clause in the version of the framework your auditor uses.
Secure development practices. NIST's Secure Software Development Framework groups practices into Prepare the Organization, Protect the Software, Produce Well-Secured Software and Respond to Vulnerabilities. Output validation and encoding belong under producing well secured software. For AI systems, NIST's companion SP 800-218A extends the framework to generative AI and dual use foundation models, and is meant to be used alongside the base document.
Injection and secure coding duties. Payment, privacy and security standards generally expect software to be developed so that injection flaws are prevented. If your application executes model output as code or query, an auditor reading your secure coding control will expect the model to be in scope.
Access control and least privilege. OWASP lists excessive privilege as an aggravating factor. A model wired to a tool with broad rights makes every output handling bug worse. Your access control evidence should cover the identity that the model's tools run as.
Logging and monitoring. OWASP's last recommendation is monitoring for unusual output. That ties to any control that asks for detection and review of security events.
Change management. Prompts, tools and model versions change behavior. Treat them as changes that need review, testing and a rollback path.
A working checklist
- List every place model output goes: a browser, a database, a shell, a file path, an email, another service.
- For each, write the encoding or validation rule that applies to that destination.
- Remove any path where output is executed. If one must exist, add a human approval step.
- Use parameterized queries wherever a model touches data stores.
- Set a Content Security Policy on pages that render model text.
- Run the model's tools with the least privilege that works.
- Log output anomalies and review them on a schedule.
- Add tests that feed hostile looking output into each destination and confirm it is neutralized. Use harmless strings, not working exploits.
- Record all of this in the control narrative your auditor will read.
What does a scanner help with?
Static analysis and dependency scanning can find unsafe sinks in your code, such as eval or string built SQL, which are the places where model output becomes dangerous. They cannot see what a model will say. Safeguard's CLI and IDE extensions include security scanning as you code, and none of that substitutes for designing the destination to be safe.
Quick check
Is LLM05 the same as prompt injection?
No. Prompt injection influences what the model says. Improper output handling is what your application does with the answer. The first can cause the second, but the second is yours to fix.
What is the core fix?
Treat model output as untrusted input at every destination, and encode or parameterize it for that destination.
Sources
- OWASP GenAI: LLM05:2025 Improper Output Handling
- NIST: Secure Software Development Framework
- NIST SP 800-218A
Last reviewed: 18 October 2026.