Anyone can write to a chatbot, so every message must be treated as untrusted input. Security does not rest on a single filter but on layers: before the model, around the model and after the model.
The guide summarises OWASP's LLM recommendations, the OpenAI API's documented data handling and the GDPR information duty. It is general information, not legal advice.
1. What is prompt injection?
According to OWASP, prompt injection exists when user input changes a language model's behaviour or output in unintended ways. It can be direct (the visitor types it) or indirect (hidden in external content the model processes). OWASP also notes that, because of the stochastic nature of generative AI, it is unclear whether fool-proof prevention exists, so layered defences are needed.
2. Layers of defence
| Layer | Mit tesz? | Where it works |
|---|---|---|
| Input screening and blocked topics | Rejects obvious abuse, off-topic requests and requests for other customers' data. | Before the model |
| Strict role and response schema | The model may only answer in the given role and a predefined format. | At the model call |
| Least privilege | The model gets no tools, network or database access; it only sees a few selected excerpts. | In the system design |
| Output validation | Code checks the reply: no links, markup or secret-like text. | After the model |
| Human handover | What cannot be answered safely goes to the team as a ticket. | At the end of the flow |
3. Privacy in practice
- A visitor's message can contain personal data even if you did not ask for it: plan for this in the privacy notice and the retention period.
- Under Article 13 GDPR, when data is collected the data subject must be told, among other things, who the controller is, the purpose, the legal basis, the recipients, the retention period and their rights.
- Set a retention period for conversation logs and delete them automatically; store IP addresses only as keyed hashes, if at all.
- Check which provider processes the messages. According to OpenAI's documentation, data sent to the API is not used to train models, and abuse-monitoring logs are by default kept for up to 30 days unless the law or protection of the service requires longer.
- Give visitors a simple way to submit a deletion or access request.
4. Human handover and transparency
- The chatbot should openly introduce itself as an AI assistant (AI Act Article 50(1)).
- If it cannot answer it should not guess: it offers a contact and asks for consent to data processing before collecting a name and e-mail address.
- The ticket goes to the team and the visitor receives a confirmation.
- Set a deadline for answering enquiries and measure how long answers take.
5. Regular testing
- Test the chatbot from time to time with trial attacks (for example “ignore the previous instructions”). OWASP recommends regular adversarial testing and treating the model as an untrusted user.
- Review the refused requests in the logs: they show what people are trying.
- Document who is responsible for the knowledge base, the logs and handling deletion requests.



