All articles

AI security in product and code: OWASP LLM 2025, RAG isolation, slopsquatting, and cost caps

What actually breaks in production AI products: indirect prompt injection, LLM06 Excessive Agency, cross-tenant RAG leaks, hallucinated packages (slopsquatting), and Denial of Wallet.

Two separate risk surfaces: AI inside your product and AI writing your code

Conversations about “AI risk” often blur two distinct threat surfaces: vulnerabilities in customer-facing LLM features running in production, and vulnerabilities silently introduced by AI assistants while writing your codebase. Both need verification before launch—otherwise a polished UI masks critical flaws until the first real incident.

The most dangerous habit is promoting a prototype built on dummy data straight into production. While the database holds seeded test records, missing server authorization, unconstrained tool calls, or leaked client-side keys look completely invisible in the UI.

OWASP LLM Top 10 (2025): the three risks that hit real businesses hardest

The OWASP Top 10 for Large Language Model Applications (2025 / v2.0) highlights three failure classes that drive the majority of real-world production incidents.

First is LLM01:2025 Prompt Injection—especially Indirect Prompt Injection. Because LLMs process system instructions and external content inside the same context window, an attacker can hide malicious directives inside a PDF resume, support ticket, or webpage. Defense does not rely on a “stronger prompt” alone: treat all user and retrieved text as untrusted data, validate model output against a strict server-side JSON Schema, and never render raw LLM HTML.

Second is LLM06:2025 Excessive Agency. Granting an AI agent broad tool permissions to issue refunds, modify billing plans, send external emails, or run arbitrary database mutations turns a single injection or hallucination into financial damage. Start with human-in-the-loop drafts where the model proposes an action and the server enforces authorization and confirmation independently.

Third is LLM10:2025 Unbounded Consumption (Denial of Wallet). Without hard caps on input/output tokens, per-user rate limits, agent loop depth, and timeouts, a single abusive user or runaway loop can burn a monthly API budget in an hour.

RAG cross-tenant leaks: never use a prompt as an access-control boundary

A common B2B mistake in Retrieval-Augmented Generation (RAG) is indexing every customer’s documents into one shared vector store and instructing the model in the system prompt to “only answer using the current tenant’s files.” A system prompt is not an authorization layer.

Tenant isolation must be deterministic at the storage and retrieval layer: either separate indexes/namespaces per tenant or a mandatory pre-filter injected into the vector query (filter: { tenant_id }) derived strictly from the verified server session or JWT—never from client request parameters. Add automated canary tests with unique markers per tenant to verify that Company A can never retrieve chunks belonging to Company B.

The AI coding supply-chain risk: slopsquatting and leaked secrets

A newer 2025–2026 supply-chain attack vector—coined “slopsquatting” by Python Software Foundation Developer-in-Residence Seth Larson and documented in USENIX Security research—exploits repeatable package hallucinations. LLMs frequently invent plausible, non-existent npm or PyPI package names. Attackers pre-register those exact names with malicious payloads; when a developer or autonomous coding agent blindly runs npm install or pip install, the compromised package executes inside local machines or CI.

Baseline hygiene is straightforward: verify every AI-recommended package on npmjs.com or pypi.org (publish date, maintainer, docs) before installing, enforce lockfile pinning, block autonomous agents from installing unapproved packages, and keep API keys (OpenAI, Gemini, Stripe, service_role) strictly in server environments and a secret manager.

Evals, graceful timeouts, and real unit economics

A fluent answer is not a correct answer. Before shipping, assemble a golden evaluation set of 20–50 sanitized real-world cases: ordinary requests, missing context, conflicting rules, out-of-scope questions, and prompt-injection attempts. Define the expected outcome for each (answer, clarify, or escalate to a human) and re-run the suite whenever you change a prompt or upgrade a model.

Design for provider failures explicitly: upstream LLM APIs return 429s, 503s, timeouts, and malformed JSON. Enforce hard timeouts, preserve the user’s draft, cap retries, and surface an honest fallback instead of fabricating output. Measure unit economics by real spend per completed user journey—including retries and system context—rather than the cost of a single clean call in a playground.

What to require at AI feature handoff

A link to a working chat screen is not a production handoff. Require a short operational brief covering: exactly what data is sent to the model provider (and confirmation of zero-data-training API terms), where secrets live, tool permissions and token/rate caps, evaluation-set results, and a kill switch (feature flag) so an on-call engineer can disable the AI module immediately without taking down the rest of the product.

Sources and further reading

OWASP: Top 10 for Large Language Model Applications (2025 / v2.0) ↗

USENIX Security: We Have a Package for You! (LLM Package Hallucinations & Slopsquatting) ↗

Google AI for Developers: Gemini API Structured Outputs & Safety ↗

OWASP API Security Top 10 ↗