6 AI & LLM Failure Modes Blocking Production Launch (And How to Fix Them)
Traditional security scanners were built for classic CRUD web apps—not chat routes, RAG pipelines, and LangGraph tool-calling agents. That is why our pre-launch audit includes a dedicated AI, LLM & Agent Safety review covering six common failure modes.
| # | Failure Mode | Risk Level |
|---|---|---|
| 1 | Exposed OpenAI, Anthropic, or Gemini keys in client code or git history | Critical |
| 2 | Missing token, rate, and spend caps (runaway AI bills) | Critical |
| 3 | Prompt injection via raw user input in system prompts | High |
| 4 | Unrestricted AI agent tool calling without user-level permission checks | Critical |
| 5 | Unvalidated AI output passed directly to SQL, shell commands, or HTML | Critical |
| 6 | Sensitive customer PII logged or sent to unapproved models | High |
1. Exposed AI Provider Keys
Prototype generators frequently place
NEXT_PUBLIC_OPENAI_API_KEY in browser code or commit
keys in test scripts. Move all model calls behind authenticated
server routes and scan git history with Gitleaks before launch.
2. Runaway AI Billing Abuse
A public /api/chat endpoint without server-side
auth, per-IP/per-user rate limiting, and explicit
max_tokens caps allows a single script to exhaust
monthly AI credits in minutes. Enforce Redis/Upstash rate
limits, token budgets, and hard provider spend caps.
3. Prompt Injection in System Instructions
Interpolating untrusted user input or retrieved document chunks directly into privileged system prompt strings lets attackers override instructions. Keep system prompts strictly separated from user messages, validate structured outputs with Pydantic or Zod, and treat RAG context as untrusted data.
4. Unrestricted Agent Tool Calling
When a LangChain or LangGraph agent can invoke database queries, email senders, or refund tools without per-tool authorization, prompt injection turns directly into unauthorized actions. Every tool must verify the authenticated user’s tenant ID and role—and require human confirmation for destructive or billing operations.
5. Unvalidated AI Output Passed to SQL, Shell, or DOM
Never execute raw SQL generated by a model or render raw HTML
into React with dangerouslySetInnerHTML. Use
parameterized queries, strict allowlisted schemas, and HTML
sanitization.
6. Customer PII Leakage to Logs or Unapproved Models
Debug logging full prompt/response payloads often captures user emails, tokens, and customer records in plain-text log sinks. Redact PII before logging and restrict outbound calls to approved model endpoints with appropriate data-retention terms.
Audit Your AI / LLM Stack in 72 Hours