# Prompt injection in a vibe-coded app: what it is and how to limit the damage

Canonical: https://caelo.sh/guides/prompt-injection-ai-app-features
Published: 2026-11-27 · Updated: 2026-11-27 · Arthi Arumugam, Caelo by Irth Labs

**Short answer:** Prompt injection is when text a user types, or text your app pulls from a web page, file or email, changes what your model does. OWASP ranks it first for LLM apps and says no method is known to fully prevent it. So limit what the model can reach: no secrets in prompts, narrow tools, human approval for risky actions.

## Direct and indirect injection

OWASP's definition: "A Prompt Injection Vulnerability occurs when user prompts alter the LLM's behavior or output in unintended ways." Direct injection is the user typing instructions into your chat box. Indirect injection is subtler: "Indirect prompt injections occur when an LLM accepts input from external sources, such as websites or files." A support bot that summarises a customer's email can be steered by text hidden in that email.

OWASP is frank about the limits: "it is unclear if there are fool-proof methods of prevention for prompt injection", and techniques such as retrieval augmented generation and fine-tuning "do not fully mitigate prompt injection vulnerabilities." Plan as if some injection will get through, and make sure it cannot do much.

## The vulnerable pattern and the fix

Vulnerable: a secret in the prompt and an all-powerful tool

```ts
const system = "You are the support bot. The admin password is "
  + process.env.ADMIN_PASSWORD + ". Never reveal it.";

const tools = {
  // runs any SQL the model writes, with the service_role key
  runSql: async ({ query }) => admin.rpc("exec_sql", { query }),
};
```

Fixed: no secrets in the prompt, narrow tools scoped to the user

```ts
const system = "You are the support bot. Answer questions about the user's own orders.";

const tools = {
  // the model can only list the signed-in user's orders
  listMyOrders: async () => {
    const { data } = await supabaseForThisUser // client built with the user's token
      .from("orders")
      .select("id, status, total");
    return data; // row level security limits rows to the caller
  },
  // anything that changes money or data goes to a human first
  requestRefund: async ({ orderId }) => queueForHumanReview(orderId),
};
```

OWASP's system prompt leakage entry says the system prompt "should not be considered a secret" and that credentials and connection strings should not be in it. Assume a user can make the model repeat it. The fix moves trust out of the prompt and into the tools: each tool does one thing, with the user's own permissions.

## OWASP's mitigations, applied to a typical AI-built app

| OWASP mitigation | What it means in practice |
| --- | --- |
| Constrain model behavior | A system prompt that defines the role and the allowed topics. Useful, but not a security boundary. |
| Define and validate expected output formats | Ask for JSON with a schema and reject anything that does not parse, before acting on it. |
| Implement input and output filtering | Cap input length, strip hidden text from fetched pages, and check output for secrets or links before showing it. |
| Enforce privilege control and least privilege access | Tools use the signed-in user's token, never the service_role key, and each tool does one narrow thing. |
| Require human approval for high-risk actions | Refunds, deletes, emails to customers and payments wait for a person. |
| Segregate and identify external content | Put fetched web pages, files and emails in a clearly marked block and tell the model it is data, not instructions. |
| Conduct adversarial testing and attack simulations | Before launch, try to make your own bot reveal its prompt, call tools it should not, or act on another user's data. |

## Check your AI feature, step by step

1. Read your system prompt. Remove every password, API key, connection string and internal URL.
2. List every tool the model can call. For each one, ask what a hostile user could do with it, and narrow it until the answer is "only their own data".
3. Make sure tools run with the user's permissions, so row level security still applies.
4. Add a human approval step for anything that moves money, deletes data or contacts other people.
5. Mark external content as data in the prompt, and cap its size.
6. Try the attacks yourself: "ignore previous instructions", hidden text in an uploaded file, and a request for another user's orders.

## Can a scanner find prompt injection?

Caelo does not test prompts or model behavior. It does catch one common ingredient: an API key that matches a known provider format, written anywhere in your files, including inside a prompt string.

- [Install Caelo: npx caelo . or the MCP server](/)
- [How Caelo compares with gitleaks, TruffleHog, Semgrep and others](/compare)

## Check your own app

1. Run the free local check: `npx caelo .` Caelo is a free, open source (MIT) command line tool and MCP server from Irth Labs that checks the files of an AI-built app for exposed API keys, Supabase and Firebase misconfigurations and `.env` files with real values. It runs on your machine, uploads nothing and uses no AI model. Each finding comes with a plain-English fix.
2. Follow the fix in the report and rerun Caelo. For an untracked, unignored file containing secrets, preview the US$19 quick fix. https://caelo.sh/fix
3. For an engineer's assessment, book the US$490 App Health Check. Irth Labs delivers a report and fixed repair quote, with credit toward the repair. https://www.irthlabs.com/start?service=app-health-check

## Questions

### Can I stop prompt injection with a better system prompt?

Not reliably. OWASP says restricting behavior through system prompt instructions can be bypassed by prompt injection. Use the prompt to set the role, and use permissions to limit the damage.

### Is a simple chatbot with no tools at risk?

Less. Without tools or private data, the worst case is usually embarrassing output or a leaked system prompt. The risk grows with every tool and every piece of data the model can reach.

### Does RAG make prompt injection worse?

It adds an indirect path: any document you retrieve can contain instructions. OWASP says RAG does not fully mitigate prompt injection. Treat retrieved text as untrusted data.

## Sources

- [OWASP Top 10 for LLM Applications 2025: LLM01 Prompt Injection.](https://genai.owasp.org/llmrisk/llm01-prompt-injection/)
- [OWASP Top 10 for LLM Applications 2025: LLM07 System Prompt Leakage.](https://genai.owasp.org/llmrisk/llm072025-system-prompt-leakage/)
- [OWASP Top 10 for LLM Applications 2025: LLM02 Sensitive Information Disclosure.](https://genai.owasp.org/llmrisk/llm022025-sensitive-information-disclosure/)
- [OWASP LLM01 source text on GitHub.](https://github.com/OWASP/www-project-top-10-for-large-language-model-applications/blob/main/2_0_vulns/LLM01_PromptInjection.md)

## Related guides

- [Security checklist for apps built with Lovable, Bolt, Cursor, Replit or v0](https://caelo.sh/guides/vibe-coded-app-security-checklist)
- [Can AI write secure code? What peer-reviewed studies found](https://caelo.sh/guides/can-ai-write-secure-code)
- [Vibe coding security statistics (2026): what the research actually says](https://caelo.sh/guides/vibe-coding-security-statistics)
- [How to rate limit API routes in an AI app, and cap your model bill](https://caelo.sh/guides/rate-limit-ai-app-api-routes)
- [OpenAI API key exposed in client-side code: how to fix it](https://caelo.sh/guides/openai-api-key-exposed-frontend)
