---
title: "Security recommendations"
description: "Learn how to handle prompt injection risks when AI Toolkit tools read user-generated document content."
canonical_url: "https://tiptap.dev/docs/ai/ai-toolkit/advanced-guides/security"
---

# Security recommendations

Learn how to handle prompt injection risks when AI Toolkit tools read user-generated document content.

## Mitigate prompt injection attacks

The AI Toolkit's tools, including `tiptapRead` and `getThreads`, can return content from user-generated documents. Content from untrusted sources may contain a prompt injection attack.

The AI Toolkit does not include document content in your system prompt. It returns the content as a tool result instead. However, tool results can still influence an AI model. This can be exploited to create a prompt injection attack by including malicious instructions in the document that the AI model could follow.

If your application needs to mitigate this risk, validate tool output for prompt-injection patterns before passing it to an AI model. Apply the same safeguards you would use for an agent that reads websites or other untrusted sources.

Additionally, require explicit approval from the user before the AI takes any destructive or consequential action. One way to do so is to [integrate the AI Toolkit with Tracked Changes](https://tiptap.dev/docs/ai/ai-toolkit/agents/tracked-changes.md), so that the user can accept and reject every document edit that the AI makes.
