Home
Cybersecurity

Prompt injection: how to protect your AI chatbot

Óliver Vega Lora · CTO at Webimpacto
Published: · 7 min read

What prompt injection is

An AI assistant receives instructions from the company (what it can say, how it should respond) and messages from the user. Prompt injection means slipping in new instructions so the model obeys them over the company's own.

OWASP, the leading organisation in web security, ranks it first on its list of risks for applications built on language models.

There are two variants. Direct injection, when the attacker types into the chat. And indirect injection, when the instruction is hidden in content the assistant reads: a review, a product description, an email or a web page.

What can go wrong in a shop

The damage depends on what the assistant can reach. These are the cases we see most often when reviewing ecommerce assistants:

  • Data leaks: the assistant shows other customers' orders, addresses or emails.
  • False discounts or promises: the assistant offers a price, a coupon or a condition the shop does not give.
  • Unauthorised actions: cancelling orders, changing addresses or starting returns without verifying who they belong to.
  • Leaks of internal instructions, suppliers or margins that should never leave the team.
  • Brand damage: offensive or false answers that someone captures and publishes.

How to protect it

The basic rule is to treat the model as a user you do not fully trust. The important protections sit outside it:

  • Least access: the assistant only sees the data it needs, and only for the identified customer.
  • Sensitive actions (refunds, address changes, discounts) go through system rules or a person, never through the model's judgement alone.
  • Customer identification before discussing a specific order.
  • External content marked as data, not as instructions, and reviewed before it is passed to the model.
  • Per-user usage limits to stop automated attacks.
  • GDPR-compliant conversation logging to detect abuse and improve the rules.

Test it before going live

Before opening an assistant to the public, it is worth attacking it in a controlled way: trying to make it reveal its instructions, show another customer's data, invent a discount or skip a verification. Every attempt that works becomes a new rule outside the model.

These tests are repeated whenever the agent's tools, the data it accesses or the model it uses change.

Frequently asked questions

Can prompt injection be prevented completely?

Today no technique prevents it one hundred per cent. That is why effective protection limits what the assistant can see and do, and leaves sensitive decisions to system rules or to a person.

Is a chatbot that only answers questions also at risk?

The risk is lower if it does not access customer data and cannot take actions, but it exists: it can give false information, promise conditions you don't offer or reveal its internal instructions. It is still worth testing it before going live.

What does GDPR have to do with an AI chatbot?

A chatbot that processes personal data must inform the user, limit the data it collects and store it securely. If the assistant can show one customer's data to another person, it is not only a security problem but also a personal data breach.

Want this applied to your business?

We’ll tell you what we would do in your case, no strings attached. A real person from the team replies.

Request a proposal
By
Óliver Vega Lora
CTO at Webimpacto · Webimpacto

Head of technology at Webimpacto. He leads the development teams that build, migrate and maintain shops on Shopify, PrestaShop, Adobe Commerce, VTEX and WooCommerce.