Skip to main content
Waaru
WhatsApp AI agents

Prompt injection in WhatsApp AI agents: safeguards

Tanay PatelAI and full-stack engineer
The short answer

Prompt injection happens when an AI agent treats untrusted content as instructions it should follow. In WhatsApp, that content can arrive in a customer message or a document the agent reads. Protect actions with server-side permissions and validated inputs. A warning in the prompt is only one layer.

Identify the untrusted inputs

A customer can ask a legitimate question and include instructions about how the assistant should behave. A retrieved document can contain the same kind of instruction even when the customer never wrote it.

For example, a document might tell the agent to ignore its usual approval step. Reading that document should not grant new permissions. Treat retrieved text as evidence for an answer, not as authority to change the workflow. OWASP describes direct and indirect prompt injection.

Keep permissions outside the conversation

An agent that answers order questions should receive only the actions it needs. The server must establish the permitted workspace, sending number and customer relationship. The model should not choose those security boundaries from user-supplied text.

Validate the action and its inputs independently. An instruction to reveal another customer's record must fail even if the model requests that lookup. Keep secrets out of prompts and tool results wherever possible. A secret the model never receives cannot be repeated in its reply.

Separate reading from committing a change

Answering a policy question and changing an order carry different consequences. Require an explicit, verified permission path for writes. A customer saying "the manager approved this" is a claim to check, not approval.

For sensitive changes, define the authorised reviewer and the exact action they approve. Do not assume a confirmation sentence in chat is a secure approval mechanism. The AI action guide explains the broader action boundary.

Review the result before it reaches another system

Restrict tool outputs to the fields needed for the task. Check generated arguments before sending them to a CRM, calendar or endpoint. Do not interpret a model-generated URL as permission to send customer data there.

When a source is conflicting or suspicious, stop the action and preserve enough redacted evidence for investigation. Keep the customer's request open with a human owner. Avoid copying the full conversation into a broadly shared incident log.

Use a controlled review checklist

With fictional records in an authorised test environment, check whether customer text can change the workspace, select another person's order, skip an approval or alter the destination of an action. Also review a document containing an instruction unrelated to its factual content.

Record the attempted boundary crossing, the expected rejection and the observed result. A single successful refusal does not prove resistance to every variation. Repeat review when tools, permissions or document sources change. These are review recommendations, not a claim that any production agent is certified secure.

FAQ

Frequently asked questions.

Can a stronger system prompt prevent every injection?

No. Use prompts alongside enforced permissions, constrained actions, input validation and review.

Is retrieved business content always trusted?

No. Its factual relevance does not make instructions embedded in it authoritative.

Research notes

Evidence checked for this article.

  • Prompt injection risks and layered mitigations.

    OWASP · Accessed 2026-10-09

About the author

Tanay Patel

AI and full-stack engineer

Tanay builds production AI systems, agent workflows, and the full-stack software around them. His work focuses on reliable state, recovery, and human handoff.

Read Tanay's engineering notes

Put this into practice on your own number.

The platform is free. AI features are paid separately.