caelo

Caelo › Guides › Prompt injection in AI apps

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

By Arthi Arumugam, Irth Labs · Published · Updated

Short answerPrompt 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

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

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 mitigationWhat it means in practice
Constrain model behaviorA system prompt that defines the role and the allowed topics. Useful, but not a security boundary.
Define and validate expected output formatsAsk for JSON with a schema and reject anything that does not parse, before acting on it.
Implement input and output filteringCap input length, strip hidden text from fetched pages, and check output for secrets or links before showing it.
Enforce privilege control and least privilege accessTools 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 actionsRefunds, deletes, emails to customers and payments wait for a person.
Segregate and identify external contentPut 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 simulationsBefore 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.

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. Act on a finding

Follow the fix in your report and run Caelo again. If Git could commit an untracked file containing secrets, preview a US$19 quick fix for that file.

For findings that need an engineer, Irth Labs offers a US$490 App Health Check. You receive a written report within 48 hours and a fixed repair quote. The fee counts toward the repair if you proceed.

Book the App Health Check See repair services

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